diff --git a/src/js/game/hud/parts/base_toolbar.js b/src/js/game/hud/parts/base_toolbar.js index 72abaad3..f5ec24c6 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 newBuildingFound = 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) { + newBuildingFound = true; break; } } + if (!newBuildingFound) { + return; + } const metaBuildingClass = this.supportedBuildings[newIndex]; const metaBuilding = gMetaBuildingRegistry.findByClass(metaBuildingClass); this.selectBuildingForPlacement(metaBuilding);