From 8cda9d6d8b7a8f61752a4e596aaf353f79ac8db1 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Thu, 27 Jan 2011 18:36:25 +1300 Subject: [PATCH] restore previous sequence after IdleAnimation; apply randomness to idle animation wait --- OpenRA.Mods.RA/IdleAnimation.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.RA/IdleAnimation.cs b/OpenRA.Mods.RA/IdleAnimation.cs index 3e417aa7a0..c42ba51fc9 100644 --- a/OpenRA.Mods.RA/IdleAnimation.cs +++ b/OpenRA.Mods.RA/IdleAnimation.cs @@ -15,7 +15,8 @@ namespace OpenRA.Mods.RA { class IdleAnimationInfo : ITraitInfo, ITraitPrerequisite { - public readonly int IdleWaitTicks = 50; + public readonly int MinIdleWaitTicks = 30; + public readonly int MaxIdleWaitTicks = 110; public readonly string[] Animations = {}; public object Create(ActorInitializer init) { return new IdleAnimation(this); } } @@ -56,7 +57,15 @@ namespace OpenRA.Mods.RA var ri = self.TraitOrDefault(); if (ri.anim.HasSequence(sequence)) - ri.anim.PlayThen(sequence, () => state = IdleState.None); + { + var previousSequence = ri.anim.CurrentSequence.Name; + ri.anim.PlayThen(sequence, + () => + { + state = IdleState.None; + ri.anim.PlayRepeating(previousSequence); + }); + } else state = IdleState.None; } @@ -68,8 +77,8 @@ namespace OpenRA.Mods.RA return; state = IdleState.Waiting; - sequence = Info.Animations.Random(self.World.SharedRandom); - delay = Info.IdleWaitTicks; + sequence = Info.Animations.Random(self.World.SharedRandom); + delay = self.World.SharedRandom.Next(Info.MinIdleWaitTicks, Info.MaxIdleWaitTicks); } } }