Remove FootprintUtils

This commit is contained in:
reaperrr
2017-07-01 17:44:24 +02:00
committed by abcdefg30
parent 46dc827d46
commit fdb3866238
18 changed files with 35 additions and 83 deletions

View File

@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Traits
class Bridge : IRender, INotifyDamageStateChanged
{
readonly BuildingInfo building;
readonly BuildingInfo buildingInfo;
readonly Bridge[] neighbours = new Bridge[2];
readonly LegacyBridgeHut[] huts = new LegacyBridgeHut[2]; // Huts before this / first & after this / last
readonly Health health;
@@ -99,7 +99,7 @@ namespace OpenRA.Mods.Common.Traits
this.info = info;
type = self.Info.Name;
isDangling = new Lazy<bool>(() => huts[0] == huts[1] && (neighbours[0] == null || neighbours[1] == null));
building = self.Info.TraitInfo<BuildingInfo>();
buildingInfo = self.Info.TraitInfo<BuildingInfo>();
}
public Bridge Neighbour(int direction) { return neighbours[direction]; }
@@ -181,7 +181,7 @@ namespace OpenRA.Mods.Common.Traits
IRenderable[] TemplateRenderables(WorldRenderer wr, PaletteReference palette, ushort template)
{
var offset = FootprintUtils.CenterOffset(self.World, building).Y + 1024;
var offset = buildingInfo.CenterOffset(self.World).Y + 1024;
return footprint.Select(c => (IRenderable)(new SpriteRenderable(
wr.Theater.TileSprite(new TerrainTile(template, c.Value)),

View File

@@ -1,52 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2017 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, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
namespace OpenRA.Mods.Common.Traits
{
public static class FootprintUtils
{
public static IEnumerable<CPos> Tiles(Actor a)
{
var info = a.Info.TraitInfo<BuildingInfo>();
return info.Tiles(a.Location);
}
public static IEnumerable<CPos> FrozenUnderFogTiles(Actor a)
{
var info = a.Info.TraitInfo<BuildingInfo>();
return info.FrozenUnderFogTiles(a);
}
public static IEnumerable<CPos> UnpathableTiles(string name, BuildingInfo buildingInfo, CPos position)
{
return buildingInfo.UnpathableTiles(position);
}
public static IEnumerable<CPos> PathableTiles(string name, BuildingInfo buildingInfo, CPos position)
{
return buildingInfo.PathableTiles(position);
}
public static CVec AdjustForBuildingSize(BuildingInfo buildingInfo)
{
return buildingInfo.AdjustForBuildingSize();
}
public static WVec CenterOffset(World w, BuildingInfo buildingInfo)
{
return buildingInfo.CenterOffset(w);
}
}
}

View File

@@ -117,7 +117,7 @@ namespace OpenRA.Mods.Common.Traits
public override void AddedToWorld(Actor self)
{
base.AddedToWorld(self);
blockedPositions = FootprintUtils.Tiles(self);
blockedPositions = Info.Tiles(self.Location);
}
bool IsBlocked()

View File

@@ -51,7 +51,7 @@ namespace OpenRA.Mods.Common.Traits
bridgeLayer = self.World.WorldActor.Trait<BridgeLayer>();
var buildingInfo = self.Info.TraitInfo<BuildingInfo>();
cells = FootprintUtils.PathableTiles(self.Info.Name, buildingInfo, self.Location);
cells = buildingInfo.PathableTiles(self.Location);
}
void UpdateTerrain(Actor self, byte terrainIndex)