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

@@ -192,13 +192,8 @@ namespace OpenRA.Traits
{
if (!self.World.Map.IsInMap(cell.X,cell.Y))
return float.PositiveInfinity;
// Custom terrain types don't stack: pick one
var customTerrain = self.World.WorldActor.traits.WithInterface<ITerrainTypeModifier>()
.Select( t => t.GetTerrainType(cell) )
.FirstOrDefault( t => t != null );
var type = (customTerrain != null) ? customTerrain : self.World.GetTerrainType(cell);
var type = self.World.GetTerrainType(cell);
var additionalCost = self.World.WorldActor.traits.WithInterface<ITerrainCost>()
.Select( t => t.GetTerrainCost(cell, self) ).Sum();
@@ -210,13 +205,8 @@ namespace OpenRA.Traits
var unitInfo = self.Info.Traits.GetOrDefault<UnitInfo>();
if( unitInfo == null )
return 0f;
// Custom terrain types don't stack: pick one
var customTerrain = self.World.WorldActor.traits.WithInterface<ITerrainTypeModifier>()
.Select( t => t.GetTerrainType(cell) )
.FirstOrDefault( t => t != null );
var type = (customTerrain != null) ? customTerrain : self.World.GetTerrainType(cell);
var type = self.World.GetTerrainType(cell);
var modifier = self.traits
.WithInterface<ISpeedModifier>()