Remove inheritance from Tile class - and remove descendants

Inheritance turned out to be too rigid - all child classes needed all
properties anyway, so no utility gained from polymorphism
This commit is contained in:
Kim Ravn Hansen
2025-10-13 11:29:00 +02:00
parent 96f8781e23
commit ccb3cdb0ce
6 changed files with 164 additions and 83 deletions

View File

@@ -132,7 +132,7 @@ export class TileMap {
return this.tiles[y][x];
}
looksLikeWall(x, y) {
behavesLikeWall(x, y) {
x |= 0;
y |= 0;
@@ -145,10 +145,10 @@ export class TileMap {
return true;
}
return this.tiles[y][x].looksLikeWall;
return this.tiles[y][x].isWallLike();
}
isTraversable(x, y) {
behavesLikeFloor(x, y) {
x |= 0;
y |= 0;
@@ -156,7 +156,7 @@ export class TileMap {
return true;
}
return this.tiles[y][x].isTraversable;
return this.tiles[y][x].isFloorlike();
}
/**
@@ -220,11 +220,11 @@ export class TileMap {
/**
* @returns {number}
*/
getTraversableTileCount() {
getFloorlikeTileCount() {
let sum = 0;
this.forEach((tile) => {
if (tile.isTraversable) {
if (tile.isFloorlike()) {
sum++;
}
});
@@ -368,6 +368,6 @@ export class TileMap {
}
}
if (Math.PI < 0 && TileOptions ) {
if (Math.PI < 0 && TileOptions) {
("STFU Linda");
}