Polishing Hovers
This commit is contained in:
committed by
reaperrr
parent
16f1750252
commit
6c9d961bb5
@@ -26,28 +26,65 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
|
|
||||||
public readonly int MinHoveringAltitude = 0;
|
public readonly int MinHoveringAltitude = 0;
|
||||||
|
|
||||||
|
[Desc("Amount of ticks it takes to reach OffsetModifier.")]
|
||||||
|
public readonly int Ticks = 25;
|
||||||
|
|
||||||
|
[Desc("Amount of ticks it takes to fall to the ground from the highest point when disabled.")]
|
||||||
|
public readonly int FallTicks = 12;
|
||||||
|
|
||||||
|
[Desc("Amount of ticks it takes to rise from the ground to InitialHeight.")]
|
||||||
|
public readonly int RiseTicks = 17;
|
||||||
|
|
||||||
|
public readonly int InitialHeight = 384;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new Hovers(this, init.Self); }
|
public override object Create(ActorInitializer init) { return new Hovers(this, init.Self); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Hovers : ConditionalTrait<HoversInfo>, IRenderModifier
|
public class Hovers : ConditionalTrait<HoversInfo>, IRenderModifier, ITick
|
||||||
{
|
{
|
||||||
readonly HoversInfo info;
|
readonly HoversInfo info;
|
||||||
|
readonly int stepPercentage;
|
||||||
|
readonly int fallTickHeight;
|
||||||
|
|
||||||
|
int ticks = 0;
|
||||||
|
WVec worldVisualOffset = WVec.Zero;
|
||||||
|
|
||||||
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;
|
||||||
|
this.fallTickHeight = (info.InitialHeight + info.OffsetModifier) / info.FallTicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ITick.Tick(Actor self)
|
||||||
|
{
|
||||||
|
if (IsTraitDisabled)
|
||||||
|
{
|
||||||
|
if (worldVisualOffset.Z < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var fallTicks = worldVisualOffset.Z / fallTickHeight - 1;
|
||||||
|
worldVisualOffset = new WVec(0, 0, fallTickHeight * fallTicks);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ticks++;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerable<IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
IEnumerable<IRenderable> IRenderModifier.ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||||
{
|
{
|
||||||
if (self.World.Paused || IsTraitDisabled)
|
if (!IsTraitDisabled)
|
||||||
return r;
|
{
|
||||||
|
var visualOffset = self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length >= info.MinHoveringAltitude
|
||||||
|
? new WAngle(ticks % (info.Ticks * 4) * stepPercentage).Sin() : 0;
|
||||||
|
var currentHeight = info.OffsetModifier * visualOffset / 1024 + info.InitialHeight;
|
||||||
|
|
||||||
var visualOffset = self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length >= info.MinHoveringAltitude
|
// This part rises the actor up from disabled state
|
||||||
? (int)Math.Abs((self.ActorID + Game.LocalTick) / 5 % 4 - 1) - 1
|
if (worldVisualOffset.Z < currentHeight)
|
||||||
: 0;
|
currentHeight = Math.Min(worldVisualOffset.Z + info.InitialHeight / info.RiseTicks, currentHeight);
|
||||||
var worldVisualOffset = new WVec(0, 0, info.OffsetModifier * visualOffset);
|
|
||||||
|
worldVisualOffset = new WVec(0, 0, currentHeight);
|
||||||
|
}
|
||||||
|
|
||||||
return r.Select(a => a.OffsetBy(worldVisualOffset));
|
return r.Select(a => a.OffsetBy(worldVisualOffset));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ HVR:
|
|||||||
Mobile:
|
Mobile:
|
||||||
Speed: 99
|
Speed: 99
|
||||||
Locomotor: hover
|
Locomotor: hover
|
||||||
|
Selectable:
|
||||||
|
Bounds: 40,24,0,-10
|
||||||
Health:
|
Health:
|
||||||
HP: 23000
|
HP: 23000
|
||||||
Armor:
|
Armor:
|
||||||
@@ -86,6 +88,8 @@ HVR:
|
|||||||
PauseOnCondition: empdisable
|
PauseOnCondition: empdisable
|
||||||
WithVoxelTurret:
|
WithVoxelTurret:
|
||||||
Hovers:
|
Hovers:
|
||||||
|
RequiresCondition: !empdisable
|
||||||
|
OffsetModifier: 64
|
||||||
LeavesTrails:
|
LeavesTrails:
|
||||||
RequiresCondition: !inside-tunnel
|
RequiresCondition: !inside-tunnel
|
||||||
Image: wake
|
Image: wake
|
||||||
|
|||||||
Reference in New Issue
Block a user