PathFinder doesn't really need it's own ref to Rules.Map

This commit is contained in:
Chris Forbes
2009-12-17 10:02:08 +13:00
parent bd2a2cefbb
commit f729c130c7
3 changed files with 38 additions and 40 deletions

View File

@@ -9,19 +9,16 @@ namespace OpenRa.Game
class PathFinder
{
float[][,] passableCost = new float[4][,];
Map map;
public PathFinder(Map map)
public PathFinder()
{
this.map = map;
for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++)
passableCost[(int)umt] = new float[128, 128];
for( int x = 0 ; x < 128 ; x++ )
for( int y = 0 ; y < 128 ; y++ )
for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++ )
passableCost[(int)umt][ x, y ] = ( map.IsInMap( x, y ) )
? (float)TerrainCosts.Cost( umt, Rules.TileSet.GetWalkability( map.MapTiles[ x, y ] ) )
passableCost[(int)umt][ x, y ] = ( Rules.Map.IsInMap( x, y ) )
? (float)TerrainCosts.Cost( umt, Rules.TileSet.GetWalkability( Rules.Map.MapTiles[ x, y ] ) )
: float.PositiveInfinity;
}