From ff10961b33fd4670856f7a48146da960aec1e956 Mon Sep 17 00:00:00 2001 From: artemisSystem <39034386+artemisSystem@users.noreply.github.com> Date: Sat, 31 Oct 2020 14:24:58 +0100 Subject: [PATCH] make levers, readers and displays selectable/pipettable/deletable from the wires layer --- src/js/game/hud/parts/layer_preview.js | 6 ++++++ src/js/game/map_chunk.js | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/js/game/hud/parts/layer_preview.js b/src/js/game/hud/parts/layer_preview.js index 36e0ea58..84bf21d8 100644 --- a/src/js/game/hud/parts/layer_preview.js +++ b/src/js/game/hud/parts/layer_preview.js @@ -76,6 +76,12 @@ export class HUDLayerPreview extends BaseHUDPart { const tileY = dy + startTileY; const content = this.root.map.getLayerContentXY(tileX, tileY, "wires"); + const contentRegular = this.root.map.getLayerContentXY(tileX, tileY, "regular"); + if (contentRegular && content) { + // We don't want to count something on the wires layer here if it is on the normal layer, + // because then it will get rendered twice + continue; + } if (content) { MapChunkView.drawSingleWiresOverviewTile({ context: this.context, diff --git a/src/js/game/map_chunk.js b/src/js/game/map_chunk.js index 54af1125..47c2b996 100644 --- a/src/js/game/map_chunk.js +++ b/src/js/game/map_chunk.js @@ -372,10 +372,24 @@ export class MapChunk { assert(localY >= 0, "Local Y is < 0"); assert(localX < globalConfig.mapChunkSize, "Local X is >= chunk size"); assert(localY < globalConfig.mapChunkSize, "Local Y is >= chunk size"); + const regularContents = this.contents[localX][localY] || null; if (layer === "regular") { - return this.contents[localX][localY] || null; + return regularContents; } else { - return this.wireContents[localX][localY] || null; + const wireContents = this.wireContents[localX][localY] || null; + // If there is a reader, lever, or display on the tile, we count it + // as a wires component and act as if it is on the wires layer. + const regularContentsIsWireComponent = + regularContents ? + regularContents.components.BeltReader || + regularContents.components.Lever || + regularContents.components.Display + : false; + if (!wireContents && regularContentsIsWireComponent) { + return regularContents; + } else { + return wireContents; + } } } /**