fix: query deindexing
This commit is contained in:
parent
c224445345
commit
fa817e3072
|
@ -170,10 +170,16 @@ test('ticks systems', async () => {
|
|||
.to.deep.equal(JSON.stringify({y: 128 + 30}));
|
||||
});
|
||||
|
||||
test('schedules entities to be deleted when ticking systems', () => {
|
||||
test('schedules entities to be deleted when ticking systems', async () => {
|
||||
const ecs = new Ecs({
|
||||
Components: {Empty},
|
||||
Systems: {
|
||||
Despawn: class extends System {
|
||||
static queries() {
|
||||
return {
|
||||
default: ['Empty'],
|
||||
};
|
||||
}
|
||||
tick() {
|
||||
this.ecs.destroy(1);
|
||||
expect(ecs.get(1))
|
||||
|
@ -183,8 +189,10 @@ test('schedules entities to be deleted when ticking systems', () => {
|
|||
},
|
||||
});
|
||||
ecs.system('Despawn').active = true;
|
||||
ecs.create();
|
||||
await ecs.create({Empty: {}});
|
||||
ecs.tick(1);
|
||||
expect(Array.from(ecs.system('Despawn').select('default')))
|
||||
.to.have.lengthOf(0);
|
||||
expect(ecs.get(1))
|
||||
.to.be.undefined;
|
||||
});
|
||||
|
|
|
@ -24,8 +24,8 @@ export default class Query {
|
|||
}
|
||||
|
||||
deindex(entityIds) {
|
||||
for (let i = 0; i < entityIds.length; ++i) {
|
||||
this.$$index.delete(entityIds[i]);
|
||||
for (const entityId of entityIds) {
|
||||
this.$$index.delete(entityId);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user