refactor: after destruction ticker method

This commit is contained in:
cha0s 2019-05-02 20:17:46 -05:00
parent 8c33d58030
commit 53678d106c

View File

@ -98,19 +98,7 @@ export class EntityList extends decorate(class {}) {
}
tick(elapsed) {
// Run after destruction tickers.
const finishedTickers = [];
for (let i = 0; i < this._afterDestructionTickers.length; ++i) {
const ticker = this._afterDestructionTickers[i];
if (ticker(elapsed)) {
finishedTickers.push(ticker);
}
}
for (let i = 0; i < finishedTickers.length; ++i) {
const ticker = finishedTickers[i];
const index = this._afterDestructionTickers.indexOf(ticker);
this._afterDestructionTickers.splice(index, 1);
}
this.tickAfterDestructionTickers(elapsed);
// Run normal tickers.
for (const uuid in this._entities) {
const entity = this._entities[uuid];
@ -131,6 +119,22 @@ export class EntityList extends decorate(class {}) {
}
}
tickAfterDestructionTickers(elapsed) {
// Run after destruction tickers.
const finishedTickers = [];
for (let i = 0; i < this._afterDestructionTickers.length; ++i) {
const ticker = this._afterDestructionTickers[i];
if (ticker(elapsed)) {
finishedTickers.push(ticker);
}
}
for (let i = 0; i < finishedTickers.length; ++i) {
const ticker = finishedTickers[i];
const index = this._afterDestructionTickers.indexOf(ticker);
this._afterDestructionTickers.splice(index, 1);
}
}
visibleEntities(query) {
const entities = [];
const entitiesTrack = [];