Skip to content

7) World Map Handler

Kubo edited this page Apr 21, 2025 · 7 revisions

Classes within Map package allow you to add new World Maps, without lots of code. They also ensure your map will be given a valid ID within the game, as well as handle logic regarding linking maps to eachother, and to custom levels.

Usage

A world map can be registered using following method in FP2Lib.Map.MapHandler

RegisterWorldMap(string uid, string name, GameObject prefab)

Return value indicates if adding the map was successful. Returns true on success. Value of false might imply a map with this uid was already initialised.

  • uid - Unique Identifier for the map. It has to be unique enough to not conflict with other mods - and also convenient enough to type in, since it will be used in few places!
  • name - Name of the map.
  • prefab - GameObject containing the map itself.

The GameObject has to be an object containing entirety of the world map - background, location markers, any extra effects, etc. It should not contain pre-made roads (so don't save the prefab when the game is running in the editor!), as these are built by the game at runtime. Unless of course you wish to make your own roads, and disabled the default ones :3

Easiest way to build it would be to open the AdventureMenu map in Unity Editor, and make a copy of existing world map - this way you can build and test the map in the editor. You can find more loose tips on making a map at: https://github.com/Kuborros/FP2Lib/wiki/99)-Miscelanious-Modding-Notes If you have different water colour than daytime stages, you will wish to add extra colored backing to the prefab to cover the default blue one.

Special logic for setting IDs:

  • Automatic map linking: Since you cannot predict what ID will be given to a specific map, fp2lib comes with automatic means to update the destination ID of any cross-map Exit. The linking is achieved by adding an extra field within the map icon - usually there should be only one field by default, containing the name of the exit. Simply add another field like in the example, containing the UID of destination map. The library will update the destination on the node the icon belongs to automatically.

image

  • Automatic stage/hub linking: Just like above, stage id's are only known after first launch of the game with the mod. Therefore you can use similar trick to automatically set destination stage. For HUBs the steps are identical to the map - add second field, put UID in. Stages contain extra data in the text element, which while unused has to stay otherwise the game will complain. Therefore for stages the 4th field has to be added with UID, like below.

image

The library will make it's best effort to rescue the player in case they make the unwise decision to remove your mod while their character saves are on one of your maps.

Clone this wiki locally