Move GetTerrainIndex/Info from WorldUtils to Map
This commit is contained in:
@@ -182,7 +182,7 @@ namespace OpenRA.GameRules
|
||||
if (!world.Map.IsInMap(cell))
|
||||
return false;
|
||||
|
||||
var cellInfo = world.GetTerrainInfo(cell);
|
||||
var cellInfo = world.Map.GetTerrainInfo(cell);
|
||||
if (!ValidTargets.Intersect(cellInfo.TargetTypes).Any()
|
||||
|| InvalidTargets.Intersect(cellInfo.TargetTypes).Any())
|
||||
return false;
|
||||
|
||||
@@ -537,5 +537,18 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int GetTerrainIndex(CPos cell)
|
||||
{
|
||||
var custom = CustomTerrain[cell.X, cell.Y];
|
||||
var tileSet = Rules.TileSets[Tileset];
|
||||
return custom != -1 ? custom : tileSet.GetTerrainIndex(MapTiles.Value[cell.X, cell.Y]);
|
||||
}
|
||||
|
||||
public TerrainTypeInfo GetTerrainInfo(CPos cell)
|
||||
{
|
||||
var tileSet = Rules.TileSets[Tileset];
|
||||
return tileSet[GetTerrainIndex(cell)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace OpenRA.Traits
|
||||
if (!world.Map.IsInMap(a.X, a.Y))
|
||||
return false;
|
||||
|
||||
if (!rt.Info.AllowedTerrainTypes.Contains(world.GetTerrainInfo(a).Type))
|
||||
if (!rt.Info.AllowedTerrainTypes.Contains(world.Map.GetTerrainInfo(a).Type))
|
||||
return false;
|
||||
|
||||
if (!rt.Info.AllowUnderActors && world.ActorMap.AnyUnitsAt(a))
|
||||
|
||||
@@ -88,17 +88,6 @@ namespace OpenRA
|
||||
public const int MaxRange = 50;
|
||||
static List<CVec>[] TilesByDistance = InitTilesByDistance(MaxRange);
|
||||
|
||||
public static int GetTerrainIndex(this World world, CPos cell)
|
||||
{
|
||||
var custom = world.Map.CustomTerrain[cell.X, cell.Y];
|
||||
return custom != -1 ? custom : world.TileSet.GetTerrainIndex(world.Map.MapTiles.Value[cell.X, cell.Y]);
|
||||
}
|
||||
|
||||
public static TerrainTypeInfo GetTerrainInfo(this World world, CPos cell)
|
||||
{
|
||||
return world.TileSet[world.GetTerrainIndex(cell)];
|
||||
}
|
||||
|
||||
public static CPos ClampToWorld(this World world, CPos xy)
|
||||
{
|
||||
var r = world.Map.Bounds;
|
||||
|
||||
Reference in New Issue
Block a user