Allow NormalizeSequence to remove existing damage prefixes. Fixes #5909.

This commit is contained in:
Paul Chote
2014-07-10 17:16:46 +12:00
parent fd68c81b15
commit 2e9e4cff5c
2 changed files with 16 additions and 6 deletions

View File

@@ -47,9 +47,9 @@ namespace OpenRA.Traits
public int2 SelectionSize(Actor self) { return AutoSelectionSize(self); }
public string NormalizeSequence(Actor self, string baseSequence)
public string NormalizeSequence(Actor self, string sequence)
{
return NormalizeSequence(DefaultAnimation, self.GetDamageState(), baseSequence);
return NormalizeSequence(DefaultAnimation, self.GetDamageState(), sequence);
}
public void PlayCustomAnim(Actor self, string name)

View File

@@ -149,7 +149,7 @@ namespace OpenRA.Traits
anims.Remove(key);
}
public static string NormalizeSequence(Animation anim, DamageState state, string baseSequence)
public static string NormalizeSequence(Animation anim, DamageState state, string sequence)
{
var states = new Pair<DamageState, string>[]
{
@@ -159,11 +159,21 @@ namespace OpenRA.Traits
Pair.New(DamageState.Light, "scuffed-")
};
// Remove existing damage prefix
foreach (var s in states)
if (state >= s.First && anim.HasSequence(s.Second + baseSequence))
return s.Second + baseSequence;
{
if (sequence.StartsWith(s.Second))
{
sequence = sequence.Substring(s.Second.Length);
break;
}
}
return baseSequence;
foreach (var s in states)
if (state >= s.First && anim.HasSequence(s.Second + sequence))
return s.Second + sequence;
return sequence;
}
// Required by RenderSimple