fix interaction between autoattack and idleanimation

This commit is contained in:
Bob
2010-11-16 10:45:36 +13:00
committed by Chris Forbes
parent 7bd7f4e56b
commit a7f42dcf0c
6 changed files with 10 additions and 11 deletions

View File

@@ -68,12 +68,11 @@ namespace OpenRA
public void Tick() public void Tick()
{ {
var wasIdle = currentActivity is Idle; if (currentActivity == null)
currentActivity = Util.RunActivity( this, currentActivity ) ?? new Idle();
if (currentActivity is Idle && !wasIdle)
foreach (var ni in TraitsImplementing<INotifyIdle>()) foreach (var ni in TraitsImplementing<INotifyIdle>())
ni.Idle(this); ni.TickIdle(this);
currentActivity = Util.RunActivity( this, currentActivity );
} }
public bool IsIdle public bool IsIdle

View File

@@ -203,7 +203,7 @@ namespace OpenRA.Traits
} }
public interface IRenderOverlay { void Render( WorldRenderer wr ); } public interface IRenderOverlay { void Render( WorldRenderer wr ); }
public interface INotifyIdle { void Idle(Actor self); } public interface INotifyIdle { void TickIdle(Actor self); }
public interface IBlocksBullets { } public interface IBlocksBullets { }

View File

@@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Air
class ReturnOnIdle : INotifyIdle class ReturnOnIdle : INotifyIdle
{ {
public void Idle(Actor self) public void TickIdle(Actor self)
{ {
var altitude = self.Trait<Aircraft>().Altitude; var altitude = self.Trait<Aircraft>().Altitude;
if (altitude == 0) return; // we're on the ground, let's stay there. if (altitude == 0) return; // we're on the ground, let's stay there.
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Air
class FlyAwayOnIdle : INotifyIdle class FlyAwayOnIdle : INotifyIdle
{ {
public void Idle(Actor self) public void TickIdle(Actor self)
{ {
self.QueueActivity(new FlyOffMap()); self.QueueActivity(new FlyOffMap());
self.QueueActivity(new RemoveSelf()); self.QueueActivity(new RemoveSelf());

View File

@@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA
class AutoHeal : INotifyIdle class AutoHeal : INotifyIdle
{ {
public void Idle( Actor self ) public void TickIdle( Actor self )
{ {
self.QueueActivity( new IdleHealActivity() ); self.QueueActivity( new IdleHealActivity() );
} }

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA
self.Trait<AttackBase>().AttackTarget(Target.FromActor(e.Attacker), false, self.Info.Traits.Get<AutoTargetInfo>().AllowMovement); self.Trait<AttackBase>().AttackTarget(Target.FromActor(e.Attacker), false, self.Info.Traits.Get<AutoTargetInfo>().AllowMovement);
} }
public void Idle( Actor self ) public void TickIdle( Actor self )
{ {
self.QueueActivity( new IdleAttackActivity() ); self.QueueActivity( new IdleAttackActivity() );
} }

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA
self.CancelActivity(); self.CancelActivity();
} }
public void Idle(Actor self) public void TickIdle(Actor self)
{ {
self.QueueActivity(new Activities.IdleAnimation(Info.Animations.Random(self.World.SharedRandom), self.QueueActivity(new Activities.IdleAnimation(Info.Animations.Random(self.World.SharedRandom),
Info.IdleWaitTicks)); Info.IdleWaitTicks));