Change black empty tile to grass and make it destructable
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { World, EntityId, Action, SimEvent, Actor, CombatantActor, CollectibleActor, ActorType } from "../../core/types";
|
||||
|
||||
import { isBlocked, inBounds, isWall } from "../world/world-logic";
|
||||
import { isBlocked, inBounds, isWall, tryDestructTile } from "../world/world-logic";
|
||||
import { isDestructibleByWalk } from "../../core/terrain";
|
||||
import { findPathAStar } from "../world/pathfinding";
|
||||
import { GAME_CONFIG } from "../../core/config/GameConfig";
|
||||
import { type EntityManager } from "../EntityManager";
|
||||
@@ -105,6 +106,16 @@ function handleMove(w: World, actor: Actor, action: { dx: number; dy: number },
|
||||
const to = { ...actor.pos };
|
||||
const events: SimEvent[] = [{ type: "moved", actorId: actor.id, from, to }];
|
||||
|
||||
// Check for "destructible by walk" tiles (e.g. grass)
|
||||
// We check the tile at the *new* position
|
||||
const tileIdx = ny * w.width + nx;
|
||||
const tile = w.tiles[tileIdx];
|
||||
if (isDestructibleByWalk(tile)) {
|
||||
tryDestructTile(w, nx, ny);
|
||||
// Optional: Add an event if we want visual feedback immediately,
|
||||
// but the renderer usually handles map updates automatically or next frame
|
||||
}
|
||||
|
||||
if (actor.category === "combatant" && actor.isPlayer) {
|
||||
handleExpCollection(w, actor, events, em);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user