Skip to content

GeneratorContext beta ​

Interface of @v12-engine/engine

ts
export interface GeneratorContext

What a pass works with (GeneratorPass.run): the map as the passes before left it, the seed's numbers, noise that repeats across the map, the symmetry, and what to put down with

Members ​

addCamp ​

ts
addCamp(x: number, z: number, units: string[], more?: Partial<Omit<MapCamp, 'id' | 'x' | 'z' | 'units'>>): MapCamp;

Creeps that guard a spot, with an id of their own

addDoodad ​

ts
addDoodad(doodad: Omit<MapDoodad, 'id' | 'scale' | 'yaw'> & {
        scale?: number | [number, number, number];
        yaw?: number;
    }): MapDoodad;

Scenery put down, with an id of its own: the model by its path in models/, as big as it says, turned as it says

addObject ​

ts
addObject(type: string, owner: PlayerId, x: number, z: number, more?: Partial<Omit<MapObject, 'id' | 'type' | 'owner' | 'x' | 'z'>>): MapObject;

A unit or a building of a type put down, with an id of its own, for a player (MAP_NEUTRAL, MAP_CREEPS, or one of the map's)

addRegion ​

ts
addRegion(name: string, shape: AreaShape, more?: Partial<Omit<MapRegion, 'id' | 'name' | 'shape'>>): MapRegion;

A region the rules watch by name, with an id of its own

canonical ​

ts
canonical(cx: number, cz: number): boolean;

Whether a cell is the first of its mirrored set: what is done once a set is done at this one, and mirrored from it

free ​

ts
free(x: number, z: number, radius: number, kinds?: readonly string[]): boolean;

Whether nothing marked is within radius of a place (of kinds alone, when said)

levelAt ​

ts
levelAt(x: number, z: number): number;

The level of the ground at a point: its cell's cliff level

map ​

ts
map: GameMap;

The map as the passes before left it; a pass changes it in place

mark ​

ts
mark(kind: string, x: number, z: number, radius: number): void;

Puts a mark down for the passes after: nothing on the map, only in placed

noise ​

ts
noise(name: string, cells?: readonly number[]): (x: number, z: number) => number;

Noise that repeats across the map, by a name (the same name is the same noise), 0..1 at a point of the map in cells; cells are the sizes of its features, coarsest first ([32, 16, 8] for hills). Mirrored as the map is

once ​

ts
once<T>(x: number, z: number, draw: () => T): T;

What draw makes, made once for a place and the places the symmetry mirrors it to: the first call of a set draws (and spends the seed's numbers), the calls for its mirrors get the same. For a choice put down at every mirror (a camp's creeps), so the map stays fair

options ​

ts
options: GeneratorOptions;

The options the map is made with: seed, size, players, symmetry and parameters

param ​

ts
param<T extends number | string | boolean>(id: string, fallback: T): T;

A parameter as it is: what the options say, or its default (MapGenerator.params), or fallback where neither says

placed ​

ts
placed: GeneratorMark[];

What the passes before put down, by kind

registry ​

ts
registry: Registry;

The game's registry, which tells what unit types and doodads exist

rng ​

ts
rng: Rng;

The seed's numbers: every draw of a pass is one of these, so the same seed makes the same map

symmetric ​

ts
symmetric(x: number, z: number): Vec2[];

A place, and the places the symmetry mirrors or turns it to (the first is the place itself): what is put down at one is put down at the others, so the map is fair

walkable ​

ts
walkable(x: number, z: number): boolean;

Whether a point is on the map and on ground something walks: no deep water, not off the map