Fix moonwalking infantry
This commit is contained in:
@@ -27,7 +27,8 @@ namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
Idle,
|
||||
Attacking,
|
||||
Moving
|
||||
Moving,
|
||||
Waiting
|
||||
};
|
||||
|
||||
public AnimationState State { get; private set; }
|
||||
@@ -52,11 +53,14 @@ namespace OpenRA.Mods.RA.Render
|
||||
{
|
||||
base.Tick(self);
|
||||
|
||||
if (State == AnimationState.Attacking || self.IsIdle || !mobile.IsMoving)
|
||||
return;
|
||||
|
||||
// Set move animation
|
||||
if (State != AnimationState.Moving)
|
||||
// If path is blocked, we can have !isMoving and !idle
|
||||
// Need to handle this case specially
|
||||
if (!mobile.IsMoving && State == AnimationState.Moving)
|
||||
{
|
||||
State = AnimationState.Waiting;
|
||||
anim.Play("stand");
|
||||
}
|
||||
else if (State != AnimationState.Moving && mobile.IsMoving)
|
||||
{
|
||||
State = AnimationState.Moving;
|
||||
anim.PlayRepeating("run");
|
||||
|
||||
@@ -45,11 +45,18 @@ namespace OpenRA.Mods.RA
|
||||
remainingProneTime--;
|
||||
|
||||
var ri = self.Trait<RenderInfantry>();
|
||||
if (ri.State == RenderInfantry.AnimationState.Idle)
|
||||
if (IsProne)
|
||||
ri.anim.PlayFetchIndex("crawl", () => 0);
|
||||
else
|
||||
ri.anim.Play("stand");
|
||||
|
||||
// Mobile.IsMoving isn't set to true until after the first move tick
|
||||
// so we need a hack here to prevent a single frame of stand state
|
||||
|
||||
if (IsProne && (ri.State == RenderInfantry.AnimationState.Idle ||
|
||||
ri.State == RenderInfantry.AnimationState.Waiting ||
|
||||
ri.anim.CurrentSequence.Name == "stand"))
|
||||
ri.anim.PlayFetchIndex("crawl", () => 0);
|
||||
else if (!IsProne && (ri.State == RenderInfantry.AnimationState.Idle ||
|
||||
ri.State == RenderInfantry.AnimationState.Waiting ||
|
||||
ri.anim.CurrentSequence.Name == "stand"))
|
||||
ri.anim.Play("stand");
|
||||
|
||||
if (ri.anim.CurrentSequence.Name == "run" && IsProne)
|
||||
ri.anim.ReplaceAnim("crawl");
|
||||
|
||||
Reference in New Issue
Block a user