Runtime

entity

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.

Examples

// 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.handleAs(Position, playerId)

Functions

Explicit helpers for constructing and refining entity ids and handles.

makeEntityId

Source

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.

makeHandle

Source

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.

handle

Source

Converts a current runtime id into an unqualified durable handle.

Use this when you need a long-lived reference but do not want to assert any intended component role. Resolve it later with lookup.getHandle(...).

The handle is storage-safe, not a proof of liveness. The entity may have been despawned by the time it is resolved.

const handle = Game.Entity.handle(entityId)

handleAs

Source

Converts a current runtime id into an intent-qualified durable handle.

The extra intent does not prove the entity still has that component later. It only forces resolution through a query that statically proves the component is present.

This is the safer default when the handle will later be used in gameplay logic that assumes a specific role, such as "player", "camera target", or "damage source".

// Preserve that later resolution must prove this is still a player entity.
const handle = Game.Entity.handleAs(Player, playerId)

draft

Source

Creates a typed entity draft from an id and a proof.

ref

Source

Creates a read-only entity proof value.

mut

Source

Creates a mutable entity proof value.