use new Enter activity for engy, spy, c4

This commit is contained in:
Bob
2010-10-21 20:58:07 +13:00
parent 8e4f5da791
commit 88a8d84153
10 changed files with 125 additions and 25 deletions

View File

@@ -40,7 +40,7 @@ namespace OpenRA
public List<int2> FindUnitPath(int2 from, int2 target, Actor self)
{
using (new PerfSample("find_unit_path"))
using (new PerfSample("Pathfinder"))
{
var cached = CachedPaths.FirstOrDefault(p => p.from == from && p.to == target && p.actor == self);
if (cached != null)
@@ -69,7 +69,7 @@ namespace OpenRA
public List<int2> FindUnitPathToRange( int2 src, int2 target, int range, Actor self )
{
using( new PerfSample( "find_unit_path_multiple_src" ) )
using( new PerfSample( "Pathfinder" ) )
{
var mobileInfo = self.Info.Traits.Get<MobileInfo>();
var tilesInRange = world.FindTilesInCircle(target, range)
@@ -93,7 +93,7 @@ namespace OpenRA
public List<int2> FindPath( PathSearch search )
{
//using (new PerfSample("find_path_inner"))
using (new PerfSample("Pathfinder"))
{
while (!search.queue.Empty)
{
@@ -127,26 +127,29 @@ namespace OpenRA
List<int2> FindBidiPath( /* searches from both ends toward each other */
public List<int2> FindBidiPath( /* searches from both ends toward each other */
PathSearch fromSrc,
PathSearch fromDest)
{
while (!fromSrc.queue.Empty && !fromDest.queue.Empty)
using (new PerfSample("Pathfinder"))
{
/* make some progress on the first search */
var p = fromSrc.Expand( world );
while (!fromSrc.queue.Empty && !fromDest.queue.Empty)
{
/* make some progress on the first search */
var p = fromSrc.Expand( world );
if (fromDest.cellInfo[p.X, p.Y].Seen && fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, p);
if (fromDest.cellInfo[p.X, p.Y].Seen && fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, p);
/* make some progress on the second search */
var q = fromDest.Expand( world );
/* make some progress on the second search */
var q = fromDest.Expand( world );
if (fromSrc.cellInfo[q.X, q.Y].Seen && fromSrc.cellInfo[q.X, q.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, q);
if (fromSrc.cellInfo[q.X, q.Y].Seen && fromSrc.cellInfo[q.X, q.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, q);
}
return new List<int2>();
}
return new List<int2>();
}
static List<int2> MakeBidiPath(PathSearch a, PathSearch b, int2 p)

View File

@@ -72,7 +72,7 @@ namespace OpenRA
public PathSearch FromPoint(int2 from)
{
AddInitialCell( world, from );
AddInitialCell( from );
return this;
}
@@ -155,7 +155,7 @@ namespace OpenRA
new int2( 1, 1 ),
};
public void AddInitialCell( World world, int2 location )
public void AddInitialCell( int2 location )
{
if (!world.Map.IsInMap(location.X, location.Y))
return;
@@ -177,7 +177,7 @@ namespace OpenRA
heuristic = DefaultEstimator( target ),
checkForBlocked = checkForBlocked };
search.AddInitialCell( world, from );
search.AddInitialCell( from );
return search;
}
@@ -189,8 +189,8 @@ namespace OpenRA
checkForBlocked = checkForBlocked
};
foreach (var sl in froms)
search.AddInitialCell(world, sl);
foreach( var sl in froms )
search.AddInitialCell( sl );
return search;
}