Further refactoring

This commit is contained in:
Peter Stockings
2026-01-07 09:19:38 +11:00
parent f9b1abee6e
commit fcd31cce68
11 changed files with 910 additions and 220 deletions

View File

@@ -1,4 +1,5 @@
import { FOV } from "rot-js";
import type ROT from "rot-js";
import { type World, type EntityId } from "../core/types";
import { idx, inBounds } from "../engine/world/world-logic";
import { blocksSight } from "../core/terrain";
@@ -6,7 +7,7 @@ import { GAME_CONFIG } from "../core/config/GameConfig";
import Phaser from "phaser";
export class FovManager {
private fov!: any;
private fov!: InstanceType<typeof ROT.FOV.PreciseShadowcasting>;
private seen!: Uint8Array;
private visible!: Uint8Array;
private visibleStrength!: Float32Array;
@@ -51,12 +52,12 @@ export class FovManager {
}
isSeen(x: number, y: number): boolean {
if (!inBounds({ width: this.worldWidth, height: this.worldHeight } as any, x, y)) return false;
if (x < 0 || x >= this.worldWidth || y < 0 || y >= this.worldHeight) return false;
return this.seen[y * this.worldWidth + x] === 1;
}
isVisible(x: number, y: number): boolean {
if (!inBounds({ width: this.worldWidth, height: this.worldHeight } as any, x, y)) return false;
if (x < 0 || x >= this.worldWidth || y < 0 || y >= this.worldHeight) return false;
return this.visible[y * this.worldWidth + x] === 1;
}