diff --git a/OpenRA.Mods.Common/Traits/Render/Hovers.cs b/OpenRA.Mods.Common/Traits/Render/Hovers.cs index ae2f0239b5cf..8960d4951c92 100644 --- a/OpenRA.Mods.Common/Traits/Render/Hovers.cs +++ b/OpenRA.Mods.Common/Traits/Render/Hovers.cs @@ -22,12 +22,12 @@ namespace OpenRA.Mods.Common.Traits.Render public class HoversInfo : ConditionalTraitInfo, Requires { [Desc("Maximum visual Z axis distance relative to actual position + InitialHeight.")] - public readonly WDist OffsetModifier = new WDist(-43); + public readonly WDist BobDistance = new WDist(-43); [Desc("Actual altitude of actor needs to be this or higher to enable hover effect.")] public readonly WDist MinHoveringAltitude = WDist.Zero; - [Desc("Amount of ticks it takes to reach OffsetModifier.")] + [Desc("Amount of ticks it takes to reach BobDistance.")] public readonly int Ticks = 6; [Desc("Amount of ticks it takes to fall to the ground from the highest point when disabled.")] @@ -43,8 +43,8 @@ public class HoversInfo : ConditionalTraitInfo, Requires public override void RulesetLoaded(Ruleset rules, ActorInfo ai) { - if (OffsetModifier.Length > -1) - throw new YamlException("Hovers.OffsetModifier must be a negative value."); + if (BobDistance.Length > -1) + throw new YamlException("Hovers.BobDistance must be a negative value."); if (Ticks < 1) throw new YamlException("Hovers.Ticks must be higher than zero."); @@ -78,7 +78,7 @@ public Hovers(HoversInfo info, Actor self) stepPercentage = 256 / info.Ticks; // fallTickHeight must be at least 1 to avoid a DivideByZeroException and other potential problems when trait is disabled. - fallTickHeight = (info.InitialHeight.Length + info.OffsetModifier.Length).Clamp(info.FallTicks, int.MaxValue) / info.FallTicks; + fallTickHeight = (info.InitialHeight.Length + info.BobDistance.Length).Clamp(info.FallTicks, int.MaxValue) / info.FallTicks; } void ITick.Tick(Actor self) @@ -101,7 +101,7 @@ IEnumerable IRenderModifier.ModifyRender(Actor self, WorldRenderer { var visualOffset = self.World.Map.DistanceAboveTerrain(self.CenterPosition) >= info.MinHoveringAltitude ? new WAngle(ticks % (info.Ticks * 4) * stepPercentage).Sin() : 0; - var currentHeight = info.OffsetModifier.Length * visualOffset / 1024 + info.InitialHeight.Length; + var currentHeight = info.BobDistance.Length * visualOffset / 1024 + info.InitialHeight.Length; // This part rises the actor up from disabled state if (worldVisualOffset.Z < currentHeight) diff --git a/OpenRA.Mods.Common/UpdateRules/Rules/20190314/RenameHoversOffsetModifier.cs b/OpenRA.Mods.Common/UpdateRules/Rules/20190314/RenameHoversOffsetModifier.cs new file mode 100644 index 000000000000..b581a57763ed --- /dev/null +++ b/OpenRA.Mods.Common/UpdateRules/Rules/20190314/RenameHoversOffsetModifier.cs @@ -0,0 +1,38 @@ +#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 RenameHoversOffsetModifier : UpdateRule + { + public override string Name { get { return "Rename Hovers OffsetModifier"; } } + public override string Description + { + get + { + return "Hovers' OffsetModifier was renamed to BobDistance,\n" + + "as 'Modifier' is a term we don't normally use for distance,\n" + + "while 'Offset' would imply a 3D vector, which isn't the case here."; + } + } + + public override IEnumerable UpdateActorNode(ModData modData, MiniYamlNode actorNode) + { + foreach (var h in actorNode.ChildrenMatching("Hovers")) + foreach (var node in h.ChildrenMatching("OffsetModifier")) + node.RenameKey("BobDistance"); + + yield break; + } + } +} diff --git a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs index d503788d0e2a..cb4376f3ebab 100644 --- a/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs +++ b/OpenRA.Mods.Common/UpdateRules/UpdatePath.cs @@ -127,6 +127,7 @@ public class UpdatePath new SplitHarvesterSpriteBody(), new RenameAttackMoveConditions(), new RemovePlaceBuildingPalettes(), + new RenameHoversOffsetModifier(), }) }; diff --git a/mods/ts/rules/defaults.yaml b/mods/ts/rules/defaults.yaml index 93de4cc54532..2db43061249b 100644 --- a/mods/ts/rules/defaults.yaml +++ b/mods/ts/rules/defaults.yaml @@ -897,7 +897,7 @@ VTOL: true Hovers@CRUISING: RequiresCondition: cruising - OffsetModifier: -64 + BobDistance: -64 InitialHeight: 64 ^AircraftHusk: diff --git a/mods/ts/rules/gdi-vehicles.yaml b/mods/ts/rules/gdi-vehicles.yaml index f86bc68e62ad..7ae2c705aba3 100644 --- a/mods/ts/rules/gdi-vehicles.yaml +++ b/mods/ts/rules/gdi-vehicles.yaml @@ -89,7 +89,7 @@ HVR: WithVoxelTurret: Hovers: RequiresCondition: !empdisable - OffsetModifier: -64 + BobDistance: -64 InitialHeight: 384 LeavesTrails: RequiresCondition: !inside-tunnel