Skip to content

@temporary-escape/mod-sdk ​

Enumerations ​

EnumerationDescription
CborTagsCBOR tags the engine uses for math types (mirrors Engine::Cbor::Tags).
CborTypeCBOR major types (the top three bits of the initial byte).
CollisionFlags-
CollisionMask-
DestroyReasonReason an entity is being removed, forwarded to a template's onDestroy hook.
IconCategory-
IconType-

Classes ​

ClassDescription
Asset-
AssetBlock-
AssetBlockCategory-
AssetFaction-
AssetImage-
AssetModel-
AssetPlanet-
AssetSectorType-
AssetShader-
AssetShipDesign-
AssetSkybox-
AssetSound-
AssetSystemType-
AssetTemplate-
AssetTexture-
AssetTurret-
CborEncoderStreaming CBOR encoder that writes into a growable in-guest buffer.
CborFieldA 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).
CborVisitorStreaming cursor over a CBOR encoded buffer (guest side, no host calls).
CursorBase class for cursors that iterate over documents.
DatabaseThe shared document-database API, implemented by TransactionalDatabase and Transaction.
DocumentCursorA document cursor that can iterate over documents in a database.
Engine-
Entity-
EntityTemplateA built entity template: an optional callback per lifecycle hook.
EntityTemplateBuilderBuilder for an EntityTemplate.
FactionHomeDataBase 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.
FactionLabelsDataBase 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.
FactionSpawnLocationDataBase 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.
FleetDataBase 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.
GalaxyDataBase 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-
GeneratorsReusable sector generators. Accessible as engine.generators.
IndexCursorA cursor that iterates over the documents matching an index lookup.
IndexKeyBuilders for the individual components of a document index key.
IndexKeySlotsThe four u64 hash slots of the fixed-arity index ABI. The host always receives four values; only the first count are meaningful.
IndexResultA document returned by an index lookup: its database id together with the decoded document value.
LabelValueMirrors the engine's LabelValue variant (`string
Logger-
Matrix3f-
Matrix4f-
OptionalF32std::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.
OptionalU64std::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.
OptionIdStrRetA 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.
OptionStrRetA 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.
PlayerDataBase 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.
PlayerFactionStandingDataBase 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-
RandomDeterministic PCG32 generator.
RegionDataBase 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-
SectorDataBase 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-
SectorPlayerExploredDataBase 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.
SectorSaveDataBase 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.
SerializableBase 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.
ServerInfoDataBase 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.
ShipDataBase 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.
ShipLocationDataBase 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.
ShipWarpTicketDataBase 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.
SignalDataBase 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.
SignalPlayerAdminCommandPayload for an admin command routed through a signal. The signal name is the command's configured target, so it is not fixed.
SignalsSector signal registry. Accessible as engine.signals.
SignalSpawnShipSent to a sector to spawn a ship from a ship design. Mirrors C++ Engine::SignalSpawnShip in src/Engine/Server/Signals.hpp.
SpawnArgsEncoded spawn arguments, owned by the caller for the duration of the call.
SpawnArgsBuilderBuilder for the CBOR map passed to Scene.spawn.
SpawnArgsViewRead-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.
SpawnContextContext 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.
StrRetA 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>.
SystemConnectionDataBase 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.
SystemDataBase 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.
SystemGateDataBase 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.
SystemLabelsDataBase 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.
SystemPlanetDataBase 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.
SystemPlayerExploredDataBase 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.
TemplatesTemplate registry entry points. Accessible as engine.templates.
TickCounterDataBase 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.
TimePointA 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.
TransactionDatabase 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.
TransactionalDatabaseThe shared document-database API, implemented by TransactionalDatabase and Transaction.
Utf8StringA 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 AliasDescription
CapabilityId-
CborDecodeFuncA single named field of a document map. set must consume exactly one CBOR item from the visitor.
CborEncodeFunc-
DestroyCallback-
EntityId-
GeneratorFn-
LoadCallback-
SaveCallback-
SignalCallbackCallback invoked with the decoded payload of a registered signal.
SpawnCallbackTyped 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 ​

VariableDescription
DEG_TO_RAD-
engine-
NullEntity-
RAD_TO_DEG-

Functions ​

FunctionDescription
allocOptionIdStrRetAllocates a raw 24-byte canonical-ABI option<(u64, (ptr, len))> return area.
allocOptionRetAllocates a raw 12-byte canonical-ABI option<(ptr, len)> return area.
allocRetAllocates a raw 8-byte canonical-ABI return area (two u32 cells).
cabi_reallocCanonical-ABI allocation entry point, exported by the module and called reentrantly by the host to allocate inside the guest's linear memory.
decodeMapDecodes 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.
encodeMapEncodes self as a CBOR map using the given field table. Mirrors the C++ CBOR_DEFINE_MAP pack behaviour: fields are written in table order.
encodeSignalEncodes a Signal document envelope for insertion into the database.
field-
fnv1a64FNV-1a 64-bit hash of the UTF-8 bytes of value. See fnv1a64Bytes.
newEntityTemplate-
readOptionIdStrRetReads and releases an option<(id, doc)> return area written by the host.
readOptionStrRetReads the discriminant and (ptr, len) payload a host import wrote into retPtr.
readRetAsArrayU64-
readRetAsStringReads a string and releases a buffer previously allocated by the host.
readStrRetReads and releases a (ptr, len) return area previously written by the host.
splitmix64SplitMix64, used to derive the PCG stream selector from the seed. Kept public so callers can derive independent child seeds with the same function.
toIndexKeySlotsPacks 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.