Skip to content

Commit

Permalink
Rename Hovers' OffsetModifier to BobDistance
Browse files Browse the repository at this point in the history
  • Loading branch information
reaperrr committed Jun 1, 2019
1 parent 5ba58c3 commit 2ea2d76
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 8 deletions.
12 changes: 6 additions & 6 deletions OpenRA.Mods.Common/Traits/Render/Hovers.cs
Expand Up @@ -22,12 +22,12 @@ namespace OpenRA.Mods.Common.Traits.Render
public class HoversInfo : ConditionalTraitInfo, Requires<IMoveInfo>
{
[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.")]
Expand All @@ -43,8 +43,8 @@ public class HoversInfo : ConditionalTraitInfo, Requires<IMoveInfo>

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.");
Expand Down Expand Up @@ -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)
Expand All @@ -101,7 +101,7 @@ IEnumerable<IRenderable> 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)
Expand Down
@@ -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<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var h in actorNode.ChildrenMatching("Hovers"))
foreach (var node in h.ChildrenMatching("OffsetModifier"))
node.RenameKey("BobDistance");

yield break;
}
}
}
1 change: 1 addition & 0 deletions OpenRA.Mods.Common/UpdateRules/UpdatePath.cs
Expand Up @@ -127,6 +127,7 @@ public class UpdatePath
new SplitHarvesterSpriteBody(),
new RenameAttackMoveConditions(),
new RemovePlaceBuildingPalettes(),
new RenameHoversOffsetModifier(),
})
};

Expand Down
2 changes: 1 addition & 1 deletion mods/ts/rules/defaults.yaml
Expand Up @@ -897,7 +897,7 @@
VTOL: true
Hovers@CRUISING:
RequiresCondition: cruising
OffsetModifier: -64
BobDistance: -64
InitialHeight: 64

^AircraftHusk:
Expand Down
2 changes: 1 addition & 1 deletion mods/ts/rules/gdi-vehicles.yaml
Expand Up @@ -89,7 +89,7 @@ HVR:
WithVoxelTurret:
Hovers:
RequiresCondition: !empdisable
OffsetModifier: -64
BobDistance: -64
InitialHeight: 384
LeavesTrails:
RequiresCondition: !inside-tunnel
Expand Down

0 comments on commit 2ea2d76

Please sign in to comment.