Index: binaries/data/mods/public/simulation/components/Foundation.js =================================================================== --- binaries/data/mods/public/simulation/components/Foundation.js +++ binaries/data/mods/public/simulation/components/Foundation.js @@ -453,8 +453,9 @@ PlaySound("constructed", building); - Engine.PostMessage(this.entity, MT_ConstructionFinished, - { "entity": this.entity, "newentity": building }); + for (let ent of this.GetBuilders()) + Engine.PostMessage(ent, MT_ConstructionFinished, + { "entity": this.entity, "newentity": building }); Engine.PostMessage(this.entity, MT_EntityRenamed, { "entity": this.entity, "newentity": building }); Engine.DestroyEntity(this.entity); Index: binaries/data/mods/public/simulation/components/Repairable.js =================================================================== --- binaries/data/mods/public/simulation/components/Repairable.js +++ binaries/data/mods/public/simulation/components/Repairable.js @@ -129,7 +129,8 @@ // If we repaired all the damage, send a message to entities to stop repairing this building if (amount >= damage) - Engine.PostMessage(this.entity, MT_ConstructionFinished, { "entity": this.entity, "newentity": this.entity }); + for (let ent of this.GetBuilders()) + Engine.PostMessage(this.entity, MT_ConstructionFinished, { "entity": this.entity, "newentity": this.entity }); }; Repairable.prototype.GetRepairRate = function() Index: binaries/data/mods/public/simulation/components/UnitAI.js =================================================================== --- binaries/data/mods/public/simulation/components/UnitAI.js +++ binaries/data/mods/public/simulation/components/UnitAI.js @@ -2839,7 +2839,7 @@ { // The building was already finished/fully repaired before we arrived; // let the ConstructionFinished handler handle this. - this.OnGlobalConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget}); + this.OnConstructionFinished({"entity": this.repairTarget, "newentity": this.repairTarget}); return true; } @@ -4137,11 +4137,8 @@ this.UnitFsm.ProcessMessage(this, Object.assign({ "type": "MovementUpdate" }, msg)); }; -UnitAI.prototype.OnGlobalConstructionFinished = function(msg) +UnitAI.prototype.OnConstructionFinished = function(msg) { - // TODO: This is a bit inefficient since every unit listens to every - // construction message - ideally we could scope it to only the one we're building - this.UnitFsm.ProcessMessage(this, {"type": "ConstructionFinished", "data": msg}); };