diff --git a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs index b6888a7701..b31140d54a 100644 --- a/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs +++ b/OpenRA.Mods.Common/Activities/Air/ReturnToBase.cs @@ -113,10 +113,8 @@ namespace OpenRA.Mods.Common.Activities { var exit = dest.FirstExitOrDefault(null); var offset = exit != null ? exit.Info.SpawnOffset : WVec.Zero; - if (aircraft.Info.TurnToDock) + if (aircraft.Info.TurnToDock || !aircraft.Info.VTOL) facing = aircraft.Info.InitialFacing; - if (!aircraft.Info.VTOL) - facing = 192; aircraft.MakeReservation(dest); QueueChild(new Land(self, Target.FromActor(dest), offset, facing, Color.Green)); diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/RemoveInitialFacingHardcoding.cs b/OpenRA.Mods.Common/UpdateRules/Rules/RemoveInitialFacingHardcoding.cs new file mode 100644 index 0000000000..11cf8a0051 --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/RemoveInitialFacingHardcoding.cs @@ -0,0 +1,65 @@ +#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 RemoveInitialFacingHardcoding : UpdateRule + { + public override string Name { get { return "Removed InitialFacing hardcoding for non-VTOLs"; } } + public override string Description + { + get + { + return "Removed hardcoding of InitialFacing to 192 for aircraft with VTOL: false."; + } + } + + readonly List> nonVTOLs = new List>(); + + public override IEnumerable AfterUpdate(ModData modData) + { + var message = "InitialFacing is no longer hardcoded to 192 for aircraft with VTOL: false.\n" + + "You may have to set it manually now in the following places:\n" + + UpdateUtils.FormatMessageList(nonVTOLs.Select(n => n.Item1 + " (" + n.Item2 + ")")); + + if (nonVTOLs.Any()) + yield return message; + + nonVTOLs.Clear(); + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + var aircraft = actorNode.LastChildMatching("Aircraft"); + if (aircraft != null) + { + var initialFacing = aircraft.LastChildMatching("InitialFacing"); + + var isVTOL = false; + var vtolNode = aircraft.LastChildMatching("VTOL"); + if (vtolNode != null) + isVTOL = vtolNode.NodeValue(); + + // If InitialFacing is defined or it's a VTOL, no changes are needed. + if (initialFacing != null || isVTOL) + yield break; + + nonVTOLs.Add(Tuple.Create(actorNode.Key, actorNode.Location.Filename)); + } + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index d436aa2ec7..416a124fbd 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -142,6 +142,7 @@ namespace OpenRA.Mods.Common.UpdateRules { // Bleed only changes here new RemoveYesNo(), + new RemoveInitialFacingHardcoding(), }) };