Kill ITerrainTypeModifier for explicit updating of a custom layer in the map. Functionally equivalent, but MUCH faster.

This commit is contained in:
Paul Chote
2010-07-22 22:22:53 +12:00
parent 3e493cb93c
commit d21e9fe093
10 changed files with 27 additions and 49 deletions

View File

@@ -171,6 +171,10 @@ namespace OpenRA.Mods.RA
currentTemplate = (ds == DamageState.Half && Info.DamagedTemplate > 0) ? Info.DamagedTemplate :
(ds == DamageState.Dead && Info.DestroyedTemplate > 0) ? Info.DestroyedTemplate : Info.Template;
// Update map
foreach (var c in TileSprites[currentTemplate].Keys)
self.World.Map.CustomTerrain[c.X, c.Y] = GetTerrainType(c);
if (Info.Long && ds == DamageState.Dead)
{
// Long bridges have custom art for multiple segments being destroyed

View File

@@ -22,7 +22,7 @@ namespace OpenRA.Mods.RA
public object Create(ActorInitializer init) { return new BridgeLayer(init.self, this); }
}
class BridgeLayer : ILoadWorldHook, ITerrainTypeModifier
class BridgeLayer : ILoadWorldHook
{
readonly BridgeLayerInfo Info;
readonly World world;
@@ -106,13 +106,6 @@ namespace OpenRA.Mods.RA
bridge.Create(tile, subTiles);
}
public string GetTerrainType(int2 cell)
{
if (Bridges[ cell.X, cell.Y ] != null)
return Bridges[ cell.X, cell.Y ].GetTerrainType(cell);
return null;
}
// Used to check for neighbouring bridges
public Bridge GetBridge(int2 cell)
{

View File

@@ -58,7 +58,7 @@ namespace OpenRA.Mods.RA
var p = self.World.ChooseRandomCell(self.World.SharedRandom);
// Is this valid terrain?
var terrainType = self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[p.X, p.Y]);
var terrainType = self.World.GetTerrainType(p);
if (!(inWater ? info.ValidWater : info.ValidGround).Contains(terrainType)) continue;
// Don't drop on any actors

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA
var p = self.World.ChooseRandomCell(self.World.SharedRandom);
// Is this valid terrain?
var terrainType = self.World.TileSet.GetTerrainType(self.World.Map.MapTiles[p.X, p.Y]);
var terrainType = self.World.GetTerrainType(p);
if (!(inWater ? info.ValidWater : info.ValidGround).Contains(terrainType)) continue;
// Don't spawn on any actors