Skip to content

Commit bf3e54a

Browse files
committed
delete behavior ui in behavior list on BehaviorDestroyed signal
closes DRE-1546
1 parent 44b0953 commit bf3e54a

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

editor/client/ui/behavior-panel/behavior-list.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
Behavior,
33
BehaviorConstructor,
4+
BehaviorDestroyed,
45
BehaviorSpawned,
56
ClientGame,
67
Entity,
@@ -156,6 +157,16 @@ export class BehaviorList {
156157
this.editors.set(newBehavior.ref, editor);
157158
this.addBehavior(newBehavior);
158159
});
160+
161+
this.entity.on(BehaviorDestroyed, ({ behavior }) => {
162+
const existingBehaviorIdx = this.behaviors.findIndex(it => it.ref === behavior.ref);
163+
if (existingBehaviorIdx !== -1) this.behaviors.splice(existingBehaviorIdx, 1);
164+
165+
const editor = this.editors.get(behavior.ref);
166+
if (!editor) return;
167+
this.editors.delete(behavior.ref);
168+
editor.details.remove();
169+
});
159170
}
160171

161172
this.#drawAddBehavior(ui);

0 commit comments

Comments
 (0)