fix: destruction order
This commit is contained in:
parent
aacfd6271f
commit
b04392756b
|
@ -38,6 +38,14 @@ export default class Collider extends Component {
|
||||||
return distance(entity.Position, l) > distance(entity.Position, r) ? -1 : 1;
|
return distance(entity.Position, l) > distance(entity.Position, r) ? -1 : 1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
destroy() {
|
||||||
|
const entity = ecs.get(this.entity);
|
||||||
|
for (const otherId in this.collidingWith) {
|
||||||
|
const other = ecs.get(otherId);
|
||||||
|
delete entity.Collider.collidingWith[other.id];
|
||||||
|
delete other.Collider.collidingWith[entity.id];
|
||||||
|
}
|
||||||
|
}
|
||||||
isCollidingWith(other) {
|
isCollidingWith(other) {
|
||||||
const {aabb, aabbs} = this;
|
const {aabb, aabbs} = this;
|
||||||
const {aabb: otherAabb, aabbs: otherAabbs} = other;
|
const {aabb: otherAabb, aabbs: otherAabbs} = other;
|
||||||
|
|
|
@ -233,12 +233,14 @@ export default class Ecs {
|
||||||
}
|
}
|
||||||
destroying[componentName].push(entityId);
|
destroying[componentName].push(entityId);
|
||||||
}
|
}
|
||||||
this.$$entities[entityId] = undefined;
|
|
||||||
this.diff[entityId] = false;
|
|
||||||
}
|
}
|
||||||
for (const i in destroying) {
|
for (const i in destroying) {
|
||||||
this.Components[i].destroyMany(destroying[i]);
|
this.Components[i].destroyMany(destroying[i]);
|
||||||
}
|
}
|
||||||
|
for (const entityId of entityIds) {
|
||||||
|
this.$$entities[entityId] = undefined;
|
||||||
|
this.diff[entityId] = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get entities() {
|
get entities() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user