diff --git a/OpenRA.Game/Graphics/AnimationWithOffset.cs b/OpenRA.Game/Graphics/AnimationWithOffset.cs index c048f5c8fd..8691c91c6e 100644 --- a/OpenRA.Game/Graphics/AnimationWithOffset.cs +++ b/OpenRA.Game/Graphics/AnimationWithOffset.cs @@ -16,7 +16,7 @@ namespace OpenRA.Graphics public class AnimationWithOffset { public Animation Animation; - public Func OffsetFunc; + public Func OffsetFunc; public Func DisableFunc; public int ZOffset; @@ -25,18 +25,18 @@ namespace OpenRA.Graphics { } - public AnimationWithOffset(Animation a, Func o, Func d) + public AnimationWithOffset(Animation a, Func o, Func 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; diff --git a/OpenRA.Game/Traits/Render/RenderSimple.cs b/OpenRA.Game/Traits/Render/RenderSimple.cs index e6c5eca69d..eec13f8683 100755 --- a/OpenRA.Game/Traits/Render/RenderSimple.cs +++ b/OpenRA.Game/Traits/Render/RenderSimple.cs @@ -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; diff --git a/OpenRA.Mods.Cnc/RenderBuildingRefinery.cs b/OpenRA.Mods.Cnc/RenderBuildingRefinery.cs index 105dd9934e..819f02cf53 100755 --- a/OpenRA.Mods.Cnc/RenderBuildingRefinery.cs +++ b/OpenRA.Mods.Cnc/RenderBuildingRefinery.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Cnc : 0); var offset = new float2(-32,-21); - anims.Add("lights", new AnimationWithOffset( lights, () => offset, () => !buildComplete ) + anims.Add("lights", new AnimationWithOffset( lights, wr => offset, () => !buildComplete ) { ZOffset = 24 }); } diff --git a/OpenRA.Mods.Cnc/RenderGunboat.cs b/OpenRA.Mods.Cnc/RenderGunboat.cs index 708d29a405..9bb6be9d3d 100644 --- a/OpenRA.Mods.Cnc/RenderGunboat.cs +++ b/OpenRA.Mods.Cnc/RenderGunboat.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Render var wake = new Animation(anim.Name); wake.Play("left-wake"); - Func offset = () => new float2(((anims["wake"].Animation.CurrentSequence.Name == "left-wake") ? 1 : -1),2); + Func offset = wr => new float2(((anims["wake"].Animation.CurrentSequence.Name == "left-wake") ? 1 : -1),2); anims.Add( "wake", new AnimationWithOffset( wake, offset, () => false ) { ZOffset = -2 } ); } diff --git a/OpenRA.Mods.Cnc/WithFire.cs b/OpenRA.Mods.Cnc/WithFire.cs index d94c8922a4..85ee48ca0b 100644 --- a/OpenRA.Mods.Cnc/WithFire.cs +++ b/OpenRA.Mods.Cnc/WithFire.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Cnc var rs = self.Trait(); var roof = new Animation(rs.GetImage(self)); roof.PlayThen("fire-start", () => roof.PlayRepeating("fire-loop")); - rs.anims.Add( "fire", new AnimationWithOffset( roof, () => new float2(7,-15), null ) { ZOffset = 24 } ); + rs.anims.Add( "fire", new AnimationWithOffset( roof, wr => new float2(7,-15), null ) { ZOffset = 24 } ); } } } diff --git a/OpenRA.Mods.RA/Burns.cs b/OpenRA.Mods.RA/Burns.cs index bc39d33ef8..34c3db5528 100644 --- a/OpenRA.Mods.RA/Burns.cs +++ b/OpenRA.Mods.RA/Burns.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA var anim = new Animation("fire", () => 0); anim.PlayRepeating(Info.Anim); rs.anims.Add("fire", - new AnimationWithOffset(anim, () => new float2(0, -3), null)); + new AnimationWithOffset(anim, wr => new float2(0, -3), null)); } public void Tick(Actor self) diff --git a/OpenRA.Mods.RA/Render/RenderBuildingSeparateTurret.cs b/OpenRA.Mods.RA/Render/RenderBuildingSeparateTurret.cs index 4266355f55..b8c1d9da7d 100644 --- a/OpenRA.Mods.RA/Render/RenderBuildingSeparateTurret.cs +++ b/OpenRA.Mods.RA/Render/RenderBuildingSeparateTurret.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Render anim.Play("turret"); anims.Add("turret_{0}".F(i++), new AnimationWithOffset(anim, - () => PPos.FromWPosHackZ(WPos.Zero + t.Position(self)).ToFloat2(), null)); + wr => PPos.FromWPosHackZ(WPos.Zero + t.Position(self)).ToFloat2(), null)); } } } diff --git a/OpenRA.Mods.RA/Render/RenderUnitSpinner.cs b/OpenRA.Mods.RA/Render/RenderUnitSpinner.cs index 7089f599a3..9665c224e1 100755 --- a/OpenRA.Mods.RA/Render/RenderUnitSpinner.cs +++ b/OpenRA.Mods.RA/Render/RenderUnitSpinner.cs @@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Render var turret = new Turret(info.Offset); anims.Add("spinner", new AnimationWithOffset( spinnerAnim, - () => turret.PxPosition(self, facing).ToFloat2(), + wr => turret.PxPosition(self, facing).ToFloat2(), null ) { ZOffset = 1 } ); } } diff --git a/OpenRA.Mods.RA/Render/RenderUnitTurreted.cs b/OpenRA.Mods.RA/Render/RenderUnitTurreted.cs index 7bc2a6987c..cbba9dfb79 100755 --- a/OpenRA.Mods.RA/Render/RenderUnitTurreted.cs +++ b/OpenRA.Mods.RA/Render/RenderUnitTurreted.cs @@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Render anim.Play("turret"); anims.Add("turret_{0}".F(i++), new AnimationWithOffset(anim, - () => TurretPosition(self, turret, facing), null)); + wr => TurretPosition(self, turret, facing), null)); } } diff --git a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs index eb917643d2..bea897ec68 100644 --- a/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs +++ b/OpenRA.Mods.RA/Render/WithMuzzleFlash.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Render muzzleFlashes.Add("muzzle{0}".F(muzzleFlashes.Count), new AnimationWithOffset( muzzleFlash, - () => PPos.FromWPosHackZ(WPos.Zero + a.MuzzleOffset(self, barrel)).ToFloat2(), + wr => PPos.FromWPosHackZ(WPos.Zero + a.MuzzleOffset(self, barrel)).ToFloat2(), () => !isShowing)); } } @@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Render { foreach (var a in muzzleFlashes.Values) if (a.DisableFunc == null || !a.DisableFunc()) - yield return a.Image(self, wr.Palette("effect")); + yield return a.Image(self, wr, wr.Palette("effect")); } public void Tick(Actor self) diff --git a/OpenRA.Mods.RA/Render/WithRotor.cs b/OpenRA.Mods.RA/Render/WithRotor.cs index e394e6b884..89e5f513c6 100755 --- a/OpenRA.Mods.RA/Render/WithRotor.cs +++ b/OpenRA.Mods.RA/Render/WithRotor.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Render var turret = new Turret(info.Offset); rs.anims.Add(info.Id, new AnimationWithOffset( rotorAnim, - () => turret.PxPosition(self, facing).ToFloat2(), + wr => turret.PxPosition(self, facing).ToFloat2(), null ) { ZOffset = 1 } ); } diff --git a/OpenRA.Mods.RA/ThrowsParticle.cs b/OpenRA.Mods.RA/ThrowsParticle.cs index 3ce1f252f3..746bca1d3f 100644 --- a/OpenRA.Mods.RA/ThrowsParticle.cs +++ b/OpenRA.Mods.RA/ThrowsParticle.cs @@ -56,7 +56,7 @@ namespace OpenRA.Mods.RA anim.PlayRepeating(info.Anim); ru.anims.Add(info.AnimKey, new AnimationWithOffset( - anim, () => pos - new float2(0, alt), null)); + anim, wr => pos - new float2(0, alt), null)); } public void Tick(Actor self)