From 4bf659ca38dbc8de3dc3cc0264ec9c72984ad4f8 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 13 Jul 2019 00:00:12 +0200 Subject: [PATCH] CanSlide update rule --- .../UpdateRules/Rules/20190314/AddCanSlide.cs | 48 +++++++++++++++++++ OpenRA.Mods.Common/UpdateRules/UpdatePath.cs | 1 + mods/cnc/rules/defaults.yaml | 2 + mods/ra/rules/defaults.yaml | 2 + 4 files changed, 53 insertions(+) create mode 100644 OpenRA.Mods.Common/UpdateRules/Rules/20190314/AddCanSlide.cs diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20190314/AddCanSlide.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20190314/AddCanSlide.cs new file mode 100644 index 0000000000..b6ff6a7409 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20190314/AddCanSlide.cs @@ -0,0 +1,48 @@ +#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; +using System.Collections.Generic; +using System.Linq; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class AddCanSlide : UpdateRule + { + public override string Name { get { return "Split CanSlide from CanHover"; } } + public override string Description + { + get + { + return "Aircraft.CanHover was split into two flags; CanHover now only makes aircraft hover when idle,\n" + + "while CanSlide toggles the ability to immediately changing direction without flying a curve."; + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + var aircraftTraits = actorNode.ChildrenMatching("Aircraft"); + foreach (var aircraft in aircraftTraits) + { + var canHover = false; + var canHoverNode = aircraft.LastChildMatching("CanHover"); + if (canHoverNode != null) + canHover = canHoverNode.NodeValue(); + else + yield break; + + aircraft.AddNode("CanSlide", canHover.ToString()); + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index 1e9d984b88..cf182a7092 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -130,6 +130,7 @@ namespace OpenRA.Mods.Common.UpdateRules new RenameHoversOffsetModifier(), new AddAirAttackTypes(), new RenameCarryallDelays(), + new AddCanSlide(), }) }; diff --git a/mods/cnc/rules/defaults.yaml b/mods/cnc/rules/defaults.yaml index 4e431cdd3e..42ab742be6 100644 --- a/mods/cnc/rules/defaults.yaml +++ b/mods/cnc/rules/defaults.yaml @@ -331,6 +331,7 @@ LandableTerrainTypes: Clear, Rough, Road, Beach, Tiberium, BlueTiberium Crushes: crate, infantry InitialFacing: 224 + CanSlide: True HiddenUnderFog: Type: GroundPosition ActorLostNotification: @@ -1091,6 +1092,7 @@ Aircraft: CanHover: True VTOL: true + CanSlide: True FallsToEarth: Spins: True Moves: False diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 28a8d56e2e..a113e56221 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -634,6 +634,7 @@ LandableTerrainTypes: Clear, Rough, Road, Ore, Beach, Gems Crushes: crate, mine, infantry InitialFacing: 224 + CanSlide: True GpsDot: String: Helicopter Hovers@CRUISING: @@ -1047,6 +1048,7 @@ Aircraft: CanHover: True VTOL: true + CanSlide: True FallsToEarth: Explosion: UnitExplodeHeli BodyOrientation: