From c3aed48daef27904088cef84b95a726403877bfb Mon Sep 17 00:00:00 2001 From: isaisstillalive Date: Mon, 22 Jun 2020 23:33:00 +0900 Subject: [PATCH] Fix Belt planner Overlay --- src/js/game/hud/parts/building_placer_logic.js | 15 +++++++++++++++ src/js/game/hud/parts/keybinding_overlay.js | 11 ++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/js/game/hud/parts/building_placer_logic.js b/src/js/game/hud/parts/building_placer_logic.js index a71bb802..ed10e3bc 100644 --- a/src/js/game/hud/parts/building_placer_logic.js +++ b/src/js/game/hud/parts/building_placer_logic.js @@ -175,6 +175,21 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { } } + /** + * Returns if the direction lock is available + * @returns {boolean} + */ + get isDirectionLockAvailable() { + const metaBuilding = this.currentMetaBuilding.get(); + if (!(metaBuilding && metaBuilding.getHasDirectionLockAvailable())) { + return false; + } + if (this.currentlyDirectionLock !== null) { + return false; + } + return !this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.lockBeltDirection).pressed; + } + /** * Returns if the direction lock is currently active * @returns {boolean} diff --git a/src/js/game/hud/parts/keybinding_overlay.js b/src/js/game/hud/parts/keybinding_overlay.js index 2603e011..0da2f1a1 100644 --- a/src/js/game/hud/parts/keybinding_overlay.js +++ b/src/js/game/hud/parts/keybinding_overlay.js @@ -78,6 +78,15 @@ export class HUDKeybindingOverlay extends BaseHUDPart { return placer && !!placer.currentBlueprint.get(); } + /** + * HELPER / Returns if the belt planner is available + * @returns {boolean} + */ + get beltPlannerAvailable() { + const placer = this.root.hud.parts.buildingPlacer; + return !this.mapOverviewActive && placer && placer.isDirectionLockAvailable; + } + /** * HELPER / Returns if the belt planner is currently active * @returns {boolean} @@ -225,7 +234,7 @@ export class HUDKeybindingOverlay extends BaseHUDPart { // Belt planner label: T.ingame.keybindingsOverlay.lockBeltDirection, keys: [k.placementModifiers.lockBeltDirection], - condition: () => this.buildingPlacementSupportsBeltPlanner && !this.beltPlannerActive, + condition: () => this.buildingPlacementSupportsBeltPlanner && this.beltPlannerAvailable, }, {