Pass WorldRenderer to AnimationWithOffset.OffsetFunc.
This commit is contained in:
@@ -16,7 +16,7 @@ namespace OpenRA.Graphics
|
||||
public class AnimationWithOffset
|
||||
{
|
||||
public Animation Animation;
|
||||
public Func<float2> OffsetFunc;
|
||||
public Func<WorldRenderer, float2> OffsetFunc;
|
||||
public Func<bool> DisableFunc;
|
||||
public int ZOffset;
|
||||
|
||||
@@ -25,18 +25,18 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
}
|
||||
|
||||
public AnimationWithOffset(Animation a, Func<float2> o, Func<bool> d)
|
||||
public AnimationWithOffset(Animation a, Func<WorldRenderer, float2> o, Func<bool> d)
|
||||
{
|
||||
this.Animation = a;
|
||||
this.OffsetFunc = o;
|
||||
this.DisableFunc = d;
|
||||
}
|
||||
|
||||
public Renderable Image(Actor self, PaletteReference pal)
|
||||
public Renderable Image(Actor self, WorldRenderer wr, PaletteReference pal)
|
||||
{
|
||||
var p = self.CenterLocation;
|
||||
var loc = p.ToFloat2() - 0.5f * Animation.Image.size
|
||||
+ (OffsetFunc != null ? OffsetFunc() : float2.Zero);
|
||||
+ (OffsetFunc != null ? OffsetFunc(wr) : float2.Zero);
|
||||
var r = new Renderable(Animation.Image, loc, pal, p.Y);
|
||||
|
||||
return ZOffset != 0 ? r.WithZOffset(ZOffset) : r;
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace OpenRA.Traits
|
||||
foreach (var a in anims.Values)
|
||||
if (a.DisableFunc == null || !a.DisableFunc())
|
||||
{
|
||||
Renderable ret = a.Image(self, palette);
|
||||
Renderable ret = a.Image(self, wr, palette);
|
||||
if (Info.Scale != 1f)
|
||||
ret = ret.WithScale(Info.Scale).WithPos(ret.Pos + 0.5f * ret.Sprite.size * (1 - Info.Scale));
|
||||
yield return ret;
|
||||
|
||||
Reference in New Issue
Block a user