Make FrozenUnderFog count passable footprint cells

To avoid crashing on actors with only passable footprint cells.
This commit is contained in:
reaperrr
2016-05-14 00:29:16 +02:00
parent f31ea658ef
commit e59c7a8b1f
2 changed files with 8 additions and 3 deletions

View File

@@ -17,7 +17,7 @@ namespace OpenRA.Mods.Common.Traits
{
public static class FootprintUtils
{
public static IEnumerable<CPos> Tiles(Ruleset rules, string name, BuildingInfo buildingInfo, CPos topLeft)
public static IEnumerable<CPos> Tiles(Ruleset rules, string name, BuildingInfo buildingInfo, CPos topLeft, bool includePassable = false)
{
var dim = buildingInfo.Dimensions;
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits
footprint = footprint.Concat(new char[dim.X]);
}
return TilesWhere(name, dim, footprint.ToArray(), a => a != '_').Select(t => t + topLeft);
return TilesWhere(name, dim, footprint.ToArray(), a => includePassable || a != '_').Select(t => t + topLeft);
}
public static IEnumerable<CPos> Tiles(Actor a)
@@ -38,6 +38,11 @@ namespace OpenRA.Mods.Common.Traits
return Tiles(a.World.Map.Rules, a.Info.Name, a.Info.TraitInfo<BuildingInfo>(), a.Location);
}
public static IEnumerable<CPos> FrozenUnderFogTiles(Actor a)
{
return Tiles(a.World.Map.Rules, a.Info.Name, a.Info.TraitInfo<BuildingInfo>(), a.Location, true);
}
public static IEnumerable<CPos> UnpathableTiles(string name, BuildingInfo buildingInfo, CPos position)
{
var footprint = buildingInfo.Footprint.Where(x => !char.IsWhiteSpace(x)).ToArray();

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.Common.Traits
// Explore map-placed actors if the "Explore Map" option is enabled
var exploredMap = !init.World.LobbyInfo.GlobalSettings.Shroud;
startsRevealed = exploredMap && init.Contains<SpawnedByMapInit>() && !init.Contains<HiddenUnderFogInit>();
var footprintCells = FootprintUtils.Tiles(init.Self).ToList();
var footprintCells = FootprintUtils.FrozenUnderFogTiles(init.Self).ToList();
footprint = footprintCells.SelectMany(c => map.ProjectedCellsCovering(c.ToMPos(map))).ToArray();
}