diff --git a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs index 44917304b2..841e6325da 100644 --- a/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs +++ b/OpenRA.Mods.Common/Traits/Upgrades/DeployToUpgrade.cs @@ -53,6 +53,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("Sound to play when undeploying.")] public readonly string UndeploySound = null; + [Desc("Can this actor undeploy?")] + public readonly bool CanUndeploy = true; + public object Create(ActorInitializer init) { return new DeployToUpgrade(init, this); } } @@ -112,7 +115,7 @@ namespace OpenRA.Mods.Common.Traits public IEnumerable Orders { get { yield return new DeployOrderTargeter("DeployToUpgrade", 5, - () => IsOnValidTerrain() ? info.DeployCursor : info.DeployBlockedCursor); } + () => IsCursorBlocked() ? info.DeployBlockedCursor : info.DeployCursor); } } public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) @@ -131,7 +134,7 @@ namespace OpenRA.Mods.Common.Traits if (!order.Queued) self.CancelActivity(); - if (deployState == DeployState.Deployed) + if (deployState == DeployState.Deployed && info.CanUndeploy) { self.QueueActivity(new CallFunc(Undeploy)); } @@ -145,6 +148,11 @@ namespace OpenRA.Mods.Common.Traits } } + bool IsCursorBlocked() + { + return ((deployState == DeployState.Deployed) && !info.CanUndeploy) || (!IsOnValidTerrain() && (deployState != DeployState.Deployed)); + } + bool IsOnValidTerrain() { return IsOnValidTerrainType() && IsOnValidRampType();