This commit is contained in:
Chris Forbes
2011-07-19 18:56:12 +12:00
parent 7429c8ef89
commit 833533b4c3
3 changed files with 11 additions and 10 deletions

View File

@@ -34,6 +34,13 @@ namespace OpenRA.Traits
{
public Dictionary<string, AnimationWithOffset> anims = new Dictionary<string, AnimationWithOffset>();
public static Func<int> MakeFacingFunc(Actor self)
{
var facing = self.TraitOrDefault<IFacing>();
if (facing == null) return () => 0;
return () => facing.Facing;
}
public Animation anim
{
get { return anims[""].Animation; }

View File

@@ -41,6 +41,7 @@ namespace OpenRA.Mods.RA.Render
RenderInfantryInfo Info;
string idleSequence;
int idleDelay;
Mobile mobile;
protected virtual string NormalizeInfantrySequence(Actor self, string baseSequence)
{
@@ -53,9 +54,9 @@ namespace OpenRA.Mods.RA.Render
}
public AnimationState State { get; private set; }
Mobile mobile;
public RenderInfantry(Actor self, RenderInfantryInfo info)
: base(self, () => self.Trait<IFacing>().Facing)
: base(self, RenderSimple.MakeFacingFunc(self))
{
Info = info;
anim.PlayFetchIndex(NormalizeInfantrySequence(self, "stand"), () => 0);

View File

@@ -21,15 +21,8 @@ namespace OpenRA.Mods.RA.Render
public class RenderUnit : RenderSimple
{
static Func<int> MakeFacingFunc(Actor self)
{
var facing = self.TraitOrDefault<IFacing>();
if (facing == null) return () => 0;
return () => facing.Facing;
}
public RenderUnit(Actor self)
: base(self, MakeFacingFunc(self))
: base(self, RenderSimple.MakeFacingFunc(self))
{
anim.PlayRepeating("idle");
}