From ada63459aa5a547b225b6c6cee24e0ce5424a5e3 Mon Sep 17 00:00:00 2001 From: isaisstillalive Date: Tue, 30 Jun 2020 22:26:30 +0900 Subject: [PATCH] fix cycle building bug --- src/js/game/hud/parts/base_toolbar.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/js/game/hud/parts/base_toolbar.js b/src/js/game/hud/parts/base_toolbar.js index 72abaad3..551763ec 100644 --- a/src/js/game/hud/parts/base_toolbar.js +++ b/src/js/game/hud/parts/base_toolbar.js @@ -103,15 +103,25 @@ export class HUDBaseToolbar extends BaseHUDPart { * Cycles through all buildings */ cycleBuildings() { + const visible = this.visibilityCondition(); + if (!visible) { + return; + } + + let process = false; let newIndex = this.lastSelectedIndex; for (let i = 0; i < this.supportedBuildings.length; ++i, ++newIndex) { newIndex %= this.supportedBuildings.length; const metaBuilding = gMetaBuildingRegistry.findByClass(this.supportedBuildings[newIndex]); const handle = this.buildingHandles[metaBuilding.id]; if (!handle.selected && handle.unlocked) { + process = true; break; } } + if (!process) { + return; + } const metaBuildingClass = this.supportedBuildings[newIndex]; const metaBuilding = gMetaBuildingRegistry.findByClass(metaBuildingClass); this.selectBuildingForPlacement(metaBuilding);