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
@@ -3596,7 +3596,11 @@
if (!cmpUnitMotion)
cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
- return !!cmpUnitMotion;
+ if (!cmpUnitMotion)
+ return false;
+
+ let cmpUpgrade = Engine.QueryInterface(this.entity, IID_Upgrade);
+ return !cmpUpgrade || !cmpUpgrade.IsUpgrading() || cmpUpgrade.IsUpgrading() && cmpUpgrade.CanMoveWhileUpgrading();
};
UnitAI.prototype.IsFleeing = function()
Index: binaries/data/mods/public/simulation/components/Upgrade.js
===================================================================
--- binaries/data/mods/public/simulation/components/Upgrade.js
+++ binaries/data/mods/public/simulation/components/Upgrade.js
@@ -40,6 +40,9 @@
"" +
"" +
"" +
+ "" +
+ "" +
+ "" +
"" +
"" +
"" +
@@ -174,6 +177,11 @@
return this.upgrading;
};
+Upgrade.prototype.CanMoveWhileUpgrading = function()
+{
+ return this.template.CanMoveWhileUpgrading == "true";
+};
+
Upgrade.prototype.WillCheckPlacementRestrictions = function(template)
{
if (!this.upgradeTemplates[template])
@@ -228,6 +236,10 @@
if (this.IsUpgrading() || !this.upgradeTemplates[template])
return false;
+ let cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion);
+ if (cmpUnitMotion && cmpUnitMotion.IsMoveRequested() && !this.CanMoveWhileUpgrading())
+ cmpUnitMotion.StopMoving();
+
let cmpPlayer = QueryOwnerInterface(this.entity, IID_Player);
if (!cmpPlayer)
return false;
Index: binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
===================================================================
--- binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
+++ binaries/data/mods/public/simulation/components/tests/test_UnitAI.js
@@ -15,6 +15,7 @@
Engine.LoadComponentScript("interfaces/ResourceGatherer.js");
Engine.LoadComponentScript("interfaces/Timer.js");
Engine.LoadComponentScript("interfaces/UnitAI.js");
+Engine.LoadComponentScript("interfaces/Upgrade.js");
Engine.LoadComponentScript("Formation.js");
Engine.LoadComponentScript("UnitAI.js");