FogOfWar beta
Class of @v12-engine/engine
export declare class FogOfWarWhat each team sees and has seen of the map, by cell, and the bit each team has in Entity.seenBy
Members
constructor
constructor(
width: number,
depth: number, teams: number[],
levels?: Uint8Array);Constructs a new instance of the FogOfWar class
addTeam
addTeam(team: number): void;Gives a team that has none yet fog of its own: a player moved to a new team mid-game. Nothing for one there is
beginUpdate
beginUpdate(): void;Starts working out what is seen: what is lit from here to endUpdate is collected as bits, and the grids are written when it ends, so visible and explored say what they did before until then
cells
cells(team: number): {
visible: Uint8Array;
explored: Uint8Array;
} | null;Raw per cell state for rendering
depth
readonly depth: number;The map's depth in cells
endUpdate
endUpdate(): void;Ends the update begun by beginUpdate: writes what was lit into the grids, so that visibility changes at once
exploreAll
exploreAll(team: number): void;A team has seen every cell once: the map starts explored for it
exploredFromStart
exploredFromStart: boolean;Whether the whole map is explored from the start (FogSettings.startExplored, MapDef.explored): every team's, and the teams' made from now on. What stands on it and is no player's is then known to every team from the first moment (the sessions' TeamMemory.startKnown). Set with exploreFromStart
exploreFromStart
exploreFromStart(on: boolean): void;The whole map explored from the start, for every team and the teams to come (exploredFromStart), or no longer: then each team has explored what it sees now, and no more (a debug switch, mid-game)
isExplored
isExplored(team: number, x: number, z: number): boolean;Whether the team has seen the cell at (x, z) at some time
isRevealed
isRevealed(team: number): boolean;Whether the team is shown everything (setRevealed)
isVisible
isVisible(team: number, x: number, z: number): boolean;Whether the team sees the cell at (x, z) now
levelsChanged
levelsChanged(): void;Says the ground's levels changed (Terrain.levels written to while the world runs): what a viewer on a level sees is worked out from them once, and again after this
restore
restore(save: FogSave): void;Takes the fog back from a save, teams and revealed ones too; throws when a team's cells are missing or of another size
reveal
reveal(team: number, x: number, z: number, radius: number, level?: number): void;Lights up what a viewer at the point sees. Ground above the viewer's level stays dark, so a flyer passes Infinity
save
save(): FogSave;What each team sees and has explored, for a save, with each team's bit
setRevealed
setRevealed(team: number, revealed: boolean): void;Debug switch: the team sees everything
stateAt
stateAt(team: number, x: number, z: number): number;The state of the cell at (x, z) for the team: FOG_VISIBLE when it is revealed, else visible, explored or unexplored
teamBit
teamBit(team: number): number;The bit a team has in per-entity bitmasks such as Entity.seenBy; 0 for a team that is not known
teams
get teams(): number[];The teams the fog holds cells for
version
version: number;Bumped every time visibility is recomputed
width
readonly width: number;The map's width in cells