don't look up IFacing (twice!) every frame for every actor with RenderUnit; fixes #1054

This commit is contained in:
Chris Forbes
2011-07-19 18:39:45 +12:00
parent 2797ea72cb
commit 7429c8ef89

View File

@@ -21,8 +21,15 @@ 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, () => self.HasTrait<IFacing>() ? self.Trait<IFacing>().Facing : 0)
: base(self, MakeFacingFunc(self))
{
anim.PlayRepeating("idle");
}