From cdac14b92b5090d302cea5443e2414d841880b3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 12 Sep 2021 12:47:50 +0200 Subject: [PATCH] Avoid duplicate field. --- OpenRA.Mods.Common/Traits/Air/AttackBomber.cs | 3 -- .../20200503/AttackBomberFacingTolerance.cs | 37 +++++++++++++++++++ OpenRA.Mods.Common/UpdateRules/UpdatePath.cs | 1 + mods/cnc/rules/aircraft.yaml | 1 + mods/d2k/rules/aircraft.yaml | 1 + mods/ra/rules/aircraft.yaml | 2 + 6 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 OpenRA.Mods.Common/UpdateRules/Rules/20200503/AttackBomberFacingTolerance.cs diff --git a/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs b/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs index 0fcb4feaa5..de34c0dcfa 100644 --- a/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs +++ b/OpenRA.Mods.Common/Traits/Air/AttackBomber.cs @@ -19,9 +19,6 @@ namespace OpenRA.Mods.Common.Traits { public class AttackBomberInfo : AttackBaseInfo { - [Desc("Tolerance for attack angle. Range [0, 512], 512 covers 360 degrees.")] - public readonly new WAngle FacingTolerance = new WAngle(8); - public override object Create(ActorInitializer init) { return new AttackBomber(init.Self, this); } } diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20200503/AttackBomberFacingTolerance.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20200503/AttackBomberFacingTolerance.cs new file mode 100644 index 0000000000..5e6026bdab --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20200503/AttackBomberFacingTolerance.cs @@ -0,0 +1,37 @@ +#region Copyright & License Information +/* + * Copyright 2007-2021 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 AttackBomberFacingTolerance : UpdateRule + { + public override string Name => "Adds the old default value for AttackBomber FacingTolerance."; + + public override string Description => "The tolerance for attack angle was defined twice on AttackBomber. This override has to be defined in the rules now."; + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + foreach (var attackBomber in actorNode.ChildrenMatching("AttackBomber")) + { + var facingTolerance = attackBomber.LastChildMatching("FacingTolerance"); + if (facingTolerance != null) + continue; + + var facingToleranceNode = new MiniYamlNode("FacingTolerance", FieldSaver.FormatValue(new WAngle(8))); + attackBomber.AddNode(facingToleranceNode); + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index fd9b8518ea..d6dd5d381e 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -96,6 +96,7 @@ namespace OpenRA.Mods.Common.UpdateRules new RemoveSmokeTrailWhenDamaged(), new ReplaceCrateSecondsWithTicks(), new UseMillisecondsForSounds(), + new AttackBomberFacingTolerance(), }) }; diff --git a/mods/cnc/rules/aircraft.yaml b/mods/cnc/rules/aircraft.yaml index 9f3e5b1636..b58f3e34af 100644 --- a/mods/cnc/rules/aircraft.yaml +++ b/mods/cnc/rules/aircraft.yaml @@ -239,6 +239,7 @@ A10: Repulsable: False AttackBomber: Armaments: gun, bombs + FacingTolerance: 8 Armament@GUNS: Name: gun Weapon: Vulcan diff --git a/mods/d2k/rules/aircraft.yaml b/mods/d2k/rules/aircraft.yaml index 406eeeab4c..abf485aa20 100644 --- a/mods/d2k/rules/aircraft.yaml +++ b/mods/d2k/rules/aircraft.yaml @@ -96,6 +96,7 @@ frigate: ornithopter: Inherits: ^Plane AttackBomber: + FacingTolerance: 8 Armament: Weapon: OrniBomb Health: diff --git a/mods/ra/rules/aircraft.yaml b/mods/ra/rules/aircraft.yaml index 06b0315f25..d663b2b561 100644 --- a/mods/ra/rules/aircraft.yaml +++ b/mods/ra/rules/aircraft.yaml @@ -53,6 +53,7 @@ BADR.Bomber: RenderSprites: Image: badr AttackBomber: + FacingTolerance: 8 AmmoPool: Ammo: 10 Armament: @@ -439,6 +440,7 @@ U2: Repulsable: False MaximumPitch: 56 AttackBomber: + FacingTolerance: 8 -Selectable: -Voiced: -Targetable@AIRBORNE: