fixed Building.unitInfo
This commit is contained in:
@@ -1,17 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRa.Game.Traits;
|
||||
|
||||
namespace OpenRa.Game.GameRules
|
||||
{
|
||||
static class Footprint
|
||||
{
|
||||
public static IEnumerable<int2> Tiles( LegacyBuildingInfo buildingInfo, int2 position )
|
||||
public static IEnumerable<int2> Tiles( string name, BuildingInfo buildingInfo, int2 position )
|
||||
{
|
||||
return Tiles(buildingInfo, position, true);
|
||||
return Tiles(name, buildingInfo, position, true);
|
||||
}
|
||||
|
||||
public static IEnumerable<int2> Tiles( LegacyBuildingInfo buildingInfo, int2 position, bool adjustForPlacement )
|
||||
public static IEnumerable<int2> Tiles( string name, BuildingInfo buildingInfo, int2 position, bool adjustForPlacement )
|
||||
{
|
||||
var dim = buildingInfo.Dimensions;
|
||||
|
||||
@@ -24,19 +25,19 @@ namespace OpenRa.Game.GameRules
|
||||
|
||||
var adjustment = adjustForPlacement ? AdjustForBuildingSize(buildingInfo) : int2.Zero;
|
||||
|
||||
var tiles = TilesWhere(buildingInfo.Name, dim, footprint.ToArray(), a => a != '_');
|
||||
var tiles = TilesWhere(name, dim, footprint.ToArray(), a => a != '_');
|
||||
return tiles.Select(t => t + position - adjustment);
|
||||
}
|
||||
|
||||
public static IEnumerable<int2> Tiles(Actor a, Traits.Building building)
|
||||
{
|
||||
return Tiles( building.unitInfo, a.Location, false );
|
||||
return Tiles( a.Info.Name, a.Info.Traits.Get<BuildingInfo>(), a.Location, false );
|
||||
}
|
||||
|
||||
public static IEnumerable<int2> UnpathableTiles( LegacyBuildingInfo buildingInfo, int2 position )
|
||||
public static IEnumerable<int2> UnpathableTiles( string name, BuildingInfo buildingInfo, int2 position )
|
||||
{
|
||||
var footprint = buildingInfo.Footprint.Where( x => !char.IsWhiteSpace( x ) ).ToArray();
|
||||
foreach( var tile in TilesWhere( buildingInfo.Name, buildingInfo.Dimensions, footprint, a => a == 'x' ) )
|
||||
foreach( var tile in TilesWhere( name, buildingInfo.Dimensions, footprint, a => a == 'x' ) )
|
||||
yield return tile + position;
|
||||
}
|
||||
|
||||
@@ -52,9 +53,9 @@ namespace OpenRa.Game.GameRules
|
||||
yield return new int2( x, y );
|
||||
}
|
||||
|
||||
public static int2 AdjustForBuildingSize( LegacyBuildingInfo unitInfo )
|
||||
public static int2 AdjustForBuildingSize( BuildingInfo buildingInfo )
|
||||
{
|
||||
var dim = unitInfo.Dimensions;
|
||||
var dim = buildingInfo.Dimensions;
|
||||
return new int2( dim.X / 2, dim.Y > 1 ? ( dim.Y + 1 ) / 2 : 0 );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user