Further performance improvements

This commit is contained in:
tobspr 2020-05-27 15:25:17 +02:00
parent 1db5d4f7cb
commit 52e05f14c0
2 changed files with 13 additions and 0 deletions

View File

@ -8,6 +8,7 @@ export const CHANGELOG = [
"Added confirmation when deleting more than 500 buildings at a time", "Added confirmation when deleting more than 500 buildings at a time",
"Added background to toolbar to increase contrast", "Added background to toolbar to increase contrast",
"Allow placing extractors anywhere again, but they don't work at all if not placed on a resource", "Allow placing extractors anywhere again, but they don't work at all if not placed on a resource",
"Fix cycling through keybindings selecting locked buildings as well",
], ],
}, },
{ {

View File

@ -160,6 +160,14 @@ export class GameSystemWithFilter extends GameSystem {
refreshCaches() { refreshCaches() {
this.allEntities.sort((a, b) => a.uid - b.uid); this.allEntities.sort((a, b) => a.uid - b.uid);
// Remove all entities which are queued for destroy
for (let i = 0; i < this.allEntities.length; ++i) {
const entity = this.allEntities[i];
if (entity.queuedForDestroy || entity.destroyed) {
this.allEntities.splice(i, 1);
}
}
} }
/** /**
@ -187,6 +195,10 @@ export class GameSystemWithFilter extends GameSystem {
* @param {Entity} entity * @param {Entity} entity
*/ */
internalPopEntityIfMatching(entity) { internalPopEntityIfMatching(entity) {
if (this.root.bulkOperationRunning) {
// We do this in refreshCaches afterwards
return;
}
const index = this.allEntities.indexOf(entity); const index = this.allEntities.indexOf(entity);
if (index >= 0) { if (index >= 0) {
arrayDelete(this.allEntities, index); arrayDelete(this.allEntities, index);