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]);
|
this.Components[i].destroyMany(destroying[i]);
|
||||||
}
|
}
|
||||||
for (const entityId of entityIds) {
|
for (const entityId of entityIds) {
|
||||||
this.$$entities[entityId] = undefined;
|
delete this.$$entities[entityId];
|
||||||
this.diff[entityId] = false;
|
this.diff[entityId] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
get entities() {
|
get entities() {
|
||||||
const it = Object.values(this.$$entities).values();
|
const ids = [];
|
||||||
return {
|
for (const entity of Object.values(this.$$entities)) {
|
||||||
[Symbol.iterator]() {
|
ids.push(entity.id);
|
||||||
return this;
|
|
||||||
},
|
|
||||||
next: () => {
|
|
||||||
let result = it.next();
|
|
||||||
while (!result.done && !result.value) {
|
|
||||||
result = it.next();
|
|
||||||
}
|
}
|
||||||
if (result.done) {
|
return ids;
|
||||||
return {done: true, value: undefined};
|
|
||||||
}
|
|
||||||
return {done: false, value: result.value.id};
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get(entityId) {
|
get(entityId) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user