can build again

This commit is contained in:
Chris Forbes
2009-11-18 19:16:06 +13:00
parent fe11e5431c
commit 25e1d9a0a1
4 changed files with 45 additions and 26 deletions

View File

@@ -15,6 +15,7 @@ namespace OpenRa.Game
public UnitMovementType umt;
Func<int2, bool> customBlock;
public bool checkForBlocked;
public bool ignoreTerrain;
public PathSearch()
{
@@ -39,22 +40,31 @@ namespace OpenRa.Game
if( cellInfo[ newHere.X, newHere.Y ].Seen )
continue;
if( passableCost[ (int)umt ][ newHere.X, newHere.Y ] == float.PositiveInfinity )
continue;
if( !Game.BuildingInfluence.CanMoveHere( newHere ) )
continue;
if (ignoreTerrain)
{
if (!Game.map.IsInMap(newHere.X, newHere.Y)) continue;
}
else
{
if (passableCost[(int)umt][newHere.X, newHere.Y] == float.PositiveInfinity)
continue;
if (!Game.BuildingInfluence.CanMoveHere(newHere))
continue;
if (Game.map.IsOverlaySolid(newHere))
continue;
}
if( checkForBlocked && Game.UnitInfluence.GetUnitAt( newHere ) != null )
continue;
if (customBlock != null && customBlock(newHere))
continue;
if (Game.map.IsOverlaySolid(newHere))
continue;
var est = heuristic( newHere );
if( est == float.PositiveInfinity )
continue;
float cellCost = ( ( d.X * d.Y != 0 ) ? 1.414213563f : 1.0f ) * passableCost[ (int)umt ][ newHere.X, newHere.Y ];
float cellCost = ( ( d.X * d.Y != 0 ) ? 1.414213563f : 1.0f ) *
(ignoreTerrain ? 1 : passableCost[ (int)umt ][ newHere.X, newHere.Y ]);
float newCost = cellInfo[ p.Location.X, p.Location.Y ].MinCost + cellCost;
if( newCost >= cellInfo[ newHere.X, newHere.Y ].MinCost )