Fixes #3334.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<BelowUnits> { }
|
||||
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<BuildingInfo>();
|
||||
offset = (bi != null) ? -FootprintUtils.CenterOffset(bi).Y : -512;
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
|
||||
{
|
||||
return r.Select(a => a.WithZOffset(-a.Size(wr).Z));
|
||||
return r.Select(a => a.WithZOffset(offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user