diff --git a/src/js/game/blueprint.js b/src/js/game/blueprint.js index 67875896..85b8d171 100644 --- a/src/js/game/blueprint.js +++ b/src/js/game/blueprint.js @@ -92,7 +92,7 @@ export class Blueprint { let placeable = true; placementCheck: for (let x = rect.x; x < rect.right(); ++x) { for (let y = rect.y; y < rect.bottom(); ++y) { - if (parameters.root.map.isTileUsedXY(x, y)) { + if (parameters.root.map.isTileUsedXY(x, y, entity.layer)) { placeable = false; break placementCheck; } @@ -156,7 +156,7 @@ export class Blueprint { rect.moveBy(tile.x, tile.y); placementCheck: for (let x = rect.x; x < rect.right(); ++x) { for (let y = rect.y; y < rect.bottom(); ++y) { - if (root.map.isTileUsedXY(x, y)) { + if (root.map.isTileUsedXY(x, y, entity.layer)) { placeable = false; break placementCheck; } diff --git a/src/js/game/map.js b/src/js/game/map.js index ec8d1ce3..bf3dd009 100644 --- a/src/js/game/map.js +++ b/src/js/game/map.js @@ -119,17 +119,6 @@ export class BaseMap extends BasicSerializableObject { return this.getOrCreateChunkAtTile(x, y).getLowerLayerFromWorldCoords(x, y); } - /** - * Returns the tile content of a given tile - * @param {number} x - * @param {number} y - * @returns {Entity} Entity or null - */ - getTileContentXY(x, y) { - const chunk = this.getChunkAtTileOrNull(x, y); - return chunk && chunk.getTileContentFromWorldCoords(x, y); - } - /** * Returns the tile content of a given tile * @param {number} x @@ -156,25 +145,27 @@ export class BaseMap extends BasicSerializableObject { /** * Checks if the tile is used * @param {Vector} tile + * @param {enumLayer} layer * @returns {boolean} */ - isTileUsed(tile) { + isTileUsed(tile, layer) { if (G_IS_DEV) { this.internalCheckTile(tile); } const chunk = this.getChunkAtTileOrNull(tile.x, tile.y); - return chunk && chunk.getTileContentFromWorldCoords(tile.x, tile.y) != null; + return chunk && chunk.getLayerContentFromWorldCoords(tile.x, tile.y, layer) != null; } /** * Checks if the tile is used * @param {number} x * @param {number} y + * @param {enumLayer} layer * @returns {boolean} */ - isTileUsedXY(x, y) { + isTileUsedXY(x, y, layer) { const chunk = this.getChunkAtTileOrNull(x, y); - return chunk && chunk.getTileContentFromWorldCoords(x, y) != null; + return chunk && chunk.getLayerContentFromWorldCoords(x, y, layer) != null; } /**