Defines a component descriptor.
Use this when declaring per-entity data that should participate in queries
and typed entity proofs.
Components are the only descriptor kind that can be queried directly with
Game.Query.read(...), write(...), or optional(...).
const Position = Descriptor.Component<{ x: number; y: number }>()("Position")
Defines a component descriptor that also knows how to validate raw values.
Use this when the component should never exist in the world in an unvalidated
shape, for example vectors, sizes, collider bounds, or other branded domain
values.
// Route raw component input through a constructor once at the boundary.
const Position = Descriptor.ConstructedComponent(Vector2)("Position")
Defines a resource descriptor.
Resources represent unique world-level values accessed through explicit
system specs.
Use resources for singleton world data such as counters, configuration,
global timers, camera summaries, or transient per-frame aggregates that
should not be duplicated across entities.
// Store shared world state once and request it explicitly from systems.
const Score = Descriptor.Resource<number>()("Score")
Defines a resource descriptor that also knows how to validate raw values.
Defines an event descriptor.
Use event descriptors to model append-only messages flowing between systems
without exposing untyped channels.
Writers emit into a pending buffer. Readers observe only the committed
readable buffer after an explicit Game.Schedule.updateEvents() boundary.
const Hit = Descriptor.Event<{ target: number; amount: number }>()("Hit")
Defines a state descriptor.
States are singleton schema values with no queued transition semantics.
Use this when you need one current world-level value and the boundary of
changing that value is not itself meaningful. If gameplay logic depends on
queued transitions, enter/exit handling, or inState(...) gating, prefer
Game.StateMachine(...) instead.
const ActiveLocale = Descriptor.State<"en" | "it">()("ActiveLocale")
Defines a state descriptor that also knows how to validate raw values.
Defines a service descriptor.
Services are the dependency-injection side of the system model, similar to
Effect environment entries.
Use them for capabilities owned by the host instead of the ECS world:
clocks, random sources, render/audio bridges, storage, or network clients.
Systems request them explicitly with Game.System.service(...), and the
runtime provides them through Game.Runtime.services(...).
// Describe one host capability the runtime must provide.
const Logger = Descriptor.Service<{ log: (message: string) => void }>()("Logger")
Checks whether one descriptor carries raw-construction metadata.
Returns the raw constructor carried by one descriptor when present.
Plain descriptors return undefined.