fix spy crashing things when disguised as a unit with fewer idle anims

This commit is contained in:
Chris Forbes
2010-12-04 11:02:53 +13:00
parent 05718f9e8e
commit 9c20fba4a0
3 changed files with 16 additions and 10 deletions

View File

@@ -56,13 +56,14 @@ namespace OpenRA.Graphics
PlayThen( sequenceName, () => PlayRepeating( CurrentSequence.Name ) );
}
public void ReplaceAnim(string sequenceName)
public bool ReplaceAnim(string sequenceName)
{
if (!HasSequence(sequenceName))
return;
return false;
CurrentSequence = SequenceProvider.GetSequence(name, sequenceName);
frame %= CurrentSequence.Length;
return true;
}
public void PlayThen( string sequenceName, Action after )
@@ -124,14 +125,15 @@ namespace OpenRA.Graphics
}
}
public void ChangeImage(string newImage)
public void ChangeImage(string newImage, string newAnimIfMissing)
{
newImage = newImage.ToLowerInvariant();
if (name != newImage)
{
name = newImage.ToLowerInvariant();
ReplaceAnim(CurrentSequence.Name);
if (!ReplaceAnim(CurrentSequence.Name))
ReplaceAnim(newAnimIfMissing);
}
}