harvester empties; first stage of fixing BIM behavior

This commit is contained in:
Chris Forbes
2009-11-04 21:03:56 +13:00
parent 0d2b7eb855
commit 43170cc318
5 changed files with 26 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ namespace OpenRa.Game
{
class BuildingInfluenceMap
{
bool[,] blocked = new bool[128, 128];
Pair<Actor, float>[,] influence = new Pair<Actor, float>[128, 128];
readonly int maxDistance; /* clip limit for voronoi cells */
static readonly Pair<Actor, float> NoClaim = Pair.New((Actor)null, float.MaxValue);
@@ -41,6 +42,10 @@ namespace OpenRa.Game
var initialTileCount = 0;
foreach (var u in Footprint.UnpathableTiles(a.unitInfo, a.Location))
if (IsValid(u))
blocked[u.X, u.Y] = true;
foreach (var t in tiles)
if (IsValid(t))
{
@@ -103,6 +108,10 @@ namespace OpenRa.Game
tiles.Aggregate(int2.Min) - new int2(maxDistance, maxDistance));
var max = int2.Min(new int2(128, 128),
tiles.Aggregate(int2.Max) + new int2(maxDistance, maxDistance));
foreach (var u in Footprint.UnpathableTiles(a.unitInfo, a.Location))
if (IsValid(u))
blocked[u.X, u.Y] = false;
for (var j = min.Y; j <= max.Y; j++)
for (var i = min.X; i <= max.X; i++)
@@ -149,6 +158,11 @@ namespace OpenRa.Game
return (int)influence[cell.X, cell.Y].Second;
}
public bool CanMoveHere(int2 cell)
{
return IsValid(cell) && !blocked[cell.X, cell.Y];
}
struct Cell : IComparable<Cell>
{
public int2 location;