fix infantry anims

This commit is contained in:
Bob
2010-09-22 13:32:58 +12:00
parent 96f72ce842
commit 8e589e3c16
4 changed files with 27 additions and 16 deletions

View File

@@ -34,8 +34,11 @@ namespace OpenRA.Traits.Activities
Log.Write("debug", "drag #{0} {1} {2}", self.ActorID, ticks, self.CenterLocation);
if (++ticks >= length)
return NextActivity;
{
self.Trait<Mobile>().IsMoving = false;
return NextActivity;
}
self.Trait<Mobile>().IsMoving = true;
return this;
}

View File

@@ -294,19 +294,27 @@ namespace OpenRA.Traits.Activities
public IActivity Tick( Actor self )
{
var mobile = self.Trait<Mobile>();
moveFraction += (int)mobile.MovementSpeedForCell(self, mobile.toCell);
if( moveFraction >= moveFractionTotal )
var ret = InnerTick( self, mobile );
mobile.IsMoving = ( ret is MovePart );
if( moveFraction > moveFractionTotal )
moveFraction = moveFractionTotal;
UpdateCenterLocation( self, mobile );
if( moveFraction >= moveFractionTotal )
{
var next = OnComplete( self, mobile, move );
if( next != null )
return next;
UpdateCenterLocation( self, mobile );
return move;
}
return this;
return ret;
}
IActivity InnerTick( Actor self, Mobile mobile )
{
moveFraction += (int)mobile.MovementSpeedForCell(self, mobile.toCell);
if( moveFraction <= moveFractionTotal )
return this;
var next = OnComplete( self, mobile, move );
if( next != null )
return next;
return move;
}
void UpdateCenterLocation( Actor self, Mobile mobile )

View File

@@ -57,6 +57,7 @@ namespace OpenRA.Traits
{
public readonly Actor self;
public readonly MobileInfo Info;
public bool IsMoving { get; internal set; }
int __facing;
int2 __fromCell, __toCell;

View File

@@ -30,10 +30,9 @@ namespace OpenRA.Mods.RA.Render
bool ChooseMoveAnim(Actor self)
{
if (!(self.GetCurrentActivity() is Move) && !(self.GetCurrentActivity() is Drag)) // A bit of a hack
return false;
var mobile = self.Trait<Mobile>();
if( !mobile.IsMoving ) return false;
if (float2.WithinEpsilon(self.CenterLocation, Util.CenterOfCell(mobile.toCell), 2)) return false;
var seq = IsProne(self) ? "crawl" : "run";