makeEntityId
SourceCreates an opaque entity id from a runtime integer id.
This is a low-level constructor used by the runtime and command system. The value it stores is the stable per-runtime numeric identity exposed on EntityId.
Runtime
Entity identities, proofs, and long-lived handles.
This module defines the nominal entity reference types used across queries, commands, relations, and lookup APIs.
In practical game code, it separates short-lived "current runtime entity" identity from durable references that may survive across frames inside components, resources, or events. That distinction is essential for keeping liveness uncertainty explicit instead of pretending a saved reference proves the entity still exists.
// Turn a current frame entity id into a durable reference.
const handle = Game.Entity.handle(playerId)
// Add an intent when later resolution should require one component proof.
const positioned = Game.Entity.handle(playerId, Position)
Creates an opaque entity id from a runtime integer id.
makeHandleCreates a durable handle from a runtime entity id.
handleConverts a current entity into a durable handle for storage.
decodeHandleDecodes a handle from untrusted data, such as a component value inside a snapshot. Use it in the constructor of a component or resource that stores handles, so restoring validates them like any other value.
draftCreates a typed entity draft from an id and a proof.
refCreates a read-only entity proof value.
mutCreates a mutable entity proof value.
Explicit helpers for constructing and refining entity ids and handles.
Creates an opaque entity id from a runtime integer id.
This is a low-level constructor used by the runtime and command system. The value it stores is the stable per-runtime numeric identity exposed on EntityId.
Creates a durable handle from a runtime entity id.
This is a low-level constructor used by the bound Game.Entity helpers and by runtime lookup resolution.
Converts a current entity into a durable handle for storage.
The handle is storage-safe, not a proof of liveness: resolve it later with lookup.getHandle(...), which fails explicitly when the entity is gone.
Pass an intent component when later code assumes a role such as "player" or "damage source". An intent does not prove the component is still present; it forces resolution through a query that proves it.
const any = Game.Entity.handle(match.entity)
const player = Game.Entity.handle(playerId, Player)
Decodes a handle from untrusted data, such as a component value inside a snapshot. Use it in the constructor of a component or resource that stores handles, so restoring validates them like any other value.
A handle only names an entity; it never proves the entity exists. Resolving it with lookup.getHandle(...) stays the checked step, so any positive integer id decodes.
const Target = Descriptor.ConstructedComponent({
result: (raw: unknown) => {
const enemy = Entity.decodeHandle(Root, isRecord(raw) ? raw["enemy"] : undefined, Health)
return enemy.ok ? Result.success({ enemy: enemy.value }) : enemy
}
})("Target")
Creates a typed entity draft from an id and a proof.
Creates a read-only entity proof value.
Creates a mutable entity proof value.