fix crash when disguising the spy as infantry without stand2

This commit is contained in:
Matthias Mailänder
2015-07-06 10:00:03 +02:00
parent 4acb096416
commit 41b488779a
3 changed files with 22 additions and 6 deletions

View File

@@ -70,12 +70,19 @@ namespace OpenRA.Mods.Common.Traits
DefaultAnimation = new Animation(init.World, rs.GetImage(self), RenderSprites.MakeFacingFunc(self));
rs.Add(new AnimationWithOffset(DefaultAnimation, null, () => IsTraitDisabled));
PlayStandAnimation(self);
DefaultAnimation.PlayFetchIndex(NormalizeInfantrySequence(init.Self, info.StandSequences.Random(Game.CosmeticRandom)), () => 0);
state = AnimationState.Waiting;
move = init.Self.Trait<IMove>();
}
public void PlayStandAnimation(Actor self)
{
var sequence = DefaultAnimation.GetRandomExistingSequence(Info.StandSequences, Game.CosmeticRandom);
if (sequence != null)
DefaultAnimation.PlayFetchIndex(NormalizeInfantrySequence(self, sequence), () => 0);
}
public void Created(Actor self)
{
rsm = self.TraitOrDefault<IRenderInfantrySequenceModifier>();
@@ -123,7 +130,7 @@ namespace OpenRA.Mods.Common.Traits
if ((state == AnimationState.Moving || dirty) && !move.IsMoving)
{
state = AnimationState.Waiting;
DefaultAnimation.PlayFetchIndex(NormalizeInfantrySequence(self, Info.StandSequences.Random(Game.CosmeticRandom)), () => 0);
PlayStandAnimation(self);
}
else if ((state != AnimationState.Moving || dirty) && move.IsMoving)
{
@@ -138,7 +145,7 @@ namespace OpenRA.Mods.Common.Traits
{
if (state != AnimationState.Idle && state != AnimationState.IdleAnimating && state != AnimationState.Attacking)
{
DefaultAnimation.PlayFetchIndex(NormalizeInfantrySequence(self, Info.StandSequences.Random(Game.CosmeticRandom)), () => 0);
PlayStandAnimation(self);
state = AnimationState.Idle;
if (Info.IdleSequences.Length > 0)
@@ -156,14 +163,14 @@ namespace OpenRA.Mods.Common.Traits
state = AnimationState.IdleAnimating;
DefaultAnimation.PlayThen(idleSequence, () =>
{
DefaultAnimation.PlayRepeating(NormalizeInfantrySequence(self, Info.StandSequences.Random(Game.CosmeticRandom)));
PlayStandAnimation(self);
state = AnimationState.Waiting;
});
}
}
else
{
DefaultAnimation.PlayRepeating(NormalizeInfantrySequence(self, Info.StandSequences.Random(Game.CosmeticRandom)));
PlayStandAnimation(self);
state = AnimationState.Waiting;
}
}