added building influence to pathfinder

This commit is contained in:
Chris Forbes
2009-10-13 18:21:57 +13:00
parent 24a6c798fa
commit c6e739d162
2 changed files with 10 additions and 6 deletions

View File

@@ -45,12 +45,12 @@ namespace OpenRa.Game
foreach( TreeReference treeReference in map.Trees )
world.Add( new Actor( treeReference, treeCache, map.Offset ) );
pathFinder = new PathFinder(map, terrain.tileSet);
LocalPlayerBuildings = new BuildingInfluenceMap(world, LocalPlayer);
pathFinder = new PathFinder(map, terrain.tileSet, LocalPlayerBuildings);
network = new Network();
LocalPlayerBuildings = new BuildingInfluenceMap(world, LocalPlayer);
controller = new Controller(this); // CAREFUL THERES AN UGLY HIDDEN DEPENDENCY HERE STILL
worldRenderer = new WorldRenderer(renderer, this);
}

View File

@@ -9,10 +9,12 @@ namespace OpenRa.Game
{
double[ , ] passableCost = new double[ 128, 128 ];
Map map;
BuildingInfluenceMap bim;
public PathFinder(Map map, TileSet tileSet)
public PathFinder(Map map, TileSet tileSet, BuildingInfluenceMap bim)
{
this.map = map;
this.bim = bim;
for( int x = 0 ; x < 128 ; x++ )
for( int y = 0 ; y < 128 ; y++ )
@@ -59,6 +61,8 @@ namespace OpenRa.Game
continue;
if( passableCost[ newHere.X, newHere.Y ] == double.PositiveInfinity )
continue;
if (bim[newHere - offset] != null)
continue;
double cellCost = ( ( d.X * d.Y != 0 ) ? 1.414213563 : 1.0 ) * passableCost[ newHere.X, newHere.Y ];
double newCost = cellInfo[ here.X, here.Y ].MinCost + cellCost;