Building areas
A building area is the space the player is building in. These tell you which area the player is in, and when that changes.
Building which building area the player is in
This is the class you start from. CurrentArea tells you which building area the player is in, and AreaEntered and AreaExited tell you when that changes.
public static class Building
{
public static BuildAreaInfo CurrentArea { get; }
public static event Action<BuildAreaInfo> AreaEntered;
public static event Action<BuildAreaInfo> AreaExited;
}
| Property | Type | What it means |
|---|---|---|
CurrentArea | BuildAreaInfo | The area the player is in right now. null when in none. |
| Event | Gives you | When it fires |
|---|---|---|
AreaEntered | BuildAreaInfo | The player has just entered an area. |
AreaExited | BuildAreaInfo | The player has just left an area. |
BuildAreaInfo a snapshot of one building area
CurrentArea and the two area events give you this. CurrentArea is read again each time you ask, while an event carries a snapshot taken at the moment of the change. (It is filled from the game’s FurnitureManager of the active area.)
public sealed class BuildAreaInfo
{
public string ManagerGuid { get; }
public bool RemoveOnly { get; }
public bool BuildMenuDisabled { get; }
public bool NotFullyExamined { get; }
public float NetPower { get; }
}
| Property | Type | What it means |
|---|---|---|
ManagerGuid | string | The id of the area. |
RemoveOnly | bool | true when the area only lets the player take furniture out. |
BuildMenuDisabled | bool | true when the build menu is off here, because the area is disabled or not fully examined. |
NotFullyExamined | bool | true when the area has not been fully examined yet. |
NetPower | float | The total power balance of the area’s furniture. |
Things to know
CurrentAreais the area the player is in right now, and it is read again each time you ask. It isnulloutside any building area and while no building system is loaded. It works even while a save is loading. (It is the game’sBuildingSystem.activeManager.BuildMenuDisabledis the game’s ownBuildMenuDisabled.NotFullyExaminedisFurnitureManager.notFullyExamined.RemoveOnlyis fromFurnitureManager.areaType.NetPowerisFurnitureManager.NetPower.)AreaEnteredfires when the player’s active area changes to an area, andAreaExitedfires when it stops being one. Going straight from area A to area B givesAreaExitedfor A, thenAreaEnteredfor B. Each event carries a snapshot taken at the moment of the change. (Both come from the game’sBuildingArea.EnterandBuildingArea.Exit. The game callsExitfrom insideEnterand from the trigger, and one change still gives one event pair.)- A save load raises no area events, but the first leave after it can look odd. The framework notes the saved area when
Events.Loadedfires, and the game restores the active area a few frames later without telling anyone. So the next exit raisesAreaExitedfor the restored area. (It seeds the last area fromBuildingSystem.activeManagerGUID.) - A map change clears the active area silently, so the next enter or exit is reported against the last area the framework saw. If that area’s object was destroyed by the scene change, its
AreaExitedis skipped. (The map change isBuildingSystem.OnMapChanging.) CurrentAreaalways reads the live value.- No area events fire while a save is loading or saving. The active area is not updated during a save or load, so the first change after it is reported from the area noted before that save or load.
Events.Loadednotes the area again after a load.