remove BelowUnits

closes #3670
This commit is contained in:
Matthias Mailänder
2014-09-14 10:41:38 +02:00
parent 219151f41f
commit a3baee9d68
22 changed files with 353 additions and 92 deletions

View File

@@ -1,40 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Graphics;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
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(self.World, bi).Y : 0) - 512;
}
public IEnumerable<IRenderable> ModifyRender(Actor self, WorldRenderer wr, IEnumerable<IRenderable> r)
{
return r.Select(a => a.WithZOffset(a.ZOffset + offset));
}
}
}

View File

@@ -14,12 +14,13 @@ using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Mods.RA.Buildings;
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
class BridgeInfo : ITraitInfo, Requires<HealthInfo>
class BridgeInfo : ITraitInfo, Requires<HealthInfo>, Requires<BuildingInfo>
{
public readonly bool Long = false;
@@ -71,6 +72,8 @@ namespace OpenRA.Mods.RA
class Bridge : IRender, INotifyDamageStateChanged
{
readonly Building building;
readonly Bridge[] neighbours = new Bridge[2];
readonly BridgeHut[] huts = new BridgeHut[2]; // Huts before this / first & after this / last
public readonly Health Health;
@@ -90,6 +93,7 @@ namespace OpenRA.Mods.RA
Health.RemoveOnDeath = false;
this.Info = info;
this.Type = self.Info.Name;
building = self.Trait<Building>();
}
public Bridge Neighbour(int direction) { return neighbours[direction]; }
@@ -163,9 +167,11 @@ namespace OpenRA.Mods.RA
IRenderable[] TemplateRenderables(WorldRenderer wr, PaletteReference palette, ushort template)
{
var offset = FootprintUtils.CenterOffset(self.World, building.Info).Y + 1024;
return footprint.Select(c => (IRenderable)(new SpriteRenderable(
wr.Theater.TileSprite(new TerrainTile(template, c.Value)),
wr.world.Map.CenterOfCell(c.Key), WVec.Zero, -512, palette, 1f, true))).ToArray();
wr.world.Map.CenterOfCell(c.Key), WVec.Zero, -offset, palette, 1f, true))).ToArray();
}
bool initialized;

View File

@@ -164,7 +164,6 @@
<Compile Include="AutoHeal.cs" />
<Compile Include="AutoTarget.cs" />
<Compile Include="BaseBuilding.cs" />
<Compile Include="BelowUnits.cs" />
<Compile Include="Bridge.cs" />
<Compile Include="BridgeLayer.cs" />
<Compile Include="Buildable.cs" />