From 71fbf8cad9cbdcabc725d3679a65dd211ffc73bd Mon Sep 17 00:00:00 2001 From: isaisstillalive Date: Wed, 1 Jul 2020 22:14:38 +0900 Subject: [PATCH] Click the storage to switch the display --- .../game/hud/parts/building_placer_logic.js | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/js/game/hud/parts/building_placer_logic.js b/src/js/game/hud/parts/building_placer_logic.js index d0737df8..2af363fb 100644 --- a/src/js/game/hud/parts/building_placer_logic.js +++ b/src/js/game/hud/parts/building_placer_logic.js @@ -264,10 +264,11 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { staticComp.rotation = this.currentBaseRotation; } } + /** - * Tries to delete the building under the mouse + * Get the building under the mouse */ - deleteBelowCursor() { + getContentBelowCursor() { const mousePosition = this.root.app.mousePosition; if (!mousePosition) { // Not on screen @@ -276,7 +277,14 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { const worldPos = this.root.camera.screenToWorld(mousePosition); const tile = worldPos.toTileSpace(); - const contents = this.root.map.getTileContent(tile, this.root.currentLayer); + return this.root.map.getTileContent(tile, this.root.currentLayer); + } + + /** + * Tries to delete the building under the mouse + */ + deleteBelowCursor() { + const contents = this.getContentBelowCursor(); if (contents) { if (this.root.logic.tryDeleteBuilding(contents)) { this.root.soundProxy.playUi(SOUNDS.destroyBuilding); @@ -692,6 +700,16 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart { if (button === enumMouseButton.right && metaBuilding) { this.currentMetaBuilding.set(null); } + + // Action + if (button === enumMouseButton.left && !metaBuilding) { + this.lastDragTile = this.root.camera.screenToWorld(pos).toTileSpace(); + const content = this.getContentBelowCursor(); + if (content && content.components.Storage) { + content.components.Storage.cycleDisplayType(); + // return STOP_PROPAGATION; + } + } } /**