@temporary-escape/mod-sdk
Enumerations
| Enumeration | Description |
|---|---|
| CborTags | CBOR tags the engine uses for math types (mirrors Engine::Cbor::Tags). |
| CborType | CBOR major types (the top three bits of the initial byte). |
| CollisionFlags | - |
| CollisionMask | - |
| CombatRole | How a ship fights — mirrors Engine::CombatRole (src/Engine/Types/CombatRole.hpp). Configured on the agent component; the engine Engage action reads it to pick the movement. No guessing/captain logic yet: the player sets it explicitly. |
| DestroyReason | Reason an entity is being removed, forwarded to a template's onDestroy hook. |
| Hostility | Mirrors Engine::AI::Hostility. |
| IconCategory | - |
| IconType | - |
| NodeType | Mirrors Engine::AI::NodeType (v1 built-in node catalog). |
| Runtime | The kind of host that loaded this module: a dedicated server script (once per process) or a per-sector script (once per SectorInstance). |
| SymmetryAxis | Axis around which the procedural template generator mirrors its result. |
| TargetKind | Mirrors Engine::AI::TargetKind. |
Classes
| Class | Description |
|---|---|
| AbiMapStringU64 | A guest Map<string, u64> laid out as the canonical-ABI in-memory representation of list<tuple<string, u64>>: one 16-byte element per entry, a UTF-8 key (ptr: u32, len: u32) at offset 0 and the u64 value at offset 8. |
| AbiStringList | A guest list<string> laid out as the canonical-ABI in-memory representation: one 8-byte element per string, each a UTF-8 (ptr: u32, len: u32) pair. |
| Asset | - |
| AssetBlock | - |
| AssetBlockCategory | - |
| AssetFaction | - |
| AssetImage | - |
| AssetModel | - |
| AssetPlanet | - |
| AssetSectorType | - |
| AssetShader | - |
| AssetShipDesign | - |
| AssetSkybox | - |
| AssetSound | - |
| AssetSystemType | - |
| AssetTemplate | - |
| AssetTexture | - |
| AssetTurret | - |
| BehaviorNode | A node in a behavior tree being composed. Wraps the host node id and the owning builder's handle so the typed setter methods target the right node. Setters take a readable parameter name (e.g. setF32("distance", 400)), resolved to a positional index on the host; each returns this for chaining. |
| Behaviors | Behavior-tree composition entry point. Accessible as engine.behaviors. |
| BehaviorTreeBuilder | Composes a behavior tree on the host through the __Behaviors_* host functions. addNode returns a BehaviorNode wrapper; createKey allocates a mod-defined blackboard key; register consumes the builder, after which the tree is addressable by name from ComponentAgent.behaviorName. |
| BlackboardKey | Mirrors Engine::AI::BlackboardKey — a slot index into a behavior's key table. During composition it also carries the owning builder's handle so a default value can be attached via setF32/setBool/... (each returns this for chaining); at runtime only slot is meaningful. |
| CborEncoder | Streaming CBOR encoder that writes into a growable in-guest buffer. |
| CborField | A single named field of a document map. decode must consume exactly one CBOR item from the visitor; encode must write exactly one CBOR item to the encoder (the map key is written by decodeMap/encodeMap). |
| CborVisitor | Streaming cursor over a CBOR encoded buffer (guest side, no host calls). |
| Commands | Sector console command registry. Accessible as engine.commands. |
| Cursor | Base class for cursors that iterate over documents. |
| Database | The shared document-database API, implemented by TransactionalDatabase and Transaction. |
| DocumentCursor | A document cursor that can iterate over documents in a database. |
| Engine | - |
| Entity | - |
| EntityTemplate | A built entity template: an optional callback per lifecycle hook. |
| EntityTemplateBuilder | Builder for an EntityTemplate. |
| FactionHomeData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| FactionLabelsData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| FactionSpawnLocationData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| FleetData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| GalaxyData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| GameServer | - |
| Generators | Reusable sector generators. Accessible as engine.generators. |
| IndexCursor | A cursor that iterates over the documents matching an index lookup. |
| IndexKey | Builders for the individual components of a document index key. |
| IndexKeySlots | The four u64 hash slots of the fixed-arity index ABI. The host always receives four values; only the first count are meaningful. |
| IndexResult | A document returned by an index lookup: its database id together with the decoded document value. |
| LabelValue | Mirrors the engine's LabelValue variant (`string |
| Logger | - |
| Matrix3f | - |
| Matrix4f | - |
| OptionalF32 | std::optional<float> equivalent for CBOR documents. AssemblyScript does not allow nullable value types, so a present flag accompanies the value; the wire format is either the float or CBOR null, matching the engine. |
| OptionalU64 | std::optional<uint64_t> equivalent for CBOR documents. AssemblyScript does not allow nullable value types, so a present flag accompanies the value; the wire format is either the integer or CBOR null, matching the engine. |
| OptionIdStrRet | A canonical-ABI option<(u64, list<u8>)> return: a one-byte discriminant (0 = none, 1 = some) at the return area, followed by the u64 payload at offset 8 (the tuple's 8-byte alignment) and the (ptr, len) byte-list payload at offset 16. Used by index lookups, which return the document id together with the document. |
| OptionStrRet | A canonical-ABI option<list<u8>> / option<string> return: a one-byte discriminant (0 = none, 1 = some) at the return area, followed by the (ptr, len) payload aligned to 4. Absence is the discriminant — an empty (present) value is distinct from none. |
| PlayerData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| PlayerFactionStandingData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| Quaternion | - |
| Random | Deterministic PCG32 generator. |
| RegionData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| Registry | - |
| Scene | - |
| SectorData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| SectorInstance | - |
| SectorPlayerExploredData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| SectorSaveData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| Serializable | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| ServerInfoData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| ShipData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| ShipLocationData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| ShipWarpTicketData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| SignalData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| SignalPlayerAdminCommand | Payload for an admin command routed through a signal. The signal name is the command's configured target, so it is not fixed. |
| Signals | Sector signal registry. Accessible as engine.signals. |
| SignalSpawnShip | Sent to a sector to spawn a ship from a ship design. Mirrors C++ Engine::SignalSpawnShip in src/Engine/Server/Signals.hpp. |
| SpawnArgs | Encoded spawn arguments, owned by the caller for the duration of the call. |
| SpawnArgsBuilder | Builder for the CBOR map passed to Scene.spawn. |
| SpawnArgsView | Read-only view over the spawn arguments a template's onSpawn receives. The backing buffer is owned by the host and only valid for the duration of the hook; copy anything you need to keep. |
| SpawnContext | Context passed to a generator. A generator is a reusable, generation-only function referenced from a sector type's spawns list. It receives a seeded RNG and may spawn any number of ordinary entities. |
| StrRet | A bare (ptr, len) pair written by the host into a canonical-ABI return area for a non-optional string/list. Absence is not represented here — use OptionStrRet for an option<T>. |
| SystemConnectionData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| SystemData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| SystemGateData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| SystemLabelsData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| SystemPlanetData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| SystemPlayerExploredData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| Templates | Template registry entry points. Accessible as engine.templates. |
| TickCounterData | Base class for CBOR-serializable documents. The pack/unpack members are usually generated from the field declarations by the SDK AssemblyScript transform (see sdk/transform.js), which is why this is a class with concrete defaults rather than an interface: the IDE sees the inherited members and does not flag a class Foo extends Serializable as missing them. |
| TimePoint | A UTC timestamp split into seconds since the Unix epoch and the sub-second nanosecond remainder. Mirrors the engine's CBOR extendedTime (tag 1001) representation of std::chrono::system_clock::time_point. |
| Transaction | Database transaction that uses a snapshot of the database at the time of the creation of the transaction. Any changes made to the database are not persisted until the transaction is committed. |
| TransactionalDatabase | The shared document-database API, implemented by TransactionalDatabase and Transaction. |
| Utf8String | A UTF-8 encoded copy of an AssemblyScript string. The backing buffer is retained so its (dataStart, length) pair can be borrowed by a host import for the duration of the call; the object can be released once the call returns. |
| Vector2b | - |
| Vector2d | - |
| Vector2f | - |
| Vector2i | - |
| Vector3b | - |
| Vector3d | - |
| Vector3f | - |
| Vector3i | - |
| Vector4b | - |
| Vector4d | - |
| Vector4f | - |
| Vector4i | - |
Type Aliases
| Type Alias | Description |
|---|---|
| CapabilityId | - |
| CborDecodeFunc | A single named field of a document map. set must consume exactly one CBOR item from the visitor. |
| CborEncodeFunc | - |
| CommandCallback | A console command callback. shipId is zero when the invoking player is not controlling a ship, and entityId is NullEntity when there is no controllable scene entity. The returned string is the complete console output; return an empty string for no output. |
| DestroyCallback | - |
| EntityId | - |
| GeneratorFn | - |
| InitCallback | An init callback, invoked with the Runtime the module is running in. Must be a module-level function (or a top-level arrow referencing only module-level values); AssemblyScript 0.28.20 does not implement closures that capture function locals. |
| LoadCallback | - |
| SaveCallback | - |
| SignalCallback | Callback invoked with the decoded payload of a registered signal. |
| SpawnCallback | Typed template hooks. The builder stores the callback, and a single plain trampoline per hook kind dispatches to it using the slot the host passes back. AssemblyScript 0.28.20 does not implement closures, so callbacks must be module-level functions (or methods whose receiver is not captured). |
Variables
| Variable | Description |
|---|---|
| DEG_TO_RAD | - |
| engine | - |
| METERS_TO_UNITS | - |
| NullEntity | - |
| RAD_TO_DEG | - |
| UNITS_TO_METERS | - |
Functions
| Function | Description |
|---|---|
| addOnInit | Registers a callback that runs when the host calls onInit. The callback receives the current Runtime and is responsible for checking it (for example, sector-only content guards on runtime == Runtime.Sector). |
| allocOptionIdStrRet | Allocates a raw 24-byte canonical-ABI option<(u64, (ptr, len))> return area. |
| allocOptionRet | Allocates a raw 12-byte canonical-ABI option<(ptr, len)> return area. |
| allocRet | Allocates a raw 8-byte canonical-ABI return area (two u32 cells). |
| cabi_realloc | Canonical-ABI allocation entry point, exported by the module and called reentrantly by the host to allocate inside the guest's linear memory. |
| decodeMap | Decodes a CBOR map into self using the given field table. Mirrors the C++ CBOR_DEFINE_MAP unpack behaviour: unknown keys abort, missing fields keep their defaults. |
| encodeMap | Encodes self as a CBOR map using the given field table. Mirrors the C++ CBOR_DEFINE_MAP pack behaviour: fields are written in table order. |
| encodeSignal | Encodes a Signal document envelope for insertion into the database. |
| field | - |
| findRandomFreePosition | Placement inside a bounded region: picks a deterministic random position that does not overlap any existing collision body, within a disc around center. Use this for content placed as part of world generation (stations, structures) where the region is known. |
| findRandomFreePositionOutward | Placement away from a point: picks a random position on a sphere that does not overlap any existing collision body, starting at distance from center. When a whole ring is occupied (e.g. the centre is inside an asteroid field) the next ring is further out, so the search keeps expanding. Use this for spawning relative to a point (a command, a player) rather than filling a known region. |
| fnv1a64 | FNV-1a 64-bit hash of the UTF-8 bytes of value. See fnv1a64Bytes. |
| hostRandomSeed | A non-deterministic 64-bit seed from the host's OS entropy source. |
| newEntityTemplate | - |
| onInit | Host entry point. Every mod re-exports this as its onInit export; the host (SectorInstance/GameServer) invokes it after the owning instance is set up. Callbacks are drained so a second onInit on the same instance is a no-op. |
| parseSymmetryAxis | Parses a spawn-arg symmetry value ("x", "y", "z" or "none", case-insensitive) into a SymmetryAxis. An empty value counts as None. |
| readOptionIdStrRet | Reads and releases an option<(id, doc)> return area written by the host. |
| readOptionStrRet | Reads the discriminant and (ptr, len) payload a host import wrote into retPtr. |
| readRetAsArrayU64 | - |
| readRetAsString | Reads a string and releases a buffer previously allocated by the host. |
| readStrList | Reads a canonical-ABI list<string> that the host lowered into guest memory. The host transfers ownership, so the element buffers and the element array are released here. An empty (present) list/string is a non-null dangling pointer with len == 0; those must not be freed. |
| readStrListRet | Reads a list<string> return area written by the host and releases it. |
| readStrRet | Reads and releases a (ptr, len) return area previously written by the host. |
| splitmix64 | SplitMix64, used to derive the PCG stream selector from the seed. Kept public so callers can derive independent child seeds with the same function. |
| toIndexKeySlots | Packs up to four pre-hashed index values into the (count, h0..h3) ABI. The host rejects a count above the database's indexed-field limit. |
| writeStrRet | Writes a guest-owned UTF-8 string into a canonical-ABI return area. The backing bytes are allocated with heap.alloc (not GC-managed) so they remain valid after the callback returns; ownership transfers to the host, which frees them after reading. |
