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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new TurnCycler(
world,tags):TurnCycler
Defined in: src/modules/turn-based/turn-cycler.ts:34
Parameters
Section titled “Parameters”Returns
Section titled “Returns”TurnCycler
Accessors
Section titled “Accessors”activeEntityId
Section titled “activeEntityId”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”EntityId | undefined
allControlledEntitiesActed
Section titled “allControlledEntitiesActed”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”advance()
Section titled “advance()”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.
Returns
Section titled “Returns”boolean