Polish various aspects of Hovers
- Use WDist instead of int for fields - Change default values to approximately restore previous releases' default behavior - Improve and clarify descriptions
This commit is contained in:
@@ -21,21 +21,23 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
[Desc("Changes the visual Z position periodically.")]
|
[Desc("Changes the visual Z position periodically.")]
|
||||||
public class HoversInfo : ConditionalTraitInfo, Requires<IMoveInfo>
|
public class HoversInfo : ConditionalTraitInfo, Requires<IMoveInfo>
|
||||||
{
|
{
|
||||||
[Desc("Amount of Z axis changes in world units.")]
|
[Desc("Maximum visual Z axis distance relative to actual position + InitialHeight.")]
|
||||||
public readonly int OffsetModifier = -43;
|
public readonly WDist OffsetModifier = new WDist(-43);
|
||||||
|
|
||||||
public readonly int MinHoveringAltitude = 0;
|
[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 OffsetModifier.")]
|
||||||
public readonly int Ticks = 25;
|
public readonly int Ticks = 6;
|
||||||
|
|
||||||
[Desc("Amount of ticks it takes to fall to the ground from the highest point when disabled.")]
|
[Desc("Amount of ticks it takes to fall to the ground from the highest point when disabled.")]
|
||||||
public readonly int FallTicks = 12;
|
public readonly int FallTicks = 10;
|
||||||
|
|
||||||
[Desc("Amount of ticks it takes to rise from the ground to InitialHeight.")]
|
[Desc("Amount of ticks it takes to rise from the ground to InitialHeight.")]
|
||||||
public readonly int RiseTicks = 17;
|
public readonly int RiseTicks = 20;
|
||||||
|
|
||||||
public readonly int InitialHeight = 384;
|
[Desc("Initial Z axis modifier relative to actual position.")]
|
||||||
|
public readonly WDist InitialHeight = new WDist(43);
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Hovers(this, init.Self); }
|
public override object Create(ActorInitializer init) { return new Hovers(this, init.Self); }
|
||||||
}
|
}
|
||||||
@@ -46,15 +48,15 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
readonly int stepPercentage;
|
readonly int stepPercentage;
|
||||||
readonly int fallTickHeight;
|
readonly int fallTickHeight;
|
||||||
|
|
||||||
int ticks = 0;
|
int ticks;
|
||||||
WVec worldVisualOffset = WVec.Zero;
|
WVec worldVisualOffset;
|
||||||
|
|
||||||
public Hovers(HoversInfo info, Actor self)
|
public Hovers(HoversInfo info, Actor self)
|
||||||
: base(info)
|
: base(info)
|
||||||
{
|
{
|
||||||
this.info = info;
|
this.info = info;
|
||||||
this.stepPercentage = 256 / info.Ticks;
|
stepPercentage = 256 / info.Ticks;
|
||||||
this.fallTickHeight = (info.InitialHeight + info.OffsetModifier) / info.FallTicks;
|
fallTickHeight = (info.InitialHeight + info.OffsetModifier).Length / info.FallTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
@@ -75,13 +77,13 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
{
|
{
|
||||||
if (!IsTraitDisabled)
|
if (!IsTraitDisabled)
|
||||||
{
|
{
|
||||||
var visualOffset = self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length >= info.MinHoveringAltitude
|
var visualOffset = self.World.Map.DistanceAboveTerrain(self.CenterPosition) >= info.MinHoveringAltitude
|
||||||
? new WAngle(ticks % (info.Ticks * 4) * stepPercentage).Sin() : 0;
|
? new WAngle(ticks % (info.Ticks * 4) * stepPercentage).Sin() : 0;
|
||||||
var currentHeight = info.OffsetModifier * visualOffset / 1024 + info.InitialHeight;
|
var currentHeight = info.OffsetModifier.Length * visualOffset / 1024 + info.InitialHeight.Length;
|
||||||
|
|
||||||
// This part rises the actor up from disabled state
|
// This part rises the actor up from disabled state
|
||||||
if (worldVisualOffset.Z < currentHeight)
|
if (worldVisualOffset.Z < currentHeight)
|
||||||
currentHeight = Math.Min(worldVisualOffset.Z + info.InitialHeight / info.RiseTicks, currentHeight);
|
currentHeight = Math.Min(worldVisualOffset.Z + info.InitialHeight.Length / info.RiseTicks, currentHeight);
|
||||||
|
|
||||||
worldVisualOffset = new WVec(0, 0, currentHeight);
|
worldVisualOffset = new WVec(0, 0, currentHeight);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user