From a456c234caa25901bb58f9c3fa639cac15ba1b9d Mon Sep 17 00:00:00 2001 From: Zimmermann Gyula Date: Sun, 20 May 2018 16:06:37 +0200 Subject: [PATCH] Provide appropriate upgrade rule. --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + ...veCanUndeployFromGrantConditionOnDeploy.cs | 48 +++++++++++++++++++ OpenRA.Mods.Common/UpdateRules/UpdatePath.cs | 1 + 3 files changed, 50 insertions(+) create mode 100644 OpenRA.Mods.Common/UpdateRules/Rules/RemoveCanUndeployFromGrantConditionOnDeploy.cs diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 973b7f9efc..3d44d2ea6b 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -910,6 +910,7 @@ + diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/RemoveCanUndeployFromGrantConditionOnDeploy.cs b/OpenRA.Mods.Common/UpdateRules/Rules/RemoveCanUndeployFromGrantConditionOnDeploy.cs new file mode 100644 index 0000000000..dd072785ac --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/RemoveCanUndeployFromGrantConditionOnDeploy.cs @@ -0,0 +1,48 @@ +#region Copyright & License Information +/* + * Copyright 2007-2018 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using System.Collections.Generic; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class RemoveCanUndeployFromGrantConditionOnDeploy : UpdateRule + { + public override string Name { get { return "Remove CanUndeploy from GrantConditionOnDeploy."; } } + public override string Description + { + get + { + return "The CanUndeploy property was removed from the GrantConditionOnDeploy trait.\n" + + "Pausing the trait itself achieves the same effect now."; + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + foreach (var gcod in actorNode.ChildrenMatching("GrantConditionOnDeploy")) + { + var canUndeploy = gcod.LastChildMatching("CanUndeploy"); + if (canUndeploy == null) + continue; + + gcod.RemoveNode(canUndeploy); + + if (canUndeploy.NodeValue()) + continue; + + var deployedCondition = gcod.LastChildMatching("DeployedCondition"); + gcod.AddNode("PauseOnCondition", deployedCondition.Value.Value); + } + + yield break; + } + } +} \ No newline at end of file diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index 1c424f0c48..60dcb3b660 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -82,6 +82,7 @@ namespace OpenRA.Mods.Common.UpdateRules new SplitRepairDecoration(), new MoveHackyAISupportPowerDecisions(), new DefineGroundCorpseDefault(), + new RemoveCanUndeployFromGrantConditionOnDeploy(), }) };