Skip to content

MapControl init process

The init process involves 2 phases:

  • Start
  • The first LateUpdate (known as latestart)

Start

Here is what Start does:

  • Reset ScrewPlatform.camischanging to false so the camera won't be fixed somewhere else as the map initialises
  • MainManager.FixSamira called. For more information, consult the samira section section of the music playback system
  • Reset the DeadLanderOmega state (state to 0, detected to false, activeid to -1 and hand to null)
  • If the skybox is present and we are not in an inside, the skybox's shader _Tint is set to pure gray

Camera gets initialised with the following fields (the default value is picked if the field's magnitude is 0.2 or below):

Value Field Default
instance.camoffset camoffset defaultcamoffset
instance.camangleoffset camangle defaultcamangle
  • mainmesh gets a default value of the first child object if it was null
  • mainrender gets a default value of the mainmesh's Renderer if it was null
  • musicpreload set to a new list
  • If areaid isn't the current one, MainManager.UpdateArea is called with the new area. For more information, check the areaid section of the map identification documentation
  • actualcenter set to centralpoint
  • If there are any canfollowID elements, tempfollowers is initialised to a new list
  • instance.battlestage set to battlemap (this becomes the default stage to use on StartBattle if the stageid is -1)
  • The TextAsset of the map's dialogues is located and loaded. For more details on how this is done, check the dialogues section of the SetText configuration documentation
  • If the dialogues file loaded sucessfully, dialogues is set to its data whose endlines are normalised to LF and split by LF
  • If useglobalcommand is true, the GlobalCommand system is enabled. Check the documentation to learn more
  • CreateEntities called which initialises entities
  • The skybox gets set:
    • If skyboxmat exists, skybox gets set to it and if we aren't in an inside, its shader _Tint gets set to pure gray
    • Otherwise, skybox gets set to null and the MainCamera's backgroundColor gets set to pure black
  • GetSkyColor called which just sets skycolor's alpha to 1.0 (fully opaque)
  • If not inevent and keepmusic is false, Music is called which sets the music and initialises some music fields
  • CheckDisc is invoked in 1.0 seconds which will set hiddenitem to 100 (only the fact it's not null matters) which will allow the Detector medal to beep under specific conditions. Check the discoveryids documentation to learn more as this array is heavily involved in the checks for this
  • All flowerbed of all playerdata entities gets destroyed if any exists
  • render gets set to all MeshRenderer under in the children of mainmesh
  • mapflags is initialised to 10 elements
  • GetDigWalls called which sets digwall with the following:
    • All GameObjects with DigWall tag are found and all their first Collider are added to digwall
    • All GameObjects with Respawn tag have their layer set to 0 (Default) and if they have a BoxCollider, it is set to be trigger

The fog settings are configured with fields:

Value Field
fogEndDistance fogend
fogColor fogcolor
ambientLight globallight
  • SetScreenEffect called which will only do something if screeneffect is SunRaysTopRight. If it is, a new Prefabs/Particles/SunRay is instantiated childed to the GUICamera with a local position of (9.0, 7.0, 10.0) without rotations
  • RefreshInsides is called without inside and without caller which forces the initial state of the map to be outside
  • CheckQuests called
  • RefreshEntities called with forceanim and refreshmap
  • CheckAchievement called which updates the records's states
  • AreaSpecific called
  • HelperMedalCheck called which will set flags 716 to true and add the Helper medal to badgeshops[0] (Merab) if flags 716 was false and any of the following flags is true (NOTE: only 514 and 298 matters because every other should imply 298 under normal gameplay):
    • 514 (Completed the Help Me Get it Back! quest)
    • 498 (Completed the Explorer Check! quest)
    • 610 (Beaten Maki’s team for the first time)
    • 135 (Completed the Requesting Assistance quest)
    • 704 (Completed the A New Hope quest)
    • 391 (Completed the Butler Missing Again! quest)
    • 298 (Beat the Dune Scorpion in chapter 4)
    • 709 (Completed the Loose Ends quest)
  • UpdateShops gets called which will randomly shuffle all availablebadgepool arrays (this changes the items on the shelf of the shops and updates flags 587's value which is true only when all Merab's medals were bought)
  • If insidetypes length isn't the insides one, insidetypes gets truncated to have a matching length
  • The shader global GlobalIceRadius is set to 0.0
  • If mapid is BugariaResidential, CombineMesh is invoked in 0.1 seconds. Check the merged mesh documentation to learn more

First LateUpdate (latestart)

  • tempfollowers gets updated from instance.extrafollowers using canfollowID and chompy gets set if needed. Check the follower system documentation to learn more
  • SetParticles called. See the particles level documentation to learn more
  • PreloadSprites is invoked in 0.1 seconds which will set entitysprite to each of entities's sprite's texture
  • If faderchange is true:
    • faders is set to all Fader in this map
    • fss is set to all the enablement of all faders
  • SetPlayerColliders is invoked in 0.2 seconds. See the entityonly documentation to learn more
  • latestart is set to true which blocks this logic from happening again