FormationContext beta
Interface of @v12-engine/engine
export interface FormationContextWhat a formation lays units out with: the group, where it is sent, the way there, and the room each unit takes. Points are in the world; right and forward are the formation's own axes, each a unit long, for a shape that is drawn facing the way of travel: a place right * x + forward * z from the target
Members
centre
readonly centre: Vec2;The middle of where the units are
forward
readonly forward: Vec2;The way from where they are to the target, a unit long (forward, where they face at the end)
nav
readonly nav: Navigation;The navigation they go on, to find where they can stand
place
place(x: number, z: number): Vec2;A point in the world, x to the right of the target and z forward of it
right
readonly right: Vec2;To the right of forward, a unit long
snap
snap(point: Vec2): Vec2;The nearest point a unit can stand on, or the target where there is none within 4
spacing
readonly spacing: number;Room a unit takes: twice the biggest radius among them, and a gap of FORMATION_GAP
target
readonly target: Vec2;Where the units are sent
turned
readonly turned: boolean;Whether the player turned the formation by hand (a right-click dragged: OrderInit.facing): forward is then the way they dragged, not the way of travel, and a formation that keeps a group's own shape lays it out anew
units
readonly units: readonly Entity[];The units laid out: those that walk, or those that fly, apart
world
readonly world: World;The world the formation is laid out in