Skip to content

TurnCycler

Defined in: src/modules/turn-based/turn-cycler.ts:29

Round-robin active-turn cycler for turn-based games. Parameterized by the controlled tag (which entities take turns) and the activeTurn tag (which one currently holds the turn). Optional cameraTarget is moved in lockstep with activeTurn when provided.

This is an opt-in turn-based module, not a core ECS primitive — real-time games don’t use it. Exported via the @pierre/ecs/modules/turn-based subpath so consumers only pay for it when they import it.

new TurnCycler(world, tags): TurnCycler

Defined in: src/modules/turn-based/turn-cycler.ts:34

EcsWorld

TurnCyclerTags

TurnCycler

get activeEntityId(): EntityId | undefined

Defined in: src/modules/turn-based/turn-cycler.ts:43

EntityId currently holding the active-turn tag, or undefined if none.

EntityId | undefined


get allControlledEntitiesActed(): boolean

Defined in: src/modules/turn-based/turn-cycler.ts:85

True if the active-turn tag is back on the first controlled entity (i.e. every controlled entity has had its turn this round). Returns true trivially when there are 0 or 1 controlled entities.

boolean

advance(): boolean

Defined in: src/modules/turn-based/turn-cycler.ts:55

Advance the active-turn tag to the next controlled entity in insertion order. Also moves cameraTarget in lockstep when configured. Returns true when the round wrapped (i.e. AI turn should run next), false otherwise. A no-op returning true when there are 0 or 1 controlled entities.

boolean