From 6581fcb6a78a1c28dd6120f44984f951a1d2775c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Wed, 24 Jun 2020 21:34:26 +0200 Subject: [PATCH] Add a random interval to idle animations. --- OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs index dc12192619..a68913145c 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithIdleAnimation.cs @@ -21,7 +21,8 @@ namespace OpenRA.Mods.Common.Traits.Render [Desc("Sequence names to use.")] public readonly string[] Sequences = { "active" }; - public readonly int Interval = 750; + [Desc("The amount of time (in ticks) between animations. Two values indicate a range between which a random value is chosen.")] + public readonly int[] Interval = { 750 }; [Desc("Which sprite body to play the animation on.")] public readonly string Body = "body"; @@ -38,7 +39,7 @@ namespace OpenRA.Mods.Common.Traits.Render : base(info) { wsb = self.TraitsImplementing().Single(w => w.Info.Name == Info.Body); - ticks = info.Interval; + ticks = Util.RandomDelay(self.World, info.Interval); } void ITick.Tick(Actor self) @@ -49,7 +50,7 @@ namespace OpenRA.Mods.Common.Traits.Render if (--ticks <= 0) { wsb.PlayCustomAnimation(self, Info.Sequences.Random(Game.CosmeticRandom)); - ticks = Info.Interval; + ticks = Util.RandomDelay(self.World, Info.Interval); } }