This commit is contained in:
Paul Chote
2013-06-01 12:53:19 +12:00
parent bf3d337913
commit 8123a383b6
2 changed files with 15 additions and 9 deletions

View File

@@ -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));
}
}
}