Skip to content

FogOfWar beta ​

Class of @v12-engine/engine

ts
export declare class FogOfWar

What each team sees and has seen of the map, by cell, and the bit each team has in Entity.seenBy

Members ​

constructor ​

ts
constructor(
    width: number, 
    depth: number, teams: number[], 
    levels?: Uint8Array);

Constructs a new instance of the FogOfWar class

addTeam ​

ts
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 ​

ts
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 ​

ts
cells(team: number): {
        visible: Uint8Array;
        explored: Uint8Array;
    } | null;

Raw per cell state for rendering

depth ​

ts
readonly depth: number;

The map's depth in cells

endUpdate ​

ts
endUpdate(): void;

Ends the update begun by beginUpdate: writes what was lit into the grids, so that visibility changes at once

exploreAll ​

ts
exploreAll(team: number): void;

A team has seen every cell once: the map starts explored for it

exploredFromStart ​

ts
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 ​

ts
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 ​

ts
isExplored(team: number, x: number, z: number): boolean;

Whether the team has seen the cell at (x, z) at some time

isRevealed ​

ts
isRevealed(team: number): boolean;

Whether the team is shown everything (setRevealed)

isVisible ​

ts
isVisible(team: number, x: number, z: number): boolean;

Whether the team sees the cell at (x, z) now

levelsChanged ​

ts
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 ​

ts
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 ​

ts
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 ​

ts
save(): FogSave;

What each team sees and has explored, for a save, with each team's bit

setRevealed ​

ts
setRevealed(team: number, revealed: boolean): void;

Debug switch: the team sees everything

stateAt ​

ts
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 ​

ts
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 ​

ts
get teams(): number[];

The teams the fog holds cells for

version ​

ts
version: number;

Bumped every time visibility is recomputed

width ​

ts
readonly width: number;

The map's width in cells