Skip to content

OrderBehavior ​

Interface of @v12-engine/engine

ts
export interface OrderBehavior<State extends object = Record<string, any>, Init extends object = OrderParams>

Logic behind an order type. Orders are the only way units act, which is what makes queueing work for everything. Game modules can register their own.

State is what it keeps in the order (Order.state), every field optional: the order starts with none of them. OrderStates names each order type's, for registry.order(type) to hand back the behaviour typed

Members ​

accepts ​

ts
accepts(world: World, entity: Entity, init: Init): boolean;

Whether the entity is able to carry out this order at all

building ​

ts
building?(order: Order<State, Init>): boolean;

Whether the unit has begun what it builds (its site is down): what it builds is counted as itself. Never, when left out

channelling ​

ts
channelling?(order: Order<State, Init>): boolean;

Whether the unit keeps something up that being stunned breaks off (a channelled ability). Never, when left out

committed ​

ts
committed?(order: Order<State, Init>): boolean;

Whether the unit is in the middle of it and cannot be called away (a cast past turning back): what was to come after is dropped, it is finished first (interrupt). Never, when left out

end ​

ts
end?(world: World, entity: Entity, order: Order<State, Init>): void;

Called when the order finishes or is interrupted, to undo anything it left behind

formation ​

ts
formation?: boolean;

Units ordered to a point together are spread out in a formation instead of all walking to the same spot

start ​

ts
start?(world: World, entity: Entity, order: Order<State, Init>): void;

Called once when the order reaches the front of the queue

type ​

ts
type: string;

The order type this behaviour handles, the key of registry.order and of Order.type

update ​

ts
update(world: World, entity: Entity, order: Order<State, Init>, dt: number): OrderStatus;

Runs each tick while the order is at the front; returns whether it is still running, done or failed. dt is the tick's seconds

waiting ​

ts
waiting?(order: Order<State, Init>): boolean;

Whether the unit stands waiting by a fight for a spot in it (an attack or an attack-move held up: holdOff): an ally on its way may ask it aside (settings.movement.makesWay). Never, when left out