diff --git a/binaries/data/mods/public/simulation/ai/common-api/shared.js b/binaries/data/mods/public/simulation/ai/common-api/shared.js index 2d0f735ef5..0467b3d3d5 100644 --- a/binaries/data/mods/public/simulation/ai/common-api/shared.js +++ b/binaries/data/mods/public/simulation/ai/common-api/shared.js @@ -237,9 +237,6 @@ SharedScript.prototype.ApplyEntitiesDelta = function(state) for (const evt of state.events.Destroy) { - if (!this._entities.has(evt.entity)) - continue;// probably should remove the event. - if (foundationFinished[evt.entity]) evt.SuccessfulFoundation = true; @@ -251,9 +248,12 @@ SharedScript.prototype.ApplyEntitiesDelta = function(state) evt.metadata[player] = this._entityMetadata[player][evt.entity]; const entity = this._entities.get(evt.entity); - for (const entCol of this._entityCollections.values()) - entCol.removeEnt(entity); - this.entities.removeEnt(entity); + if (entity) + { + for (const entCol of this._entityCollections.values()) + entCol.removeEnt(entity); + this.entities.removeEnt(entity); + } this._entities.delete(evt.entity); this._entitiesModifications.delete(evt.entity);