diff --git a/OpenRA.Game/Graphics/Renderable.cs b/OpenRA.Game/Graphics/Renderable.cs index d8e247431f..b2e84114ce 100644 --- a/OpenRA.Game/Graphics/Renderable.cs +++ b/OpenRA.Game/Graphics/Renderable.cs @@ -41,7 +41,6 @@ namespace OpenRA.Graphics IRenderable WithZOffset(int newOffset); IRenderable WithPos(WPos pos); void Render(WorldRenderer wr); - WVec Size(WorldRenderer wr); } public struct SpriteRenderable : IRenderable @@ -84,11 +83,5 @@ namespace OpenRA.Graphics { sprite.DrawAt(wr.ScreenPxPosition(pos) - pxCenter, palette.Index, scale); } - - public WVec Size(WorldRenderer wr) - { - var size = (scale*sprite.size).ToInt2(); - return new WVec(size.X, size.Y, size.Y); - } } } diff --git a/OpenRA.Mods.RA/BelowUnits.cs b/OpenRA.Mods.RA/BelowUnits.cs index 64c5c36bc2..73c6fe4616 100644 --- a/OpenRA.Mods.RA/BelowUnits.cs +++ b/OpenRA.Mods.RA/BelowUnits.cs @@ -11,17 +11,30 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; +using OpenRA.Mods.RA.Buildings; using OpenRA.Traits; namespace OpenRA.Mods.RA { - class BelowUnitsInfo : TraitInfo { } + class BelowUnitsInfo : ITraitInfo + { + public object Create(ActorInitializer init) { return new BelowUnits(init.self); } + } class BelowUnits : IRenderModifier { + int offset; + + public BelowUnits(Actor self) + { + // Offset effective position to the top of the northernmost occupied cell + var bi = self.Info.Traits.GetOrDefault(); + offset = (bi != null) ? -FootprintUtils.CenterOffset(bi).Y : -512; + } + public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { - return r.Select(a => a.WithZOffset(-a.Size(wr).Z)); + return r.Select(a => a.WithZOffset(offset)); } } }