System
Interface of @v12-engine/engine
export interface SystemSomething that runs every tick, or every few: moves units, lands attacks, works out what each team sees. When it runs is worked out once, from its phase, then from what it says it comes before and after.
Members
after
after?: string[];Names of systems in the same phase this one runs after
before
before?: string[];Names of systems in the same phase this one runs ahead of, or after
each beta
each?(world: World, entity: Entity, dt: number): void;Run for each entity of over, in order, after update. The dead are not left out: a system that wants only the living says so
every
every?: number;Runs once in so many ticks, for work that does not need doing every tick. Every tick when left out
name
name: string;Unique in a world. A game's system with the name of a core one takes its place
offset
offset?: number;With every, the tick in each round it runs at: systems with the same every and other offsets spread the work
over beta
over?: SystemOver;What each is run for (OB5): every unit ('units', when left out, in World.units' order), what has a component, in the order of its id (EntityIndex.ordered: a system about a few, like the buildings that train, does not look at every unit and tree), or the units a test says yes to. The two orders differ for scenery woken into a unit (Spawning.wake), which World.units has last: moving a system from one to the other can change which of two equals goes first, unless it breaks ties by id
phase
phase?: SystemPhase;cleanup when left out: after everything else in the tick
restore
restore?(world: World, data: unknown): void;Takes back what save gave, in a world loaded from a save: when it is made, or added again (addSystem)
save
save?(world: World): unknown;What it keeps in itself, for a save: plain data. For state that is easier kept in a system than in a component (World.state): a computer player's plans, a director's mood
update
update?(world: World, dt: number): void;dt is the time since it last ran: the length of a tick, times every. Before each, for a system that has both. One of the two is needed