Skip to content

SquadGroup beta ​

Class of @v12-engine/engine/ai

ts
export declare class SquadGroup implements Iterable<Squad>

Some squads together (ai.squads.all(), idle()): read as a list, told as one (ai.squads.all().defend(home): each squad is given the task)

Members ​

[Symbol.iterator] ​

ts
[Symbol.iterator](): Iterator<Squad>;

Iterates the squads, so that the set reads as a list

constructor ​

ts
constructor(
    ai: Brain, 
    squads: readonly Squad[]);

Constructs a new instance of the SquadGroup class

ai ​

ts
readonly ai: Brain;

The brain they are of

attack ​

ts
attack(target: Vec2 | EntityState | number, options?: {
        avoid?: 'army' | false;
        then?: TaskOrder;
    }): this;

Tells each squad to attack a point, an entity or an entity id, as Squad.attack does, and returns the set

defend ​

ts
defend(at: Vec2 | undefined, radius?: number): this;

Tells each squad to defend a place within a radius as Squad.defend does; does nothing without a place; returns the set

disband ​

ts
disband(why?: string): void;

Each disbanded

hold ​

ts
hold(at?: Vec2): this;

Tells each squad to hold at a place, or where it is, as Squad.hold does, and returns the set

length ​

ts
get length(): number;

How many squads

move ​

ts
move(at: Vec2): this;

Tells each squad to move to a point as Squad.move does, and returns the set

retreat ​

ts
retreat(to?: Vec2): this;

Tells each squad to retreat to a point, or home when left out, as Squad.retreat does, and returns the set

squads ​

ts
readonly squads: readonly Squad[];

The squads

strength ​

ts
strength(): number;

How strong they are together

task ​

ts
task<D extends object, M extends object>(def: TaskDef<D, M>, data: D & TaskCommon): this;

Each given the same task

task ​

ts
task(kind: string, data?: TaskData): this;

Gives each squad the same task, by its kind and data, and returns the set

units ​

ts
units(): UnitSet;

Their units together, as a set