Cache cell ramps to avoid repeated tileset lookups.
This commit is contained in:
@@ -83,9 +83,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (jli.JumpjetTransitionOnRamps)
|
||||
return true;
|
||||
|
||||
var tile = map.Tiles[cell];
|
||||
var ti = map.Rules.TileSet.GetTileInfo(tile);
|
||||
return ti == null || ti.RampType == 0;
|
||||
return map.Ramp[cell] == 0;
|
||||
}
|
||||
|
||||
int ICustomMovementLayer.EntryMovementCost(ActorInfo a, LocomotorInfo li, CPos cell)
|
||||
|
||||
@@ -65,8 +65,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
// Correlate the tile "image" aka subtile with its position to find the template origin
|
||||
var tile = w.Map.Tiles[cell].Type;
|
||||
var index = w.Map.Tiles[cell].Index;
|
||||
var ti = w.Map.Tiles[cell];
|
||||
var tile = ti.Type;
|
||||
var index = ti.Index;
|
||||
var template = w.Map.Rules.TileSet.Templates[tile];
|
||||
var ni = cell.X - index % template.Size.X;
|
||||
var nj = cell.Y - index / template.Size.X;
|
||||
@@ -89,7 +90,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var subtile = new CPos(ni + ind % template.Size.X, nj + ind / template.Size.X);
|
||||
|
||||
// This isn't the bridge you're looking for
|
||||
if (!mapTiles.Contains(subtile) || mapTiles[subtile].Type != tile || mapTiles[subtile].Index != ind)
|
||||
var subti = mapTiles[subtile];
|
||||
if (!mapTiles.Contains(subtile) || subti.Type != tile || subti.Index != ind)
|
||||
continue;
|
||||
|
||||
subTiles.Add(subtile, ind);
|
||||
|
||||
@@ -109,15 +109,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!rt.Info.AllowUnderBuildings && buildingInfluence.GetBuildingAt(cell) != null)
|
||||
return false;
|
||||
|
||||
if (!rt.Info.AllowOnRamps)
|
||||
{
|
||||
var tile = world.Map.Tiles[cell];
|
||||
var tileInfo = world.Map.Rules.TileSet.GetTileInfo(tile);
|
||||
if (tileInfo != null && tileInfo.RampType > 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return rt.Info.AllowOnRamps || world.Map.Ramp[cell] == 0;
|
||||
}
|
||||
|
||||
public bool CanSpawnResourceAt(ResourceType newResourceType, CPos cell)
|
||||
|
||||
@@ -82,9 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (sli.SubterraneanTransitionOnRamps)
|
||||
return true;
|
||||
|
||||
var tile = map.Tiles[cell];
|
||||
var ti = map.Rules.TileSet.GetTileInfo(tile);
|
||||
return ti == null || ti.RampType == 0;
|
||||
return map.Ramp[cell] == 0;
|
||||
}
|
||||
|
||||
int ICustomMovementLayer.EntryMovementCost(ActorInfo a, LocomotorInfo li, CPos cell)
|
||||
|
||||
@@ -63,11 +63,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
continue;
|
||||
|
||||
var height = (int)map.Height[uv];
|
||||
var tile = map.Tiles[uv];
|
||||
var ti = tileSet.GetTileInfo(tile);
|
||||
var ramp = ti != null ? ti.RampType : 0;
|
||||
|
||||
var corners = map.Grid.CellCorners[ramp];
|
||||
var corners = map.Grid.CellCorners[map.Ramp[uv]];
|
||||
var pos = map.CenterOfCell(uv.ToCPos(map));
|
||||
var width = uv == mouseCell ? 3 : 1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user