mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Keep Belt planner mode while dragging if release the shift key
This commit is contained in:
parent
1092975f08
commit
ab24e1afae
@ -92,6 +92,12 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
||||
*/
|
||||
this.currentDirectionLockSide = 0;
|
||||
|
||||
/**
|
||||
* Keep holding direction lock while dragging
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.keepDirectionLock = false;
|
||||
|
||||
this.initializeBindings();
|
||||
}
|
||||
|
||||
@ -108,7 +114,6 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
||||
.add(this.switchDirectionLockSide, this);
|
||||
keyActionMapper.getBinding(KEYMAPPINGS.general.back).add(this.abortPlacement, this);
|
||||
keyActionMapper.getBinding(KEYMAPPINGS.placement.pipette).add(this.startPipette, this);
|
||||
this.root.gameState.inputReciever.keyup.add(this.checkForDirectionLockSwitch, this);
|
||||
|
||||
// BINDINGS TO GAME EVENTS
|
||||
this.root.hud.signals.buildingsSelectedForCopy.add(this.abortPlacement, this);
|
||||
@ -177,9 +182,10 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
||||
get isDirectionLockActive() {
|
||||
const metaBuilding = this.currentMetaBuilding.get();
|
||||
return (
|
||||
metaBuilding &&
|
||||
this.keepDirectionLock ||
|
||||
(metaBuilding &&
|
||||
metaBuilding.getHasDirectionLockAvailable() &&
|
||||
this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.lockBeltDirection).pressed
|
||||
this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.lockBeltDirection).pressed)
|
||||
);
|
||||
}
|
||||
|
||||
@ -419,19 +425,6 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
||||
this.currentDirectionLockSide = 1 - this.currentDirectionLockSide;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the direction lock key got released and if such, resets the placement
|
||||
* @param {any} args
|
||||
*/
|
||||
checkForDirectionLockSwitch({ keyCode }) {
|
||||
if (
|
||||
keyCode ===
|
||||
this.root.keyMapper.getBinding(KEYMAPPINGS.placementModifiers.lockBeltDirection).keyCode
|
||||
) {
|
||||
this.abortDragging();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tries to place the current building at the given tile
|
||||
* @param {Vector} tile
|
||||
@ -661,8 +654,10 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
||||
this.currentlyDeleting = false;
|
||||
this.lastDragTile = this.root.camera.screenToWorld(pos).toTileSpace();
|
||||
|
||||
if (this.isDirectionLockActive) {
|
||||
this.keepDirectionLock = true;
|
||||
} else {
|
||||
// Place initial building, but only if direction lock is not active
|
||||
if (!this.isDirectionLockActive) {
|
||||
if (this.tryPlaceCurrentBuildingAt(this.lastDragTile)) {
|
||||
this.root.soundProxy.playUi(metaBuilding.getPlacementSound());
|
||||
}
|
||||
@ -693,14 +688,14 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
||||
if (this.root.camera.getIsMapOverlayActive()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const metaBuilding = this.currentMetaBuilding.get();
|
||||
if ((metaBuilding || this.currentlyDeleting) && this.lastDragTile) {
|
||||
// Check for direction lock
|
||||
if (this.isDirectionLockActive) {
|
||||
this.keepDirectionLock = true;
|
||||
return;
|
||||
}
|
||||
|
||||
const metaBuilding = this.currentMetaBuilding.get();
|
||||
if ((metaBuilding || this.currentlyDeleting) && this.lastDragTile) {
|
||||
const oldPos = this.lastDragTile;
|
||||
let newPos = this.root.camera.screenToWorld(pos).toTileSpace();
|
||||
|
||||
@ -798,6 +793,7 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
|
||||
if (this.lastDragTile && this.currentlyDragging && this.isDirectionLockActive) {
|
||||
this.executeDirectionLockedPlacement();
|
||||
}
|
||||
this.keepDirectionLock = false;
|
||||
|
||||
this.abortDragging();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user