diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 8e2f566326..6294c1d5fe 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -921,6 +921,7 @@ + diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20180923/LowPowerSlowdownToModifier.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20180923/LowPowerSlowdownToModifier.cs new file mode 100644 index 0000000000..a4116b8673 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20180923/LowPowerSlowdownToModifier.cs @@ -0,0 +1,54 @@ +#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; +using System.Linq; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class LowPowerSlowdownToModifier : UpdateRule + { + public override string Name { get { return "LowPowerSlowdown is renamed to LowPowerModifier"; } } + public override string Description + { + get + { + return "ProductionQueue.LowPowerSlowdown is renamed to LowPowerModifier, and\n" + + "multiplied by 100 to allow multiplying the build time with non-integer values.\n" + + "Also default value is changed to 100."; + } + } + + readonly string[] queueTraits = { "ProductionQueue", "ClassicProductionQueue" }; + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + foreach (var queue in queueTraits.SelectMany(t => actorNode.ChildrenMatching(t))) + { + var lowPower = queue.LastChildMatching("LowPowerSlowdown"); + if (lowPower != null) + { + if (lowPower.NodeValue() == 1) + queue.RemoveNodes("LowPowerSlowdown"); + else + { + lowPower.RenameKey("LowPowerModifier"); + lowPower.ReplaceValue((lowPower.NodeValue() * 100).ToString()); + } + } + else + queue.AddNode("LowPowerModifier", "300"); + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index a51126e423..a7546dd3dc 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -94,6 +94,7 @@ namespace OpenRA.Mods.Common.UpdateRules new MergeRearmAndRepairAnimation(), new MergeCaptureTraits(), new RemovedNotifyBuildComplete(), + new LowPowerSlowdownToModifier(), }) };