put AnimationWithOffset in its own file

This commit is contained in:
Chris Forbes
2011-07-17 16:53:29 +12:00
parent 59616671b6
commit 4a0b7bb003
11 changed files with 62 additions and 45 deletions

View File

@@ -105,40 +105,5 @@ namespace OpenRA.Traits
anim.PlayThen(NormalizeSequence(self, name),
() => anim.PlayRepeating(NormalizeSequence(self, "idle")));
}
public class AnimationWithOffset
{
public Animation Animation;
public Func<float2> OffsetFunc;
public Func<bool> DisableFunc;
public int ZOffset;
public AnimationWithOffset(Animation a)
: this(a, null, null)
{
}
public AnimationWithOffset(Animation a, Func<float2> o, Func<bool> d)
{
this.Animation = a;
this.OffsetFunc = o;
this.DisableFunc = d;
}
public Renderable Image(Actor self, string pal)
{
var p = self.CenterLocation;
var loc = p - 0.5f * Animation.Image.size
+ (OffsetFunc != null ? OffsetFunc() : float2.Zero);
var r = new Renderable(Animation.Image, loc, pal, p.Y);
return ZOffset != 0 ? r.WithZOffset(ZOffset) : r;
}
public static implicit operator AnimationWithOffset(Animation a)
{
return new AnimationWithOffset(a);
}
}
}
}