fix: entities iterator

This commit is contained in:
cha0s 2024-07-25 06:44:02 -05:00
parent 443797017f
commit ce802a8499

View File

@ -242,28 +242,17 @@ export default class Ecs {
this.Components[i].destroyMany(destroying[i]);
}
for (const entityId of entityIds) {
this.$$entities[entityId] = undefined;
delete this.$$entities[entityId];
this.diff[entityId] = false;
}
}
get entities() {
const it = Object.values(this.$$entities).values();
return {
[Symbol.iterator]() {
return this;
},
next: () => {
let result = it.next();
while (!result.done && !result.value) {
result = it.next();
const ids = [];
for (const entity of Object.values(this.$$entities)) {
ids.push(entity.id);
}
if (result.done) {
return {done: true, value: undefined};
}
return {done: false, value: result.value.id};
},
};
return ids;
}
get(entityId) {