Skip to content

MapExpansionsApi

public static class MapExpansionsApi

Namespace MapExpansions

Entry point for mods that add or use map expansions.

public const string ApiVersion = "0.4.0"

Version of this API. Raised when a public member changes.

public static IReadOnlyList<string> Expansions { get; }

Ids of all registered expansions, in registration order.

public static event Action<string> ExpansionReady

Raised when an expansion is placed and joined in the main world, once per world load. The argument is the expansion id.

public static event Action<string, string> WorldStateApplied

Raised after a selected local state’s geometry, grids and navigation have been applied.

public static event Action<int> PeerWorldStateRequested

The 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.

public static bool RequirePeerWorldStateAck(int peerId, long revision)

Hold this peer’s native replication until it acknowledges the specified authoritative revision.

public static bool ConfirmPeerWorldStateAck(int peerId, long revision)

Release native replication only for the matching revision. The consumer authenticates the acknowledgement.

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.

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.

public static string GetWorldState(string expansionId)
public static bool IsWorldStateApplied(string expansionId)

True only after the selected state has been applied in this loaded world.

public static ExpansionState GetState(string expansionId)

Types: ExpansionState

public static bool IsReady(string expansionId)

True while the expansion is placed and joined in the loaded world.

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.

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.

public static bool TryToWorldRotationFromDefinition(
string expansionId,
float localYaw,
out Quaternion rotation)

World rotation of an expansion-local facing in degrees, from the registered definition.

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.

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.

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.

public static Mesh ExtractRendererMesh(MeshRenderer renderer, string name)

Id of the expansion whose region contains the world point, or null.

public static string ExpansionAt(Vector3 world)