diff --git a/OpenRA.Game/Traits/Render/RenderSimple.cs b/OpenRA.Game/Traits/Render/RenderSimple.cs index bacd54e00b..72696feb6f 100755 --- a/OpenRA.Game/Traits/Render/RenderSimple.cs +++ b/OpenRA.Game/Traits/Render/RenderSimple.cs @@ -70,7 +70,7 @@ namespace OpenRA.Traits foreach( var a in anims.Values ) if( a.DisableFunc == null || !a.DisableFunc() ) { - Renderable ret = a.Image( self ).WithPalette(Palette(self.Owner)); + Renderable ret = a.Image(self, Palette(self.Owner)); if (Info.Scale != 1f) ret = ret.WithScale(Info.Scale).WithPos(ret.Pos + 0.5f*ret.Sprite.size*(1 - Info.Scale)); yield return ret; @@ -118,10 +118,12 @@ namespace OpenRA.Traits this.DisableFunc = d; } - public Renderable Image( Actor self ) + public Renderable Image( Actor self, string pal ) { - var r = Util.Centered( self, Animation.Image, self.CenterLocation - + (OffsetFunc != null ? OffsetFunc() : float2.Zero) ); + var loc = self.CenterLocation - 0.5f * Animation.Image.size + + (OffsetFunc != null ? OffsetFunc() : float2.Zero); + var r = new Renderable(Animation.Image, loc, pal, (int)self.CenterLocation.Y); + return ZOffset != 0 ? r.WithZOffset(ZOffset) : r; } diff --git a/OpenRA.Game/Traits/Util.cs b/OpenRA.Game/Traits/Util.cs index 353645c9f3..82be232013 100755 --- a/OpenRA.Game/Traits/Util.cs +++ b/OpenRA.Game/Traits/Util.cs @@ -96,14 +96,6 @@ namespace OpenRA.Traits public static float2 RelOffset(this int[] offset) { return new float2(offset[0], offset[1]); } public static float2 AbsOffset(this int[] offset) { return new float2(offset.ElementAtOrDefault(2), offset.ElementAtOrDefault(3)); } - public static Renderable Centered(Actor self, Sprite s, float2 location) - { - var pal = "player{0}".F(self.Owner == null ? 0 : self.Owner.Index); - var loc = location - 0.5f * s.size; - - return new Renderable(s, loc.Round(), pal, (int)self.CenterLocation.Y); - } - public static Activity SequenceActivities(params Activity[] acts) { return acts.Reverse().Aggregate( diff --git a/OpenRA.Mods.RA/Effects/GpsDot.cs b/OpenRA.Mods.RA/Effects/GpsDot.cs index 46419d3be1..7fba65f8d7 100644 --- a/OpenRA.Mods.RA/Effects/GpsDot.cs +++ b/OpenRA.Mods.RA/Effects/GpsDot.cs @@ -16,7 +16,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Effects { - class GpsDotInfo : ITraitInfo + class GpsDotInfo : ITraitInfo, ITraitPrerequisite { public readonly string String = "Infantry"; public object Create(ActorInitializer init) @@ -27,10 +27,9 @@ namespace OpenRA.Mods.RA.Effects class GpsDot : IEffect { - int2 loc; - Color color; Actor self; GpsWatcher watcher; + RenderSimple rs; bool show = false; Animation anim; @@ -40,8 +39,7 @@ namespace OpenRA.Mods.RA.Effects anim.PlayRepeating(s); self = init.self; - loc = self.CenterLocation; - color = self.Owner.ColorRamp.GetColor(0); + rs = self.Trait(); self.World.AddFrameEndTask(w => w.Add(this)); if(self.World.LocalPlayer != null) watcher = self.World.LocalPlayer.PlayerActor.Trait(); @@ -65,14 +63,13 @@ namespace OpenRA.Mods.RA.Effects ) { show = true; - loc = self.CenterLocation; } } public IEnumerable Render() { if (show && !self.Destroyed) - yield return Traits.Util.Centered(self, anim.Image, self.CenterLocation.ToFloat2()) + yield return new Renderable(anim.Image, self.CenterLocation - 0.5f * anim.Image.size, rs.Palette(self.Owner), (int)self.CenterLocation.Y) .WithScale(1.5f); } } diff --git a/OpenRA.Mods.RA/Effects/Parachute.cs b/OpenRA.Mods.RA/Effects/Parachute.cs index 2ac1a04d2f..5771ccbc6f 100644 --- a/OpenRA.Mods.RA/Effects/Parachute.cs +++ b/OpenRA.Mods.RA/Effects/Parachute.cs @@ -24,7 +24,6 @@ namespace OpenRA.Mods.RA.Effects readonly float2 location; readonly Actor cargo; - readonly Player owner; float altitude; const float fallRate = .3f; @@ -34,7 +33,6 @@ namespace OpenRA.Mods.RA.Effects this.location = location; this.altitude = altitude; this.cargo = cargo; - this.owner = owner; var rs = cargo.Trait(); var image = rs.anim.Name;