Cache cell ramps to avoid repeated tileset lookups.

This commit is contained in:
Paul Chote
2020-05-04 00:20:48 +01:00
committed by atlimit8
parent 1354ffc32e
commit 4614f6febe
9 changed files with 37 additions and 56 deletions

View File

@@ -39,14 +39,8 @@ namespace OpenRA.Mods.Common.Traits
else if (!bi.AllowInvalidPlacement && world.ActorMap.GetActorsAt(cell).Any(a => a != toIgnore))
return false;
var tile = world.Map.Tiles[cell];
var tileInfo = world.Map.Rules.TileSet.GetTileInfo(tile);
// TODO: This is bandaiding over bogus tilesets.
if (tileInfo != null && tileInfo.RampType > 0)
return false;
return bi.TerrainTypes.Contains(world.Map.GetTerrainInfo(cell).Type);
// Buildings can never be placed on ramps
return world.Map.Ramp[cell] == 0 && bi.TerrainTypes.Contains(world.Map.GetTerrainInfo(cell).Type);
}
public static bool CanPlaceBuilding(this World world, CPos cell, ActorInfo ai, BuildingInfo bi, Actor toIgnore)