diff --git a/src/js/game/buildings/belt_base.js b/src/js/game/buildings/belt_base.js index b7459de0..2a74c629 100644 --- a/src/js/game/buildings/belt_base.js +++ b/src/js/game/buildings/belt_base.js @@ -65,6 +65,10 @@ export class MetaBeltBaseBuilding extends MetaBuilding { return true; } + getRotateAutomaticallyWhilePlacing() { + return true; + } + /** * Creates the entity at the given location * @param {Entity} entity diff --git a/src/js/game/hud/parts/building_placer.js b/src/js/game/hud/parts/building_placer.js index 3e8b29ff..b66eae3c 100644 --- a/src/js/game/hud/parts/building_placer.js +++ b/src/js/game/hud/parts/building_placer.js @@ -97,18 +97,21 @@ export class HUDBuildingPlacer extends BaseHUDPart { return; } - if (this.currentMetaBuilding.get() && this.lastDragTile) { + const metaBuilding = this.currentMetaBuilding.get(); + if (metaBuilding && this.lastDragTile) { const oldPos = this.lastDragTile; const newPos = this.root.camera.screenToWorld(pos).toTileSpace(); if (!oldPos.equals(newPos)) { - const delta = newPos.sub(oldPos); - const angleDeg = Math_degrees(delta.angle()); - this.currentBaseRotation = (Math.round(angleDeg / 90) * 90 + 360) % 360; - - // Holding alt inverts the placement - if (this.root.app.inputMgr.altIsDown) { - this.currentBaseRotation = (180 + this.currentBaseRotation) % 360; + if (metaBuilding.getRotateAutomaticallyWhilePlacing()) { + const delta = newPos.sub(oldPos); + const angleDeg = Math_degrees(delta.angle()); + this.currentBaseRotation = (Math.round(angleDeg / 90) * 90 + 360) % 360; + + // Holding alt inverts the placement + if (this.root.app.inputMgr.altIsDown) { + this.currentBaseRotation = (180 + this.currentBaseRotation) % 360; + } } // - Using bresenhams algorithmus diff --git a/src/js/game/meta_building.js b/src/js/game/meta_building.js index 60d01905..892c93ce 100644 --- a/src/js/game/meta_building.js +++ b/src/js/game/meta_building.js @@ -57,6 +57,13 @@ export class MetaBuilding { return false; } + /** + * Whether to rotate automatically in the dragging direction while placing + */ + getRotateAutomaticallyWhilePlacing() { + return false; + } + /** * Returns a preview sprite * @returns {AtlasSprite}