From ec43274e2bd5d3c8a29b7f2761ec2fbfda2e4d5a Mon Sep 17 00:00:00 2001 From: mimo Date: Wed, 24 Feb 2016 18:49:28 +0000 Subject: [PATCH] drop carried resources when finishing to build a dropsite This was SVN commit r17801. --- .../data/mods/public/simulation/components/UnitAI.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 13cb226005..5f519ef6b2 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -2735,6 +2735,17 @@ UnitAI.prototype.UnitFsmSpec = { // Idle animation while moving towards finished construction looks weird (ghosty). var oldState = this.GetCurrentState(); + // Drop any resource we can if we are in range when the construction finishes + var cmpResourceGatherer = Engine.QueryInterface(this.entity, IID_ResourceGatherer); + var cmpResourceDropsite = Engine.QueryInterface(msg.data.newentity, IID_ResourceDropsite); + if (cmpResourceGatherer && cmpResourceDropsite && this.CheckTargetRange(msg.data.newentity, IID_Builder) && + this.CanReturnResource(msg.data.newentity, true)) + { + let dropsiteTypes = cmpResourceDropsite.GetTypes(); + cmpResourceGatherer.CommitResources(dropsiteTypes); + this.SetGathererAnimationOverride(); + } + // We finished building it. // Switch to the next order (if any) if (this.FinishOrder())