IsBlocked slightly nicer

This commit is contained in:
Chris Forbes
2009-11-07 13:54:44 +13:00
parent 701adda6f3
commit 2c545466ee

View File

@@ -54,11 +54,8 @@ namespace OpenRa.Game
return path; return path;
} }
public List<int2> FindPathToPath( int2 from, List<int2> path, UnitMovementType umt ) bool IsBlocked(int2 from, UnitMovementType umt)
{ {
using (new PerfSample("find_path_to_path"))
{
var anyMovePossible = false;
for (int v = -1; v < 2; v++) for (int v = -1; v < 2; v++)
for (int u = -1; u < 2; u++) for (int u = -1; u < 2; u++)
if (u != 0 || v != 0) if (u != 0 || v != 0)
@@ -66,10 +63,16 @@ namespace OpenRa.Game
var p = from + new int2(u, v); var p = from + new int2(u, v);
if (passableCost[(int)umt][from.X + u, from.Y + v] < float.PositiveInfinity) if (passableCost[(int)umt][from.X + u, from.Y + v] < float.PositiveInfinity)
if (Game.BuildingInfluence.CanMoveHere(p) && (Game.UnitInfluence.GetUnitAt(p) == null)) if (Game.BuildingInfluence.CanMoveHere(p) && (Game.UnitInfluence.GetUnitAt(p) == null))
anyMovePossible = true; return false;
}
return true;
} }
if (!anyMovePossible) public List<int2> FindPathToPath( int2 from, List<int2> path, UnitMovementType umt )
{
using (new PerfSample("find_path_to_path"))
{
if (IsBlocked(from, umt))
return new List<int2>(); return new List<int2>();
CellInfo[,] cellInfo = null; CellInfo[,] cellInfo = null;