BuildGrid beta
Class of @v12-engine/engine
export declare class BuildGridPlacement grid. One cell per world unit, tracking where structures stand and where the ground is flat enough to build.
Members
constructor
constructor(terrain: Terrain, options?: GridOptions);Constructs a new instance of the BuildGrid class
canPlace
canPlace(cellX: number, cellZ: number, w: number, d: number): boolean;Whether a footprint of w by d cells with its first cell at (cellX, cellZ) is free and on ground level enough to build on
cellFor
cellFor(x: number, z: number, w: number, d: number): {
x: number;
z: number;
};Min cell of a footprint centered as close as possible to the given point
depth
readonly depth: number;The grid's depth in cells, the map's depth
groundChanged
groundChanged(rect: {
x: number;
z: number;
width: number;
depth: number;
}): void;Works out again where can be built, in a rectangle of cells and the ring about it (a slope is of the vertices about a cell): after the ground was reshaped there (World.reshapeGround). What stands there stays where it is
inBounds
inBounds(x: number, z: number): boolean;Whether the cell (x, z) is on the grid
isBuildable
isBuildable(x: number, z: number): boolean;Whether a structure may be put on the cell by the ground alone: on the grid, flat enough, dry, not at the edge or blocked
isFree
isFree(x: number, z: number): boolean;Whether the cell is buildable and has no structure on it
occupantAt
occupantAt(x: number, z: number): number;The id of the structure standing on the cell, 0 when none does and -1 when the cell is off the grid
occupy
occupy(cellX: number, cellZ: number, w: number, d: number, id: number): void;Marks the footprint's cells as taken by the structure id; cells off the grid are skipped
release
release(cellX: number, cellZ: number, w: number, d: number, id: number): void;Frees the footprint's cells that the structure id holds; cells held by another id are left
width
readonly width: number;The grid's width in cells, the map's width