restore previous sequence after IdleAnimation; apply randomness to idle animation wait

This commit is contained in:
Chris Forbes
2011-01-27 18:36:25 +13:00
parent 0bd466a9e9
commit 8cda9d6d8b

View File

@@ -15,7 +15,8 @@ namespace OpenRA.Mods.RA
{
class IdleAnimationInfo : ITraitInfo, ITraitPrerequisite<RenderInfantryInfo>
{
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<RenderInfantry>();
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);
}
}
}