feat: ticking destruction dependencies
This commit is contained in:
parent
82e37f9b91
commit
b719e3227b
|
@ -1,7 +1,7 @@
|
||||||
import {Encoder, Decoder} from '@msgpack/msgpack';
|
import {Encoder, Decoder} from '@msgpack/msgpack';
|
||||||
import {LRUCache} from 'lru-cache';
|
import {LRUCache} from 'lru-cache';
|
||||||
|
|
||||||
import {withResolvers} from '@/util/promise.js';
|
import {Ticker, withResolvers} from '@/util/promise.js';
|
||||||
import Script from '@/util/script.js';
|
import Script from '@/util/script.js';
|
||||||
|
|
||||||
import EntityFactory from './entity-factory.js';
|
import EntityFactory from './entity-factory.js';
|
||||||
|
@ -462,10 +462,17 @@ export default class Ecs {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const destroying = new Set();
|
const destroying = new Set();
|
||||||
for (const [entityId, {promises, resolvers}] of this.$$destructionDependencies) {
|
for (const [entityId, {promises}] of this.$$destructionDependencies) {
|
||||||
if (0 === promises.size && resolvers) {
|
if (0 === promises.size) {
|
||||||
destroying.add(entityId);
|
destroying.add(entityId);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
for (const promise of promises) {
|
||||||
|
if (promise instanceof Ticker) {
|
||||||
|
promise.tick(elapsed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (destroying.size > 0) {
|
if (destroying.size > 0) {
|
||||||
this.destroyMany(destroying);
|
this.destroyMany(destroying);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user