Runtime

Condition

Run conditions computed by code: check(...).

Machine.inState and friends gate systems on state machines. A check gates them on anything the world holds, with ordinary code instead of a growing set of combinators:

const playing = Game.Condition.check("playing", {
  resources: { stop: Game.System.readResource(HitStop) },
  machines: { flow: Game.System.machine(Flow) }
}, ({ resources, machines }) => machines.flow.get() === "Playing" && resources.stop.get().remaining <= 0)

Game.Schedule.when([playing], Move, Attack)

A check declares its reads like a system, and they become requirements of whatever it gates, so a runtime without them is a compile error. Its access is stricter than an inspector's: only resources, machines, and read-only queries without change filters. Every read that consumes or advances a per-reader cursor (events, transition events, added/changed filters, removed/despawned records, relation failures) is rejected, and so are services. A check gating many systems is evaluated once per system, and with these reads it gives the same answer each time until something it reads is written.

Checks are evaluated just before each gated system runs, against committed values: unlike machine conditions, whose values change only at applyStateTransitions markers, a write by an earlier system in the same run is visible. A predicate that throws is a defect: the exception propagates like one thrown by a system.

Functions

check

Source

Builds a check for a known schema. Game.Condition.check(...) supplies the schema and root from the bound game.