Skip to content

FormationContext beta ​

Interface of @v12-engine/engine

ts
export interface FormationContext

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

ts
readonly centre: Vec2;

The middle of where the units are

forward ​

ts
readonly forward: Vec2;

The way from where they are to the target, a unit long (forward, where they face at the end)

ts
readonly nav: Navigation;

The navigation they go on, to find where they can stand

place ​

ts
place(x: number, z: number): Vec2;

A point in the world, x to the right of the target and z forward of it

ts
readonly right: Vec2;

To the right of forward, a unit long

snap ​

ts
snap(point: Vec2): Vec2;

The nearest point a unit can stand on, or the target where there is none within 4

spacing ​

ts
readonly spacing: number;

Room a unit takes: twice the biggest radius among them, and a gap of FORMATION_GAP

target ​

ts
readonly target: Vec2;

Where the units are sent

turned ​

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

ts
readonly units: readonly Entity[];

The units laid out: those that walk, or those that fly, apart

world ​

ts
readonly world: World;

The world the formation is laid out in