From c7e0703c45cb8cd195172b8109c3978391a49344 Mon Sep 17 00:00:00 2001 From: hexagonhexagon Date: Sun, 14 Jun 2020 22:02:01 -0400 Subject: [PATCH 1/2] Fix bug where belts in blueprints don't orient correctly. --- src/js/game/hud/parts/blueprint.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/js/game/hud/parts/blueprint.js b/src/js/game/hud/parts/blueprint.js index 6dcd4c43..fbd00484 100644 --- a/src/js/game/hud/parts/blueprint.js +++ b/src/js/game/hud/parts/blueprint.js @@ -176,6 +176,7 @@ export class Blueprint { tryPlace(root, tile) { return root.logic.performBulkOperation(() => { let anyPlaced = false; + const beltsToRegisterLater = []; for (let i = 0; i < this.entities.length; ++i) { let placeable = true; const entity = this.entities[i]; @@ -215,10 +216,22 @@ export class Blueprint { clone.components.StaticMapEntity.origin.addInplace(tile); root.map.placeStaticEntity(clone); - root.entityMgr.registerEntity(clone); + + // Registering a belt immediately triggers a recalculation of surrounding belt + // directions, which is no good when not all belts have been placed. To resolve + // this, only register belts after all entities have been placed. + if (!clone.components.Belt) { + root.entityMgr.registerEntity(clone); + } else { + beltsToRegisterLater.push(clone); + } anyPlaced = true; } } + + for (let i = 0; i < beltsToRegisterLater.length; i++) { + root.entityMgr.registerEntity(beltsToRegisterLater[i]); + } return anyPlaced; }); } From 54653cf28e784014e68cb361fa28e65b49da752b Mon Sep 17 00:00:00 2001 From: hexagonhexagon Date: Sun, 21 Jun 2020 18:11:55 -0400 Subject: [PATCH 2/2] Make edge case where building is replaceable but unremovable an assertAlways. --- src/js/game/hud/parts/blueprint.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/game/hud/parts/blueprint.js b/src/js/game/hud/parts/blueprint.js index fbd00484..c53163d9 100644 --- a/src/js/game/hud/parts/blueprint.js +++ b/src/js/game/hud/parts/blueprint.js @@ -203,10 +203,10 @@ export class Blueprint { "Can not delete entity for blueprint" ); if (!root.logic.tryDeleteBuilding(contents)) { - logger.error( + assertAlways( + false, "Building has replaceable component but is also unremovable in blueprint" ); - return false; } } }