Fix orca’s flying sequences.
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
<Compile Include="Traits\SupportPowers\IonCannonPower.cs" />
|
||||
<Compile Include="Widgets\Logic\CncMainMenuLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\ProductionTabsLogic.cs" />
|
||||
<Compile Include="Traits\RenderUnitFlying.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
|
||||
|
||||
54
OpenRA.Mods.Cnc/Traits/RenderUnitFlying.cs
Normal file
54
OpenRA.Mods.Cnc/Traits/RenderUnitFlying.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 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. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Cnc.Traits
|
||||
{
|
||||
class RenderUnitFlyingInfo : RenderUnitInfo, Requires<IMoveInfo>
|
||||
{
|
||||
public readonly string MoveSequence = "move";
|
||||
|
||||
public override object Create(ActorInitializer init) { return new RenderUnitFlying(init, this); }
|
||||
}
|
||||
|
||||
class RenderUnitFlying : RenderUnit, ITick
|
||||
{
|
||||
readonly RenderUnitFlyingInfo info;
|
||||
readonly IMove movement;
|
||||
|
||||
WPos cachedPosition;
|
||||
|
||||
public RenderUnitFlying(ActorInitializer init, RenderUnitFlyingInfo info)
|
||||
: base(init, info)
|
||||
{
|
||||
this.info = info;
|
||||
movement = init.Self.Trait<IMove>();
|
||||
|
||||
cachedPosition = init.Self.CenterPosition;
|
||||
}
|
||||
|
||||
public override void Tick(Actor self)
|
||||
{
|
||||
base.Tick(self);
|
||||
|
||||
var oldCachedPosition = cachedPosition;
|
||||
cachedPosition = self.CenterPosition;
|
||||
|
||||
// Flying units set IsMoving whenever they are airborne, which isn't enough for our purposes
|
||||
var isMoving = movement.IsMoving && !self.IsDead && (oldCachedPosition - cachedPosition).HorizontalLengthSquared != 0;
|
||||
if (isMoving ^ (DefaultAnimation.CurrentSequence.Name != info.MoveSequence))
|
||||
return;
|
||||
|
||||
DefaultAnimation.ReplaceAnim(isMoving ? info.MoveSequence : info.Sequence);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,7 +130,7 @@ ORCA:
|
||||
SelfReloads: true
|
||||
ReloadCount: 2
|
||||
SelfReloadTicks: 100
|
||||
RenderUnit:
|
||||
RenderUnitFlying:
|
||||
LeavesHusk:
|
||||
HuskActor: ORCA.Husk
|
||||
AutoTarget:
|
||||
|
||||
@@ -41,7 +41,7 @@ heli:
|
||||
orca:
|
||||
idle:
|
||||
Facings: 32
|
||||
damaged-idle:
|
||||
move:
|
||||
Start: 32
|
||||
Facings: 32
|
||||
icon: orcaicnh.tem
|
||||
|
||||
Reference in New Issue
Block a user