Rename Hovers' OffsetModifier to BobDistance

This commit is contained in:
reaperrr
2019-05-26 20:34:47 +02:00
committed by Paul Chote
parent 2f1f0c8aec
commit 3ff8fb3cd2
5 changed files with 47 additions and 8 deletions

View File

@@ -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.")]
@@ -43,8 +43,8 @@ namespace OpenRA.Mods.Common.Traits.Render
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 @@ namespace OpenRA.Mods.Common.Traits.Render
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 @@ namespace OpenRA.Mods.Common.Traits.Render
{
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)

View File

@@ -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;
}
}
}

View File

@@ -127,6 +127,7 @@ namespace OpenRA.Mods.Common.UpdateRules
new SplitHarvesterSpriteBody(),
new RenameAttackMoveConditions(),
new RemovePlaceBuildingPalettes(),
new RenameHoversOffsetModifier(),
})
};

View File

@@ -897,7 +897,7 @@
VTOL: true
Hovers@CRUISING:
RequiresCondition: cruising
OffsetModifier: -64
BobDistance: -64
InitialHeight: 64
^AircraftHusk:

View File

@@ -89,7 +89,7 @@ HVR:
WithVoxelTurret:
Hovers:
RequiresCondition: !empdisable
OffsetModifier: -64
BobDistance: -64
InitialHeight: 384
LeavesTrails:
RequiresCondition: !inside-tunnel