Skip to content

Commit 0165049

Browse files
Fix building preview I/O arrows being affected by wires
Only check a single layer for potential connection or blockage when displaying building I/O arrows. Direct port of tobspr-games#1035. Co-authored-by: Emerald Block <69981203+EmeraldBlock@users.noreply.github.com>
1 parent 05ef93e commit 0165049

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/js/game/hud/parts/building_placer.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,15 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
575575
let isBlocked = false;
576576
let isConnected = false;
577577

578-
// Find all entities which are on that tile
579-
const sourceEntities = this.root.map.getLayersContentsMultipleXY(sourceTile.x, sourceTile.y);
578+
// Find entity which is on that tile
579+
const sourceEntity = this.root.map.getLayerContentXY(
580+
sourceTile.x,
581+
sourceTile.y,
582+
this.fakeEntity.layer
583+
);
580584

581-
// Check for every entity:
582-
for (let j = 0; j < sourceEntities.length; ++j) {
583-
const sourceEntity = sourceEntities[j];
585+
// Check for the entity:
586+
if (sourceEntity) {
584587
const sourceEjector = sourceEntity.components.ItemEjector;
585588
const sourceBeltComp = sourceEntity.components.Belt;
586589
const sourceStaticComp = sourceEntity.components.StaticMapEntity;
@@ -633,15 +636,15 @@ export class HUDBuildingPlacer extends HUDBuildingPlacerLogic {
633636
let isBlocked = false;
634637
let isConnected = false;
635638

636-
// Find all entities which are on that tile
637-
const destEntities = this.root.map.getLayersContentsMultipleXY(
639+
// Find entity which is on that tile
640+
const destEntity = this.root.map.getLayerContentXY(
638641
ejectorSlotWsTile.x,
639-
ejectorSlotWsTile.y
642+
ejectorSlotWsTile.y,
643+
this.fakeEntity.layer
640644
);
641645

642-
// Check for every entity:
643-
for (let i = 0; i < destEntities.length; ++i) {
644-
const destEntity = destEntities[i];
646+
// Check for the entity:
647+
if (destEntity) {
645648
const destAcceptor = destEntity.components.ItemAcceptor;
646649
const destStaticComp = destEntity.components.StaticMapEntity;
647650
const destMiner = destEntity.components.Miner;

0 commit comments

Comments
 (0)