diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 0cddf7be71..c665da877a 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -960,6 +960,7 @@ + diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20190314/ReplaceSpecialMoveConsiderations.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20190314/ReplaceSpecialMoveConsiderations.cs new file mode 100644 index 0000000000..34ea2d93ef --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20190314/ReplaceSpecialMoveConsiderations.cs @@ -0,0 +1,78 @@ +#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; +using System.Linq; + +namespace OpenRA.Mods.Common.UpdateRules.Rules +{ + public class ReplaceSpecialMoveConsiderations : UpdateRule + { + public override string Name { get { return "Replaced special-case movement type considerations"; } } + public override string Description + { + get + { + return "Removed AlwaysConsiderTurnAsMove from Mobile and ConsiderVerticalMovement\n" + + "from GrantConditionOnMovement. Add 'Turn' and/or 'Vertical' on new ValidMovementTypes\n" + + "fields on WithMoveAnimation and GrantConditionOnMovement instead."; + } + } + + readonly Dictionary> locations = new Dictionary>(); + + public override IEnumerable AfterUpdate(ModData modData) + { + if (locations.Any()) + yield return "The following definitions implement WithMoveAnimation\n" + + "or GrantConditionOnMovement. Check if they need updated ValidMovementTypes:\n" + + UpdateUtils.FormatMessageList(locations.Select( + kv => kv.Key + ":\n" + UpdateUtils.FormatMessageList(kv.Value))); + + locations.Clear(); + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + var mobileNode = actorNode.ChildrenMatching("Mobile").FirstOrDefault(m => !m.IsRemoval()); + if (mobileNode != null) + { + var considerTurnAsMoveNode = mobileNode.LastChildMatching("AlwaysConsiderTurnAsMove"); + if (considerTurnAsMoveNode != null) + mobileNode.RemoveNode(considerTurnAsMoveNode); + } + + var used = new List(); + var grantMoveConditions = actorNode.ChildrenMatching("GrantConditionOnMovement"); + foreach (var g in grantMoveConditions) + { + var considerVerticalNode = g.LastChildMatching("ConsiderVerticalMovement"); + if (considerVerticalNode != null) + g.RemoveNode(considerVerticalNode); + } + + if (grantMoveConditions.Any()) + used.Add("GrantConditionOnMovement"); + + var moveAnim = actorNode.LastChildMatching("WithMoveAnimation"); + if (moveAnim != null) + used.Add("WithMoveAnimation"); + + if (used.Any()) + { + var location = "{0} ({1})".F(actorNode.Key, actorNode.Location.Filename); + locations[location] = used; + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index a07adb14d6..4810f699ef 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -122,6 +122,7 @@ namespace OpenRA.Mods.Common.UpdateRules new RemoveSimpleBeacon(), new MakeMobilePausableConditional(), new StreamlineRepairableTraits(), + new ReplaceSpecialMoveConsiderations(), }) }; diff --git a/mods/ts/rules/gdi-vehicles.yaml b/mods/ts/rules/gdi-vehicles.yaml index 5533a48737..f2e8c20b52 100644 --- a/mods/ts/rules/gdi-vehicles.yaml +++ b/mods/ts/rules/gdi-vehicles.yaml @@ -119,7 +119,6 @@ SMECH: Mobile: TurnSpeed: 5 Speed: 99 - AlwaysConsiderTurnAsMove: true Health: HP: 17500 Armor: @@ -143,6 +142,7 @@ SMECH: Sequence: shoot WithMoveAnimation: MoveSequence: walk + ValidMovementTypes: Horizontal, Turn Selectable: Bounds: 20, 32, 0, -8 -DamagedByTerrain@VEINS: @@ -166,7 +166,6 @@ MMCH: Mobile: TurnSpeed: 5 Speed: 56 - AlwaysConsiderTurnAsMove: true Health: HP: 40000 Armor: @@ -182,6 +181,7 @@ MMCH: Sequence: stand WithMoveAnimation: MoveSequence: walk + ValidMovementTypes: Horizontal, Turn Turreted: TurnSpeed: 5 AttackTurreted: @@ -229,7 +229,6 @@ HMEC: Mobile: TurnSpeed: 3 Speed: 42 - AlwaysConsiderTurnAsMove: true Health: HP: 80000 SelfHealing: @@ -332,7 +331,6 @@ JUGG: TurnSpeed: 5 RequiresCondition: undeployed PauseOnCondition: empdisable || being-captured - AlwaysConsiderTurnAsMove: true RevealsShroud: RequiresCondition: !inside-tunnel Range: 9c0 @@ -348,6 +346,7 @@ JUGG: RequiresCondition: undeployed WithMoveAnimation: MoveSequence: walk + ValidMovementTypes: Horizontal, Turn GrantConditionOnDeploy: DeployedCondition: deployed UndeployedCondition: undeployed