Fix orca’s flying sequences.

This commit is contained in:
Paul Chote
2015-04-19 15:51:43 +12:00
parent 76ff0eddb9
commit 722f4725d5
4 changed files with 57 additions and 2 deletions

View File

@@ -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">

View 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);
}
}
}

View File

@@ -130,7 +130,7 @@ ORCA:
SelfReloads: true
ReloadCount: 2
SelfReloadTicks: 100
RenderUnit:
RenderUnitFlying:
LeavesHusk:
HuskActor: ORCA.Husk
AutoTarget:

View File

@@ -41,7 +41,7 @@ heli:
orca:
idle:
Facings: 32
damaged-idle:
move:
Start: 32
Facings: 32
icon: orcaicnh.tem