Skip to content

Commit 3ef1fa2

Browse files
committed
don't select tilemaps ever. more intelligent logic for selecting parent.
1 parent d34929a commit 3ef1fa2

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

editor/client/panning-and-selection.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ export class CameraPanBehavior extends Behavior {
6666
if (value) canvas.classList.add("grab");
6767
else canvas.classList.remove("grab");
6868
});
69+
70+
this.game.time.waitForNextTick().then(() => {
71+
this.ui!.selectedEntity.listen(() => {
72+
// when we unselect everything, clear the flag that prevents us from repeatedly selecting an empty parent.
73+
if (this.ui?.selectedEntity.entities.length === 0) {
74+
this.#lastParentPrepended = undefined;
75+
}
76+
});
77+
});
6978
}
7079

7180
#ignoreTilemap(): boolean {
@@ -566,6 +575,8 @@ export class CameraPanBehavior extends Behavior {
566575
return inside;
567576
}
568577

578+
#lastParentPrepended: undefined | EmptyFacade = undefined;
579+
569580
#onMouseUp(event: MouseUp) {
570581
if (!this.game.isClient()) return;
571582

@@ -592,6 +603,7 @@ export class CameraPanBehavior extends Behavior {
592603
.filter(entity => entity.enabled)
593604
.filter(entity => this.ui?.sceneGraph?.entryElementMap?.has(entity.ref) ?? true)
594605
.filter(entity => EditorMetadataEntity.getLockedBy(entity) === undefined)
606+
.filter(entity => !(entity instanceof EditorFacadeTilemap))
595607
.filter(entity => {
596608
// Special case for ComplexCollider
597609
if (entity.constructor.name === "EditorFacadeComplexCollider" && event.cursor.world) {
@@ -616,6 +628,13 @@ export class CameraPanBehavior extends Behavior {
616628
return 0;
617629
});
618630

631+
if (entities[0].parent instanceof EmptyFacade) {
632+
if (this.#lastParentPrepended !== entities[0].parent) {
633+
this.#lastParentPrepended = entities[0].parent;
634+
entities.unshift(entities[0].parent);
635+
}
636+
}
637+
619638
const currentTime = Date.now();
620639
const target = gizmo?.target ?? boxresize?.target;
621640

0 commit comments

Comments
 (0)