fix: destroy guard

This commit is contained in:
cha0s 2019-05-16 15:19:57 -05:00
parent 877541f6ce
commit 2747542932

View File

@ -23,6 +23,7 @@ export class Existent extends decorate(Trait) {
constructor(entity, params, state) {
super(entity, params, state);
this._isDestroying = false;
this._isTicking = this.params.isTicking;
}
@ -30,6 +31,10 @@ export class Existent extends decorate(Trait) {
return {
destroy: () => {
if (this._isDestroying) {
return;
}
this._isDestroying = true;
this.entity.isTicking = false;
this.entity.emit('destroy');
this.entity.emit('destroyed');