repath just by pathing again; more sanity checking of simple paths
This commit is contained in:
@@ -34,10 +34,11 @@ namespace OpenRa.Game.Traits.Activities
|
||||
this.nearEnough = range;
|
||||
}
|
||||
|
||||
public Move( List<int2> path )
|
||||
public Move(Func<List<int2>> getPath)
|
||||
{
|
||||
this.path = path;
|
||||
this.destination = path[ 0 ];
|
||||
this.getPath = (_, _2) => getPath();
|
||||
this.destination = null;
|
||||
this.nearEnough = 0;
|
||||
}
|
||||
|
||||
static bool CanEnterCell( int2 c, Actor self )
|
||||
@@ -114,17 +115,23 @@ namespace OpenRa.Game.Traits.Activities
|
||||
}
|
||||
|
||||
Game.UnitInfluence.Remove( mobile );
|
||||
var newPath = Game.PathFinder.FindPathToPath( self.Location, path, mobile.GetMovementType() )
|
||||
.TakeWhile( a => a != self.Location )
|
||||
.ToList();
|
||||
var newPath = getPath(self, mobile).TakeWhile(a => a != self.Location).ToList();
|
||||
//var newPath = Game.PathFinder.FindPathToPath( self.Location, path, mobile.GetMovementType() )
|
||||
// .TakeWhile( a => a != self.Location )
|
||||
// .ToList();
|
||||
Game.UnitInfluence.Add( mobile );
|
||||
if( newPath.Count == 0 )
|
||||
if (newPath.Count == 0)
|
||||
return null;
|
||||
else
|
||||
{
|
||||
path = newPath;
|
||||
return null;
|
||||
}
|
||||
|
||||
while( path.Count != 0 && path[ path.Count - 1 ] != newPath[ 0 ] )
|
||||
path.RemoveAt( path.Count - 1 );
|
||||
for( int i = 1 ; i < newPath.Count ; i++ )
|
||||
path.Add( newPath[ i ] );
|
||||
//while( path.Count != 0 && path[ path.Count - 1 ] != newPath[ 0 ] )
|
||||
// path.RemoveAt( path.Count - 1 );
|
||||
//for( int i = 1 ; i < newPath.Count ; i++ )
|
||||
// path.Add( newPath[ i ] );
|
||||
|
||||
if( path.Count == 0 )
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user