Change black empty tile to grass and make it destructable

This commit is contained in:
Peter Stockings
2026-01-05 20:59:33 +11:00
parent a7091c70c6
commit ecf58dded1
8 changed files with 150 additions and 43 deletions

View File

@@ -1,8 +1,8 @@
import type { World, EntityId } from "../../core/types";
import { GAME_CONFIG } from "../../core/config/GameConfig";
import { isBlocking, isDestructible, getDestructionResult } from "../../core/terrain";
import { type EntityManager } from "../EntityManager";
export function inBounds(w: World, x: number, y: number): boolean {
return x >= 0 && y >= 0 && x < w.width && y < w.height;
}
@@ -12,13 +12,34 @@ export function idx(w: World, x: number, y: number): number {
}
export function isWall(w: World, x: number, y: number): boolean {
// Alias for isBlocking for backward compatibility
return isBlockingTile(w, x, y);
}
export function isBlockingTile(w: World, x: number, y: number): boolean {
const tile = w.tiles[idx(w, x, y)];
return tile === GAME_CONFIG.terrain.wall || tile === GAME_CONFIG.terrain.wallDeco;
return isBlocking(tile);
}
export function tryDestructTile(w: World, x: number, y: number): boolean {
if (!inBounds(w, x, y)) return false;
const i = idx(w, x, y);
const tile = w.tiles[i];
if (isDestructible(tile)) {
const nextTile = getDestructionResult(tile);
if (nextTile !== undefined) {
w.tiles[i] = nextTile;
return true;
}
}
return false;
}
export function isBlocked(w: World, x: number, y: number, em?: EntityManager): boolean {
if (!inBounds(w, x, y)) return true;
if (isWall(w, x, y)) return true;
if (isBlockingTile(w, x, y)) return true;
if (em) {
return em.isOccupied(x, y, "exp_orb");