From a7f42dcf0ce7963ef5b8d13ff00c14c6f07d9b43 Mon Sep 17 00:00:00 2001 From: Bob Date: Tue, 16 Nov 2010 10:45:36 +1300 Subject: [PATCH] fix interaction between autoattack and idleanimation --- OpenRA.Game/Actor.cs | 9 ++++----- OpenRA.Game/Traits/TraitsInterfaces.cs | 2 +- OpenRA.Mods.RA/Air/ReturnOnIdle.cs | 4 ++-- OpenRA.Mods.RA/AutoHeal.cs | 2 +- OpenRA.Mods.RA/AutoTarget.cs | 2 +- OpenRA.Mods.RA/IdleAnimation.cs | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 7b03e27de2..8efaaa4fc0 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -68,12 +68,11 @@ namespace OpenRA public void Tick() { - var wasIdle = currentActivity is Idle; - currentActivity = Util.RunActivity( this, currentActivity ) ?? new Idle(); - - if (currentActivity is Idle && !wasIdle) + if (currentActivity == null) foreach (var ni in TraitsImplementing()) - ni.Idle(this); + ni.TickIdle(this); + + currentActivity = Util.RunActivity( this, currentActivity ); } public bool IsIdle diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 2993c37135..742fb3454e 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -203,7 +203,7 @@ namespace OpenRA.Traits } public interface IRenderOverlay { void Render( WorldRenderer wr ); } - public interface INotifyIdle { void Idle(Actor self); } + public interface INotifyIdle { void TickIdle(Actor self); } public interface IBlocksBullets { } diff --git a/OpenRA.Mods.RA/Air/ReturnOnIdle.cs b/OpenRA.Mods.RA/Air/ReturnOnIdle.cs index 39faa67d8d..79230c43e2 100755 --- a/OpenRA.Mods.RA/Air/ReturnOnIdle.cs +++ b/OpenRA.Mods.RA/Air/ReturnOnIdle.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA.Air class ReturnOnIdle : INotifyIdle { - public void Idle(Actor self) + public void TickIdle(Actor self) { var altitude = self.Trait().Altitude; 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 { - public void Idle(Actor self) + public void TickIdle(Actor self) { self.QueueActivity(new FlyOffMap()); self.QueueActivity(new RemoveSelf()); diff --git a/OpenRA.Mods.RA/AutoHeal.cs b/OpenRA.Mods.RA/AutoHeal.cs index e63736aecc..68c14ba0bd 100644 --- a/OpenRA.Mods.RA/AutoHeal.cs +++ b/OpenRA.Mods.RA/AutoHeal.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA class AutoHeal : INotifyIdle { - public void Idle( Actor self ) + public void TickIdle( Actor self ) { self.QueueActivity( new IdleHealActivity() ); } diff --git a/OpenRA.Mods.RA/AutoTarget.cs b/OpenRA.Mods.RA/AutoTarget.cs index 5d386ba490..86a59a71b5 100644 --- a/OpenRA.Mods.RA/AutoTarget.cs +++ b/OpenRA.Mods.RA/AutoTarget.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA self.Trait().AttackTarget(Target.FromActor(e.Attacker), false, self.Info.Traits.Get().AllowMovement); } - public void Idle( Actor self ) + public void TickIdle( Actor self ) { self.QueueActivity( new IdleAttackActivity() ); } diff --git a/OpenRA.Mods.RA/IdleAnimation.cs b/OpenRA.Mods.RA/IdleAnimation.cs index 1d6f3fbd1e..0909d1297a 100644 --- a/OpenRA.Mods.RA/IdleAnimation.cs +++ b/OpenRA.Mods.RA/IdleAnimation.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA self.CancelActivity(); } - public void Idle(Actor self) + public void TickIdle(Actor self) { self.QueueActivity(new Activities.IdleAnimation(Info.Animations.Random(self.World.SharedRandom), Info.IdleWaitTicks));