repath just by pathing again; more sanity checking of simple paths

This commit is contained in:
Chris Forbes
2009-11-08 20:54:24 +13:00
parent f22170800a
commit 55adc19aa9
3 changed files with 50 additions and 36 deletions

View File

@@ -72,26 +72,19 @@ namespace OpenRa.Game.Traits.Activities
void PlanMoreHarvesting(Actor self, Mobile mobile)
{
/* find a nearby patch */
/* todo: add the queries we need to support this! */
var search = new PathSearch
{
heuristic = loc => ( Game.map.ContainsResource( loc ) ? 0 : 1 ),
umt = UnitMovementType.Wheel,
checkForBlocked = true
};
search.AddInitialCell( self.Location );
var path = Game.PathFinder.FindPath( search )
.TakeWhile( a => a != self.Location )
.ToList();
if( path.Count != 0 )
{
mobile.QueueActivity( new Move( path ) );
mobile.QueueActivity( new Harvest() );
}
mobile.QueueActivity(new Move(
() =>
{
var search = new PathSearch
{
heuristic = loc => (Game.map.ContainsResource(loc) ? 0 : 1),
umt = UnitMovementType.Wheel,
checkForBlocked = true
};
search.AddInitialCell(self.Location);
return Game.PathFinder.FindPath(search);
}));
mobile.QueueActivity(new Harvest());
mobile.InternalSetActivity( NextActivity );
}