Make grass block vision
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { World, EntityId, Action, SimEvent, Actor, CombatantActor, CollectibleActor, ActorType } from "../../core/types";
|
||||
|
||||
import { isBlocked, inBounds, isWall, tryDestructTile } from "../world/world-logic";
|
||||
import { isDestructibleByWalk } from "../../core/terrain";
|
||||
import { isBlocked, inBounds, tryDestructTile } from "../world/world-logic";
|
||||
import { isDestructibleByWalk, blocksSight } from "../../core/terrain";
|
||||
import { findPathAStar } from "../world/pathfinding";
|
||||
import { GAME_CONFIG } from "../../core/config/GameConfig";
|
||||
import { type EntityManager } from "../EntityManager";
|
||||
@@ -240,9 +240,11 @@ function canEnemySeePlayer(w: World, enemy: CombatantActor, player: CombatantAct
|
||||
const viewRadius = 8; // Enemy vision range
|
||||
let canSee = false;
|
||||
|
||||
|
||||
const fov = new FOV.PreciseShadowcasting((x: number, y: number) => {
|
||||
if (!inBounds(w, x, y)) return false;
|
||||
return !isWall(w, x, y);
|
||||
const idx = y * w.width + x;
|
||||
return !blocksSight(w.tiles[idx]);
|
||||
});
|
||||
|
||||
fov.compute(enemy.pos.x, enemy.pos.y, viewRadius, (x: number, y: number) => {
|
||||
|
||||
Reference in New Issue
Block a user