1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-02-18 13:59:20 +00:00

Require LMB to place blueprints

This commit is contained in:
Ethan Chapman 2020-11-09 16:17:03 -05:00 committed by GitHub
parent d33a72202a
commit 95a25f3f22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,22 +110,24 @@ export class HUDBlueprintPlacer extends BaseHUDPart {
} }
} }
const blueprint = this.currentBlueprint.get(); if (button === enumMouseButton.left) {
if (!blueprint) { const blueprint = this.currentBlueprint.get();
return; if (!blueprint) {
} return;
}
if (!blueprint.canAfford(this.root)) { if (!blueprint.canAfford(this.root)) {
this.root.soundProxy.playUiError(); this.root.soundProxy.playUiError();
return; return;
} }
const worldPos = this.root.camera.screenToWorld(pos); const worldPos = this.root.camera.screenToWorld(pos);
const tile = worldPos.toTileSpace(); const tile = worldPos.toTileSpace();
if (blueprint.tryPlace(this.root, tile)) { if (blueprint.tryPlace(this.root, tile)) {
const cost = blueprint.getCost(); const cost = blueprint.getCost();
this.root.hubGoals.takeShapeByKey(this.root.gameMode.getBlueprintShapeKey(), cost); this.root.hubGoals.takeShapeByKey(this.root.gameMode.getBlueprintShapeKey(), cost);
this.root.soundProxy.playUi(SOUNDS.placeBuilding); this.root.soundProxy.playUi(SOUNDS.placeBuilding);
}
} }
} }