MapExpansionsApi
public static class MapExpansionsApiNamespace MapExpansions
Entry point for mods that add or use map expansions.
Fields
Section titled “Fields”ApiVersion
Section titled “ApiVersion”public const string ApiVersion = "0.4.0"Version of this API. Raised when a public member changes.
Properties
Section titled “Properties”Expansions
Section titled “Expansions”public static IReadOnlyList<string> Expansions { get; }Ids of all registered expansions, in registration order.
Events
Section titled “Events”ExpansionReady
Section titled “ExpansionReady”public static event Action<string> ExpansionReadyRaised when an expansion is placed and joined in the main world, once per world load. The argument is the expansion id.
WorldStateApplied
Section titled “WorldStateApplied”public static event Action<string, string> WorldStateAppliedRaised after a selected local state’s geometry, grids and navigation have been applied.
PeerWorldStateRequested
Section titled “PeerWorldStateRequested”public static event Action<int> PeerWorldStateRequestedThe host needs the consumer to send this remote peer a complete authoritative world-state snapshot. Raised again every few seconds until the peer acknowledges, so the handler must be safe to repeat.
Methods
Section titled “Methods”RequirePeerWorldStateAck
Section titled “RequirePeerWorldStateAck”public static bool RequirePeerWorldStateAck(int peerId, long revision)Hold this peer’s native replication until it acknowledges the specified authoritative revision.
ConfirmPeerWorldStateAck
Section titled “ConfirmPeerWorldStateAck”public static bool ConfirmPeerWorldStateAck(int peerId, long revision)Release native replication only for the matching revision. The consumer authenticates the acknowledgement.
Register
Section titled “Register”public static bool Register(ExpansionDefinition definition)Types: ExpansionDefinition
Registers an expansion. Call it from OnInitializeMelon; definitions registered after the main menu opened are checked but only built from the next game start on.
Returns False when the id is taken, the definition is null or its check rejected it; the log names the reason.
TrySetWorldState
Section titled “TrySetWorldState”public static bool TrySetWorldState( string expansionId, string stateId, out string error)Selects a named local state, or null for dormant. Before world creation this caches the selection; after placement it applies geometry, property effects and host-owned NPC navigation synchronously. Call on each peer from the consumer’s authoritative snapshot. False retains the cause in error and the log.
GetWorldState
Section titled “GetWorldState”public static string GetWorldState(string expansionId)IsWorldStateApplied
Section titled “IsWorldStateApplied”public static bool IsWorldStateApplied(string expansionId)True only after the selected state has been applied in this loaded world.
GetState
Section titled “GetState”public static ExpansionState GetState(string expansionId)Types: ExpansionState
IsReady
Section titled “IsReady”public static bool IsReady(string expansionId)True while the expansion is placed and joined in the loaded world.
TryToWorld
Section titled “TryToWorld”public static bool TryToWorld( string expansionId, Vector3 local, out Vector3 world)World position of an expansion-local point. False while the expansion is not placed.
TryToWorldFromDefinition
Section titled “TryToWorldFromDefinition”public static bool TryToWorldFromDefinition( string expansionId, Vector3 local, out Vector3 world)World position of an expansion-local point, from the registered definition. It holds before the expansion is placed, for setup code such as NPC spawn points; it says nothing about whether the expansion gets built.
TryToWorldRotationFromDefinition
Section titled “TryToWorldRotationFromDefinition”public static bool TryToWorldRotationFromDefinition( string expansionId, float localYaw, out Quaternion rotation)World rotation of an expansion-local facing in degrees, from the registered definition.
TryToLocal
Section titled “TryToLocal”public static bool TryToLocal( string expansionId, Vector3 world, out Vector3 local)Expansion-local position of a world point. False while the expansion is not placed.
TryResolve
Section titled “TryResolve”public static bool TryResolve( LocationRef location, out Vector3 position, out Quaternion rotation)Types: LocationRef
World position and facing of a named place. False while it is unknown or not placed.
TryGetSourceCharacter
Section titled “TryGetSourceCharacter”public static bool TryGetSourceCharacter( string expansionId, string objectName, out SourceCharacter character)Types: SourceCharacter
A character of the expansion’s source scene by its object name, such as “Pam”. Known from the main menu on, once the source is captured.
ExtractRendererMesh
Section titled “ExtractRendererMesh”public static Mesh ExtractRendererMesh(MeshRenderer renderer, string name)Id of the expansion whose region contains the world point, or null.
ExpansionAt
Section titled “ExpansionAt”public static string ExpansionAt(Vector3 world)