fix spy crashing things when disguised as a unit with fewer idle anims
This commit is contained in:
@@ -56,13 +56,14 @@ namespace OpenRA.Graphics
|
|||||||
PlayThen( sequenceName, () => PlayRepeating( CurrentSequence.Name ) );
|
PlayThen( sequenceName, () => PlayRepeating( CurrentSequence.Name ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReplaceAnim(string sequenceName)
|
public bool ReplaceAnim(string sequenceName)
|
||||||
{
|
{
|
||||||
if (!HasSequence(sequenceName))
|
if (!HasSequence(sequenceName))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
CurrentSequence = SequenceProvider.GetSequence(name, sequenceName);
|
CurrentSequence = SequenceProvider.GetSequence(name, sequenceName);
|
||||||
frame %= CurrentSequence.Length;
|
frame %= CurrentSequence.Length;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayThen( string sequenceName, Action after )
|
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();
|
newImage = newImage.ToLowerInvariant();
|
||||||
|
|
||||||
if (name != newImage)
|
if (name != newImage)
|
||||||
{
|
{
|
||||||
name = newImage.ToLowerInvariant();
|
name = newImage.ToLowerInvariant();
|
||||||
ReplaceAnim(CurrentSequence.Name);
|
if (!ReplaceAnim(CurrentSequence.Name))
|
||||||
|
ReplaceAnim(newAnimIfMissing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Mods.RA.Render;
|
using OpenRA.Mods.RA.Render;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,6 @@ namespace OpenRA.Mods.RA
|
|||||||
public object Create(ActorInitializer init) { return new IdleAnimation(this); }
|
public object Create(ActorInitializer init) { return new IdleAnimation(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
// infantry prone behavior
|
|
||||||
class IdleAnimation : ITick, INotifyIdle
|
class IdleAnimation : ITick, INotifyIdle
|
||||||
{
|
{
|
||||||
enum IdleState
|
enum IdleState
|
||||||
@@ -54,7 +53,12 @@ namespace OpenRA.Mods.RA
|
|||||||
else if (delay > 0 && --delay == 0)
|
else if (delay > 0 && --delay == 0)
|
||||||
{
|
{
|
||||||
state = IdleState.Active;
|
state = IdleState.Active;
|
||||||
self.Trait<RenderInfantry>().anim.PlayThen(sequence, () => state = IdleState.None);
|
var ri = self.TraitOrDefault<RenderInfantry>();
|
||||||
|
|
||||||
|
if (ri.anim.HasSequence(sequence))
|
||||||
|
ri.anim.PlayThen(sequence, () => state = IdleState.None);
|
||||||
|
else
|
||||||
|
state = IdleState.None;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,13 +46,13 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
{
|
{
|
||||||
disguisedAsPlayer = target.Owner;
|
disguisedAsPlayer = target.Owner;
|
||||||
disguisedAsSprite = target.Trait<RenderSimple>().GetImage(target);
|
disguisedAsSprite = target.Trait<RenderSimple>().GetImage(target);
|
||||||
anim.ChangeImage(disguisedAsSprite);
|
anim.ChangeImage(disguisedAsSprite, "stand");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disguisedAsPlayer = null;
|
disguisedAsPlayer = null;
|
||||||
disguisedAsSprite = null;
|
disguisedAsSprite = null;
|
||||||
anim.ChangeImage(GetImage(self));
|
anim.ChangeImage(GetImage(self), "stand");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user