refactor: optimize ticking
This commit is contained in:
parent
637163d201
commit
38a780759a
|
@ -41,7 +41,9 @@ export default (latus) => {
|
|||
}
|
||||
this.#entities[uuid] = entity;
|
||||
this.#flatEntities.push(entity);
|
||||
if (entity.hasTickers()) {
|
||||
this.#entityTickers.push(entity.tick);
|
||||
}
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
entity.list = this;
|
||||
entity.emit('addedToList');
|
||||
|
@ -176,7 +178,10 @@ export default (latus) => {
|
|||
entity.emit('removedFromList', this);
|
||||
delete this.#entities[uuid];
|
||||
this.#flatEntities.splice(this.#flatEntities.indexOf(entity), 1);
|
||||
this.#entityTickers.splice(this.#entityTickers.indexOf(entity.tick), 1);
|
||||
const index = this.#entityTickers.indexOf(entity.tick);
|
||||
if (-1 !== index) {
|
||||
this.#entityTickers.splice(index, 1);
|
||||
}
|
||||
this.emit('entityRemoved', entity);
|
||||
}
|
||||
|
||||
|
|
|
@ -211,6 +211,10 @@ export default (latus) => {
|
|||
this.emit('destroyed');
|
||||
}
|
||||
|
||||
hasTickers() {
|
||||
return this.#traitTickers.length;
|
||||
}
|
||||
|
||||
invokeHook(hook, ...args) {
|
||||
const results = {};
|
||||
if (!(hook in this.#hooks)) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user