chore: check

This commit is contained in:
cha0s 2022-09-17 09:07:29 -05:00
parent ee4de8ac60
commit ba533f6f4d

View File

@ -41,7 +41,16 @@ export default class BaseComponent {
}
destroyMany(entities) {
this.freeMany(entities.map((entity) => this.map[entity]).filter((index) => !!index));
this.freeMany(
entities
.map((entity) => {
if (entity in this.map) {
return this.map[entity];
}
throw new Error(`can't free for non-existent entity ${entity}`);
})
.filter((index) => !!index),
);
for (let i = 0; i < entities.length; i++) {
this.map[entities[i]] = undefined;
}