chore: destroy async
This commit is contained in:
parent
901b36e5c7
commit
a94ca185dc
|
@ -57,10 +57,17 @@ export default (latus) => {
|
|||
this.startSynchronizing(entity);
|
||||
}
|
||||
|
||||
destroy() {
|
||||
async destroy() {
|
||||
await this.destroyEntities();
|
||||
}
|
||||
|
||||
destroyEntities() {
|
||||
const promises = [];
|
||||
for (let i = 0; i < this.#flatEntities.length; i++) {
|
||||
this.#flatEntities[i].destroy();
|
||||
promises.push(this.#flatEntities[i].destroy());
|
||||
this.#flatEntities[i].tick(Infinity);
|
||||
}
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
get entities() {
|
||||
|
@ -78,6 +85,7 @@ export default (latus) => {
|
|||
if (0 === json.length) {
|
||||
return;
|
||||
}
|
||||
await this.destroyEntities();
|
||||
const {Entity} = latus.get('%resources');
|
||||
const entityInstances = await Promise.all(json.map((entity) => Entity.load(entity)));
|
||||
for (let i = 0; i < entityInstances.length; i++) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user