diff --git a/src/js/game/hud/parts/miner_highlight.js b/src/js/game/hud/parts/miner_highlight.js index b398bbfd..a0c6919d 100644 --- a/src/js/game/hud/parts/miner_highlight.js +++ b/src/js/game/hud/parts/miner_highlight.js @@ -45,6 +45,12 @@ export class HUDMinerHighlight extends BaseHUDPart { return; } + const lowerContents = this.root.map.getLowerLayerContentXY(hoveredTile.x, hoveredTile.y); + if (!lowerContents) { + // Not connected + return; + } + parameters.context.fillStyle = THEME.map.connectedMiners.overlay; const connectedEntities = this.findConnectedMiners(contents); diff --git a/src/js/game/systems/miner.js b/src/js/game/systems/miner.js index feda1594..4ebc6f7b 100644 --- a/src/js/game/systems/miner.js +++ b/src/js/game/systems/miner.js @@ -5,6 +5,7 @@ import { BaseItem } from "../base_item"; import { MinerComponent } from "../components/miner"; import { Entity } from "../entity"; import { GameSystemWithFilter } from "../game_system_with_filter"; +import { statisticsUnitsSeconds } from "../hud/parts/statistics_handle"; import { MapChunkView } from "../map_chunk_view"; export class MinerSystem extends GameSystemWithFilter { @@ -93,6 +94,11 @@ export class MinerSystem extends GameSystemWithFilter { findChainedMiner(entity) { const ejectComp = entity.components.ItemEjector; const staticComp = entity.components.StaticMapEntity; + const contentsBelow = this.root.map.getLowerLayerContentXY(staticComp.origin.x, staticComp.origin.y); + if (!contentsBelow) { + // This miner has no contents + return null; + } const ejectingSlot = ejectComp.slots[0]; const ejectingPos = staticComp.localTileToWorld(ejectingSlot.pos); @@ -105,7 +111,10 @@ export class MinerSystem extends GameSystemWithFilter { if (targetContents) { const targetMinerComp = targetContents.components.Miner; if (targetMinerComp && targetMinerComp.chainable) { - return targetContents; + const targetLowerLayer = this.root.map.getLowerLayerContentXY(targetTile.x, targetTile.y); + if (targetLowerLayer) { + return targetContents; + } } }