diff --git a/app/ecs/ecs.js b/app/ecs/ecs.js index 7485a94..2f8eb28 100644 --- a/app/ecs/ecs.js +++ b/app/ecs/ecs.js @@ -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) {