unhardcode and self-document render sequences

This commit is contained in:
Matthias Mailänder
2015-04-06 21:12:07 +02:00
parent cd9589eaa0
commit 7157cc0a9f
9 changed files with 48 additions and 23 deletions

View File

@@ -20,12 +20,17 @@ namespace OpenRA.Mods.Common.Traits
public class RenderUnit : RenderSimple
{
readonly RenderUnitInfo info;
public RenderUnit(ActorInitializer init, RenderUnitInfo info)
: base(init, info) { }
: base(init, info)
{
this.info = info;
}
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
{
DefaultAnimation.PlayThen(newAnim, () => { DefaultAnimation.Play("idle"); if (after != null) after(); });
DefaultAnimation.PlayThen(newAnim, () => { DefaultAnimation.Play(info.Sequence); if (after != null) after(); });
}
public void PlayCustomAnimRepeating(Actor self, string name)
@@ -37,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
public void PlayCustomAnimBackwards(Actor self, string name, Action after)
{
DefaultAnimation.PlayBackwardsThen(name,
() => { DefaultAnimation.PlayRepeating("idle"); if (after != null) after(); });
() => { DefaultAnimation.PlayRepeating(info.Sequence); if (after != null) after(); });
}
}
}