From e2a51676f7a4a733533f8b058a99a0525f3725eb Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Wed, 26 Dec 2018 10:56:30 +0100 Subject: [PATCH] Add an update rule for the PlaceSimpleBeacon removal --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + .../Rules/20190106/RemoveSimpleBeacon.cs | 55 +++++++++++++++++++ OpenRA.Mods.Common/UpdateRules/UpdatePath.cs | 1 + 3 files changed, 57 insertions(+) create mode 100644 OpenRA.Mods.Common/UpdateRules/Rules/20190106/RemoveSimpleBeacon.cs diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 36bd1e9e8e..8e22ea5b4f 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -610,6 +610,7 @@ + diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20190106/RemoveSimpleBeacon.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20190106/RemoveSimpleBeacon.cs new file mode 100644 index 0000000000..123d5cc5d4 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20190106/RemoveSimpleBeacon.cs @@ -0,0 +1,55 @@ +#region Copyright & License Information +/* + * Copyright 2007-2019 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 RemoveSimpleBeacon : UpdateRule + { + public override string Name { get { return "Remove 'PlaceSimpleBeacon'."; } } + public override string Description + { + get + { + return "The 'PlaceSimpleBeacon' trait was removed.\n" + + "Use the new functionality of the 'PlaceBeacon' trait instead."; + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + var psb = actorNode.LastChildMatching("PlaceSimpleBeacon"); + if (psb == null) + yield break; + + psb.RenameKey("PlaceBeacon"); + + var palette = psb.LastChildMatching("Palette"); + var isPlayer = psb.LastChildMatching("IsPlayerPalette"); + var sequence = psb.LastChildMatching("BeaconSequence"); + + if (palette == null) + psb.AddNode("Palette", "effect"); + + if (isPlayer == null) + psb.AddNode("IsPlayerPalette", "false"); + + if (sequence == null) + psb.AddNode("BeaconSequence", "idle"); + + psb.AddNode("ArrowSequence", ""); + psb.AddNode("CircleSequence", ""); + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index d6d1b5a2bf..6988ce7c68 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -119,6 +119,7 @@ namespace OpenRA.Mods.Common.UpdateRules // Bleed only changes here new RemoveAttackSuicides(), new MultipleDeploySounds(), + new RemoveSimpleBeacon(), new MakeMobilePausableConditional(), new StreamlineRepairableTraits(), })