Disable direction lock for everything but belts

This commit is contained in:
tobspr 2020-06-16 20:10:00 +02:00
parent e2d6d9d51d
commit 31ab5f3422
4 changed files with 24 additions and 4 deletions

View File

@ -22,6 +22,10 @@ export class MetaBeltBaseBuilding extends MetaBuilding {
return "#777"; return "#777";
} }
getHasDirectionLockAvailable() {
return true;
}
/** /**
* @param {GameRoot} root * @param {GameRoot} root
* @param {string} variant * @param {string} variant

View File

@ -38,6 +38,10 @@ export class MetaUndergroundBeltBuilding extends MetaBuilding {
return true; return true;
} }
getHasDirectionLockAvailable() {
return true;
}
getStayInPlacementMode() { getStayInPlacementMode() {
return true; return true;
} }

View File

@ -162,6 +162,7 @@ export class HUDBuildingPlacer extends BaseHUDPart {
// Check for direction lock // Check for direction lock
if ( if (
metaBuilding.getHasDirectionLockAvailable() &&
this.root.keyMapper.getBinding(KEYMAPPINGS.placement.lockBeltDirection).isCurrentlyPressed() this.root.keyMapper.getBinding(KEYMAPPINGS.placement.lockBeltDirection).isCurrentlyPressed()
) { ) {
const vector = enumDirectionToVector[enumAngleToDirection[this.currentBaseRotation]]; const vector = enumDirectionToVector[enumAngleToDirection[this.currentBaseRotation]];
@ -177,9 +178,10 @@ export class HUDBuildingPlacer extends BaseHUDPart {
if ( if (
metaBuilding && metaBuilding &&
metaBuilding.getRotateAutomaticallyWhilePlacing(this.currentVariant.get()) && metaBuilding.getRotateAutomaticallyWhilePlacing(this.currentVariant.get()) &&
!this.root.keyMapper (!metaBuilding.getHasDirectionLockAvailable() ||
.getBinding(KEYMAPPINGS.placement.lockBeltDirection) !this.root.keyMapper
.isCurrentlyPressed() && .getBinding(KEYMAPPINGS.placement.lockBeltDirection)
.isCurrentlyPressed()) &&
!this.root.keyMapper !this.root.keyMapper
.getBinding(KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation) .getBinding(KEYMAPPINGS.placementModifiers.placementDisableAutoOrientation)
.isCurrentlyPressed() .isCurrentlyPressed()
@ -659,7 +661,10 @@ export class HUDBuildingPlacer extends BaseHUDPart {
// Draw direction lock // Draw direction lock
if (this.root.keyMapper.getBinding(KEYMAPPINGS.placement.lockBeltDirection).isCurrentlyPressed()) { if (
metaBuilding.getHasDirectionLockAvailable() &&
this.root.keyMapper.getBinding(KEYMAPPINGS.placement.lockBeltDirection).isCurrentlyPressed()
) {
if (this.lastDragTile) { if (this.lastDragTile) {
parameters.context.fillStyle = THEME.map.selectionBackground; parameters.context.fillStyle = THEME.map.selectionBackground;
parameters.context.strokeStyle = THEME.map.selectionOverlay; parameters.context.strokeStyle = THEME.map.selectionOverlay;

View File

@ -31,6 +31,13 @@ export class MetaBuilding {
return new Vector(1, 1); return new Vector(1, 1);
} }
/**
* Returns whether the building has the direction lock switch available
*/
getHasDirectionLockAvailable() {
return false;
}
/** /**
* Whether to stay in placement mode after having placed a building * Whether to stay in placement mode after having placed a building
*/ */