Further refactoring
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user