ConcealmentOptions beta
Interface of @v12-engine/engine
export interface ConcealmentOptionsHiding places painted on a map, as a layer of cells (CellLayerDef): tall grass, a forest's edge. Who stands in one is seen by another team only from inside the same patch of it (the cells of the layer that touch, sides or corners), or from close by (reach). An attacker in one is seen by whom it hits for a moment, as anyone is (expose), and what detects the invisible (entity.detected) sees it too. A game turns it on, on as many layers as it likes:
export const rules = ...myGame, packs: [concealmentPack( layer: 'bush' )]
Everything that asks what a team sees (world.isVisibleTo) goes by it: what units pick to attack, the commands a player may give, the fog's memory, and each player's snapshots, so the computer player and the players over a wire see what the rules let them. Nothing is saved: it is worked out from the layer and where everyone stands
Members
conceals
conceals?: (world: World, cell: number) => boolean;Which cells of the layer hide, by their index: every cell that is not 0 when left out. The patches are of the cells that do (those that touch), so grass that is cut or burnt neither hides nor joins two patches. What the foliage pack hides by: a style that conceals, in a state that still does (foliagePack). Asked as the patches are worked out, not for every unit
eachUnit
eachUnit?: {
unit(world: World, entity: Entity, cell: number): void;
done(world: World): boolean;
};Told of each unit on the map as the count goes through the units at the start of a tick (alive, not inside anything), with the cell it stands in (unit), and once the count is done (done, whether it changed cells of the layer or of one it follows: the count is made again of the patches as they are now). What the foliage pack tramples by, in the same pass over the units as the count (FoliageStyleDef.trample). Never told from a visible asked before the tick's count
follows
follows?: readonly string[];Other layers whose cells decide what hides (conceals), by id: the patches are worked out again when one of them changes, as when the layer itself does. The foliage pack's state layer (foliageStateLayer)
hides
hides?: (world: World, entity: Entity) => boolean;What it hides: units on the ground, of anyone, when left out (not structures, not what flies). A game's own, to hide heroes only or let some types never hide
id
id?: string;The id of its hook and its system, to replace or leave out: concealment:<layer> when left out
layer
layer: string;The layer of cells that hides (Terrain.cells): any cell of it with a value other than 0
reach
reach?: number;How near, in cells, someone of another team has to be to see into it from outside: 2 when left out
rustle
rustle?: boolean | ((world: World, entity: Entity, team: number) => boolean);Whether one hidden in it gives itself away by moving, as the brush of a hero arena game shakes: the teams that do not see it are told where it moves in it and steps into it (a rustle event, where they see the ground; not who), and their screens shake the bushes there. true for every team, a function to say for each (team), no when left out: a hidden unit shakes nothing on the screens of those who do not see it
rustleEvery
rustleEvery?: number;How often one moving in it is told again, in seconds: 0.3 when left out. Stepping in is told at once
seenBy
seenBy?: (world: World, entity: Entity, team: number) => boolean;Whether a team sees a hidden entity anyway, after what the patch and reach make of it: a ward, a scout's ability. Asked only of what would otherwise be hidden