make selection relative to world

This commit is contained in:
Dimava 2020-06-01 01:07:01 +03:00
parent 1dee6a6aa2
commit 7f5413a485
1 changed files with 5 additions and 2 deletions

View File

@ -41,6 +41,7 @@ export class HUDMassSelector extends BaseHUDPart {
this.deletionMarker = Loader.getSprite("sprites/misc/deletion_marker.png"); this.deletionMarker = Loader.getSprite("sprites/misc/deletion_marker.png");
this.currentSelectionStart = null; this.currentSelectionStart = null;
this.currentSelectionStartWorld = null;
this.currentSelectionEnd = null; this.currentSelectionEnd = null;
this.selectedUids = new Set(); this.selectedUids = new Set();
@ -147,6 +148,7 @@ export class HUDMassSelector extends BaseHUDPart {
} }
this.currentSelectionStart = pos.copy(); this.currentSelectionStart = pos.copy();
this.currentSelectionStartWorld = this.root.camera.screenToWorld(this.currentSelectionStart);
this.currentSelectionEnd = pos.copy(); this.currentSelectionEnd = pos.copy();
return STOP_PROPAGATION; return STOP_PROPAGATION;
} }
@ -163,7 +165,7 @@ export class HUDMassSelector extends BaseHUDPart {
onMouseUp() { onMouseUp() {
if (this.currentSelectionStart) { if (this.currentSelectionStart) {
const worldStart = this.root.camera.screenToWorld(this.currentSelectionStart); const worldStart = this.currentSelectionStartWorld;
const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd); const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd);
const tileStart = worldStart.toTileSpace(); const tileStart = worldStart.toTileSpace();
@ -182,6 +184,7 @@ export class HUDMassSelector extends BaseHUDPart {
} }
this.currentSelectionStart = null; this.currentSelectionStart = null;
this.currentSelectionStartWorld = null;
this.currentSelectionEnd = null; this.currentSelectionEnd = null;
} }
} }
@ -198,7 +201,7 @@ export class HUDMassSelector extends BaseHUDPart {
const boundsBorder = 2; const boundsBorder = 2;
if (this.currentSelectionStart) { if (this.currentSelectionStart) {
const worldStart = this.root.camera.screenToWorld(this.currentSelectionStart); const worldStart = this.currentSelectionStartWorld;
const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd); const worldEnd = this.root.camera.screenToWorld(this.currentSelectionEnd);
const realWorldStart = worldStart.min(worldEnd); const realWorldStart = worldStart.min(worldEnd);