Skip to content

System ​

Interface of @v12-engine/engine

ts
export interface System

Something 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 ​

ts
after?: string[];

Names of systems in the same phase this one runs after

before ​

ts
before?: string[];

Names of systems in the same phase this one runs ahead of, or after

each beta ​

ts
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 ​

ts
every?: number;

Runs once in so many ticks, for work that does not need doing every tick. Every tick when left out

name ​

ts
name: string;

Unique in a world. A game's system with the name of a core one takes its place

offset ​

ts
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 ​

ts
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 ​

ts
phase?: SystemPhase;

cleanup when left out: after everything else in the tick

restore ​

ts
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 ​

ts
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 ​

ts
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