Make grass block vision
This commit is contained in:
@@ -16,13 +16,14 @@ export interface TileBehavior {
|
||||
isBlocking: boolean;
|
||||
isDestructible: boolean;
|
||||
isDestructibleByWalk?: boolean;
|
||||
blocksVision?: boolean;
|
||||
destructsTo?: TileType;
|
||||
}
|
||||
|
||||
export const TILE_DEFINITIONS: Record<number, TileBehavior> = {
|
||||
[TileType.EMPTY]: { id: TileType.EMPTY, isBlocking: false, isDestructible: false },
|
||||
[TileType.WALL]: { id: TileType.WALL, isBlocking: true, isDestructible: false },
|
||||
[TileType.GRASS]: { id: TileType.GRASS, isBlocking: false, isDestructible: true, isDestructibleByWalk: true, destructsTo: TileType.GRASS_SAPLINGS },
|
||||
[TileType.GRASS]: { id: TileType.GRASS, isBlocking: false, isDestructible: true, isDestructibleByWalk: true, blocksVision: true, destructsTo: TileType.GRASS_SAPLINGS },
|
||||
[TileType.GRASS_SAPLINGS]: { id: TileType.GRASS_SAPLINGS, isBlocking: false, isDestructible: false },
|
||||
[TileType.EMPTY_DECO]: { id: TileType.EMPTY_DECO, isBlocking: false, isDestructible: false },
|
||||
[TileType.WALL_DECO]: { id: TileType.WALL_DECO, isBlocking: true, isDestructible: false },
|
||||
@@ -45,6 +46,11 @@ export function isDestructibleByWalk(tile: number): boolean {
|
||||
return def ? !!def.isDestructibleByWalk : false;
|
||||
}
|
||||
|
||||
export function blocksSight(tile: number): boolean {
|
||||
const def = TILE_DEFINITIONS[tile];
|
||||
return def ? (def.isBlocking || !!def.blocksVision) : false;
|
||||
}
|
||||
|
||||
export function getDestructionResult(tile: number): number | undefined {
|
||||
const def = TILE_DEFINITIONS[tile];
|
||||
return def ? def.destructsTo : undefined;
|
||||
|
||||
Reference in New Issue
Block a user