fix: entities iterator
This commit is contained in:
parent
443797017f
commit
ce802a8499
|
@ -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();
|
||||
}
|
||||
if (result.done) {
|
||||
return {done: true, value: undefined};
|
||||
}
|
||||
return {done: false, value: result.value.id};
|
||||
},
|
||||
};
|
||||
const ids = [];
|
||||
for (const entity of Object.values(this.$$entities)) {
|
||||
ids.push(entity.id);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
get(entityId) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user