fogOfWarKit's CPU side: the fog grid, every team's sources, the explored
memory, line-of-sight blockers, the visibility queries and the per-tick
update. One shared state per engine (per peer); nothing here replicates.
The public surface is `fogOfWarKit.api`; this module is what it drives.
num(v: any, fallback: number) → number
| arg | type | description |
|---|
| v | any | |
| fallback | number | |
xz(v: any, fx: number, fz: number) → void
| arg | type | description |
|---|
| v | any | |
| fx | number | |
| fz | number | |
configure(o: any) → void
Apply a setup table. Grid-shaping keys (center, size, cellSize) rebuild
every buffer and forget explored ground; the others change in place.
team(id: number) → Team
| arg | type | description |
|---|
| id | number | |
markDirty(team: number?) → void
| arg | type | description |
|---|
| team | number? | |
setBatched(team: number, list: { any }) → void
| arg | type | description |
|---|
| team | number | |
| list | { any } | |
addKeyed(key: any, src: Source) → void
| arg | type | description |
|---|
| key | any | |
| src | Source | |
moveKeyed(key: any, x: number, z: number) → boolean
| arg | type | description |
|---|
| key | any | |
| x | number | |
| z | number | |
removeKeyed(key: any) → boolean
cellOf(x: number, z: number) → void
World XZ -> cell (0-based), or nil when outside the map.
| arg | type | description |
|---|
| x | number | |
| z | number | |
cellCenter(i: number, j: number) → void
Centre of cell (i, j) in world XZ.
| arg | type | description |
|---|
| i | number | |
| j | number | |
stampDisc(bytes: buffer, sx: number, sz: number, r: number, vis: boolean) → void
Fill visible (and explored) across the row spans of a disc, clipped to the map.
| arg | type | description |
|---|
| bytes | buffer | |
| sx | number | |
| sz | number | |
| r | number | |
| vis | boolean | |
rebuildBlockers( ) → void
setBlocker(key: any, b: Blocker?) → void
| arg | type | description |
|---|
| key | any | |
| b | Blocker? | |
isBlocked(x: number, z: number) → boolean
| arg | type | description |
|---|
| x | number | |
| z | number | |
stampLOS(bytes: buffer, sx: number, sz: number, r: number) → void
Line of sight: rays from the source to its rim, stepping half a cell, until a
blocker cell (which is itself seen: you see the face of a wall).
| arg | type | description |
|---|
| bytes | buffer | |
| sx | number | |
| sz | number | |
| r | number | |
clearVisible(bytes: buffer) → void
| arg | type | description |
|---|
| bytes | buffer | |
readEntityPos(e: any) → void
pollEntitySources( ) → void
Refresh entity-following keyed sources (FogSource and Fog.addSource with an entity).
computeTeam(t: Team) → void
Recompute one team's visible set (and grow its explored memory).
reveal(team: number, x: number, z: number, r: number) → void
Permanently mark a disc explored for a team.
| arg | type | description |
|---|
| team | number | |
| x | number | |
| z | number | |
| r | number | |
reset(team: number?) → void
| arg | type | description |
|---|
| team | number? | |
ensureFresh(t: Team) → void
state(team: number, x: number, z: number) → number
| arg | type | description |
|---|
| team | number | |
| x | number | |
| z | number | |
exploredFraction(team: number) → number
Share of the map a team has explored, 0..1.
| arg | type | description |
|---|
| team | number | |
track(e: any, team: number) → void
| arg | type | description |
|---|
| e | any | |
| team | number | |
wantHidden(rec: { entity: any, team: number, hidden: boolean }) → boolean
| arg | type | description |
|---|
| rec | { entity: any, team: number, hidden: boolean } | |
applyHidden(id: string) → void
| arg | type | description |
|---|
| id | string | |
update(force: boolean?) → boolean
Run one grid update now (force) or when the update interval elapsed.
| arg | type | description |
|---|
| force | boolean? | |
⌬ Types
Source = { team: number, x: number, z: number, r: number, entity: any?, enabled: boolean }Team = {Blocker = { x0: number, z0: number, x1: number, z1: number }