restore previous sequence after IdleAnimation; apply randomness to idle animation wait
This commit is contained in:
@@ -15,7 +15,8 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
class IdleAnimationInfo : ITraitInfo, ITraitPrerequisite<RenderInfantryInfo>
|
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 readonly string[] Animations = {};
|
||||||
public object Create(ActorInitializer init) { return new IdleAnimation(this); }
|
public object Create(ActorInitializer init) { return new IdleAnimation(this); }
|
||||||
}
|
}
|
||||||
@@ -56,7 +57,15 @@ namespace OpenRA.Mods.RA
|
|||||||
var ri = self.TraitOrDefault<RenderInfantry>();
|
var ri = self.TraitOrDefault<RenderInfantry>();
|
||||||
|
|
||||||
if (ri.anim.HasSequence(sequence))
|
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
|
else
|
||||||
state = IdleState.None;
|
state = IdleState.None;
|
||||||
}
|
}
|
||||||
@@ -69,7 +78,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
state = IdleState.Waiting;
|
state = IdleState.Waiting;
|
||||||
sequence = Info.Animations.Random(self.World.SharedRandom);
|
sequence = Info.Animations.Random(self.World.SharedRandom);
|
||||||
delay = Info.IdleWaitTicks;
|
delay = self.World.SharedRandom.Next(Info.MinIdleWaitTicks, Info.MaxIdleWaitTicks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user