oops. a slight pathfinder cock-up.
This commit is contained in:
@@ -37,7 +37,7 @@ namespace OpenRa.Game
|
||||
.Where(t => Game.IsCellBuildable(t, umt))
|
||||
.Select(t => t + map.Offset);
|
||||
|
||||
var path = FindUnitPath(tilesInRange, DefaultEstimator(dest), umt);
|
||||
var path = FindUnitPath(tilesInRange, DefaultEstimator(src), umt);
|
||||
path.Reverse();
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,13 @@ namespace OpenRa.Game.Traits
|
||||
}
|
||||
public override void Apply()
|
||||
{
|
||||
var mobile = Attacker.traits.GetOrDefault<Mobile>();
|
||||
if (mobile != null)
|
||||
{
|
||||
mobile.Cancel(Attacker);
|
||||
mobile.QueueActivity(new Mobile.MoveTo(Target, 3)); /* todo: get range properly */
|
||||
}
|
||||
|
||||
Attacker.traits.Get<AttackTurreted>().target = Target;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,16 +120,27 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
public CurrentActivity NextActivity { get; set; }
|
||||
|
||||
int2 destination;
|
||||
int2? destination;
|
||||
List<int2> path;
|
||||
Func<Actor, Mobile, List<int2>> getPath;
|
||||
|
||||
MovePart move;
|
||||
|
||||
public MoveTo( int2 destination )
|
||||
{
|
||||
this.getPath = (self, mobile) => Game.pathFinder.FindUnitPath(self.Location, destination,
|
||||
mobile.GetMovementType());
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
public MoveTo(Actor target, int range)
|
||||
{
|
||||
this.getPath = (self, mobile) => Game.pathFinder.FindUnitPathToRange(
|
||||
self.Location, target.Location,
|
||||
mobile.GetMovementType(), range);
|
||||
this.destination = null;
|
||||
}
|
||||
|
||||
static bool CanEnterCell(int2 c, Actor self)
|
||||
{
|
||||
var u = Game.UnitInfluence.GetUnitAt(c);
|
||||
@@ -150,13 +161,15 @@ namespace OpenRa.Game.Traits
|
||||
return;
|
||||
}
|
||||
|
||||
if( path == null )
|
||||
path = Game.pathFinder.FindUnitPath( self.Location, destination, mobile.GetMovementType() );
|
||||
if( path.Count == 0 )
|
||||
if( path == null ) path = getPath(self, mobile);
|
||||
|
||||
if (path.Count == 0)
|
||||
{
|
||||
destination = mobile.toCell;
|
||||
return;
|
||||
}
|
||||
else
|
||||
destination = path[0];
|
||||
|
||||
var nextCell = path[ path.Count - 1 ];
|
||||
int2 dir = nextCell - mobile.fromCell;
|
||||
|
||||
Reference in New Issue
Block a user