OrderBehavior
Interface of @v12-engine/engine
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
accepts(world: World, entity: Entity, init: Init): boolean;Whether the entity is able to carry out this order at all
building
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
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
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
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
formation?: boolean;Units ordered to a point together are spread out in a formation instead of all walking to the same spot
start
start?(world: World, entity: Entity, order: Order<State, Init>): void;Called once when the order reaches the front of the queue
type
type: string;The order type this behaviour handles, the key of registry.order and of Order.type
update
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
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