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