Factor out the CVec direction list.

This commit is contained in:
i80and
2013-05-27 10:41:50 -05:00
committed by Andrew Aldridge
parent 3b6ab58940
commit 1fe2418e22
2 changed files with 13 additions and 13 deletions

View File

@@ -73,5 +73,17 @@ namespace OpenRA
} }
public override string ToString() { return "{0},{1}".F(X, Y); } public override string ToString() { return "{0},{1}".F(X, Y); }
public static readonly CVec[] directions =
{
new CVec(-1, -1),
new CVec(-1, 0),
new CVec(-1, 1),
new CVec(0, -1),
new CVec(0, 1),
new CVec(1, -1),
new CVec(1, 0),
new CVec(1, 1),
};
} }
} }

View File

@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Move
queue = new PriorityQueue<PathDistance>(); queue = new PriorityQueue<PathDistance>();
considered = new HashSet<CPos>(); considered = new HashSet<CPos>();
maxCost = 0; maxCost = 0;
nextDirections = directions.Select(d => new Pair<CVec, int>(d, 0)).ToArray(); nextDirections = CVec.directions.Select(d => new Pair<CVec, int>(d, 0)).ToArray();
} }
public PathSearch InReverse() public PathSearch InReverse()
@@ -190,18 +190,6 @@ namespace OpenRA.Mods.RA.Move
return p.Location; return p.Location;
} }
static readonly CVec[] directions =
{
new CVec( -1, -1 ),
new CVec( -1, 0 ),
new CVec( -1, 1 ),
new CVec( 0, -1 ),
new CVec( 0, 1 ),
new CVec( 1, -1 ),
new CVec( 1, 0 ),
new CVec( 1, 1 ),
};
public void AddInitialCell(CPos location) public void AddInitialCell(CPos location)
{ {
if (!world.Map.IsInMap(location.X, location.Y)) if (!world.Map.IsInMap(location.X, location.Y))