mirror of
https://github.com/tobspr/shapez.io.git
synced 2024-10-27 20:34:29 +00:00
Disable automatic rotation for buildings except belts
This commit is contained in:
parent
d2864e7385
commit
a26ef05543
@ -65,6 +65,10 @@ export class MetaBeltBaseBuilding extends MetaBuilding {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRotateAutomaticallyWhilePlacing() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the entity at the given location
|
* Creates the entity at the given location
|
||||||
* @param {Entity} entity
|
* @param {Entity} entity
|
||||||
|
@ -97,18 +97,21 @@ export class HUDBuildingPlacer extends BaseHUDPart {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.currentMetaBuilding.get() && this.lastDragTile) {
|
const metaBuilding = this.currentMetaBuilding.get();
|
||||||
|
if (metaBuilding && this.lastDragTile) {
|
||||||
const oldPos = this.lastDragTile;
|
const oldPos = this.lastDragTile;
|
||||||
const newPos = this.root.camera.screenToWorld(pos).toTileSpace();
|
const newPos = this.root.camera.screenToWorld(pos).toTileSpace();
|
||||||
|
|
||||||
if (!oldPos.equals(newPos)) {
|
if (!oldPos.equals(newPos)) {
|
||||||
const delta = newPos.sub(oldPos);
|
if (metaBuilding.getRotateAutomaticallyWhilePlacing()) {
|
||||||
const angleDeg = Math_degrees(delta.angle());
|
const delta = newPos.sub(oldPos);
|
||||||
this.currentBaseRotation = (Math.round(angleDeg / 90) * 90 + 360) % 360;
|
const angleDeg = Math_degrees(delta.angle());
|
||||||
|
this.currentBaseRotation = (Math.round(angleDeg / 90) * 90 + 360) % 360;
|
||||||
|
|
||||||
// Holding alt inverts the placement
|
// Holding alt inverts the placement
|
||||||
if (this.root.app.inputMgr.altIsDown) {
|
if (this.root.app.inputMgr.altIsDown) {
|
||||||
this.currentBaseRotation = (180 + this.currentBaseRotation) % 360;
|
this.currentBaseRotation = (180 + this.currentBaseRotation) % 360;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// - Using bresenhams algorithmus
|
// - Using bresenhams algorithmus
|
||||||
|
@ -57,6 +57,13 @@ export class MetaBuilding {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether to rotate automatically in the dragging direction while placing
|
||||||
|
*/
|
||||||
|
getRotateAutomaticallyWhilePlacing() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a preview sprite
|
* Returns a preview sprite
|
||||||
* @returns {AtlasSprite}
|
* @returns {AtlasSprite}
|
||||||
|
Loading…
Reference in New Issue
Block a user