tick
Import from @pierre/ecs/tick-source and @pierre/ecs/tick-runner.
The tick story is a two-layer design: a core interface and runner that define the per-tick ceremony, and module implementations that decide when ticks fire.
Core Interfaces (src/tick-source.ts)
Section titled “Core Interfaces (src/tick-source.ts)”TickInfo + TickSource describe the source of ticks (discrete or
continuous). A TickSource emits TickInfo payloads; how often, and
whether wall time is involved, is entirely up to the implementation.
Import via @pierre/ecs/tick-source.
TickRunner (src/tick-runner.ts)
Section titled “TickRunner (src/tick-runner.ts)”TickRunner drives the universal per-tick ceremony:
- build
ctx - run scheduler
onBeforeFlushhook- flush events / lifecycle / structural commands
onTickCompletehook
A tick is atomic. Consumers queue world swaps between ticks via
onTickComplete, and emit tick-boundary events (e.g. TurnCompleted)
via onBeforeFlush so they drain in the same flush.
Import via @pierre/ecs/tick-runner.
Implementations
Section titled “Implementations”Concrete TickSource implementations live under
src/modules/tick/. See
src/modules/tick/README.md for the
current implementations (ManualTickSource, FixedIntervalTickSource)
and guidance on which to pick.
See also
Section titled “See also”- Scheduler -
TickRunnercallsscheduler.run(ctx)each tick. - Event Bus - typically flushed inside the tick callback.
src/modules/tick/README.md- concreteTickSourceimplementations.