1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Cleanup click detector code

This commit is contained in:
tobspr
2020-06-21 18:11:41 +02:00
parent fd70130ec4
commit 2dec257dd9
4 changed files with 8 additions and 89 deletions

View File

@@ -243,20 +243,10 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
* @param {boolean} cancelAction
*/
onCanvasClick(mousePos, cancelAction = false) {
if (cancelAction) {
if (this.currentMetaBuilding.get()) {
this.currentMetaBuilding.set(null);
} else {
this.deleteBelowCursor();
}
// Prevent any other canvas clicks
if (this.currentMetaBuilding.get()) {
return STOP_PROPAGATION;
}
if (!this.currentMetaBuilding.get()) {
return;
}
return STOP_PROPAGATION;
}
/**
@@ -479,13 +469,18 @@ export class HUDBuildingPlacerLogic extends BaseHUDPart {
}
// Deletion
if (button === enumMouseButton.right && !this.currentMetaBuilding.get()) {
if (button === enumMouseButton.right && !metaBuilding) {
this.currentlyDragging = true;
this.currentlyDeleting = true;
this.lastDragTile = this.root.camera.screenToWorld(pos).toTileSpace();
this.currentMetaBuilding.set(null);
return STOP_PROPAGATION;
}
// Cancel placement
if (button === enumMouseButton.right && metaBuilding) {
this.currentMetaBuilding.set(null);
}
}
/**