fix: unloop and avoid null traits from immediate destroy
This commit is contained in:
parent
643f2bbf62
commit
c53a3308ee
|
@ -245,7 +245,7 @@ export class Entity extends decorate(Resource) {
|
|||
// Remove instance.
|
||||
delete this._traits[type];
|
||||
// Unloop.
|
||||
// instance.entity = undefined;
|
||||
instance.entity = undefined;
|
||||
}
|
||||
|
||||
removeTraits(types) {
|
||||
|
@ -261,6 +261,11 @@ export class Entity extends decorate(Resource) {
|
|||
|
||||
tick(elapsed) {
|
||||
for (const type in this._traits) {
|
||||
// If .destroy is called immediately when ticking a trait, then the next
|
||||
// traits could go away.
|
||||
if (!(type in this._traits)) {
|
||||
continue;
|
||||
}
|
||||
const instance = this._traits[type];
|
||||
instance.tick(elapsed);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user