Merge pull request #7045 from Gishten/bleed

Closes #6989
This commit is contained in:
Matthias Mailänder
2014-12-06 20:54:50 +01:00
3 changed files with 17 additions and 12 deletions

View File

@@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA.Move
readonly IEnumerable<IDisableMove> moveDisablers; readonly IEnumerable<IDisableMove> moveDisablers;
readonly WRange nearEnough; readonly WRange nearEnough;
readonly Func<List<CPos>> getPath; readonly Func<List<CPos>> getPath;
readonly Actor ignoreBuilding; readonly Actor ignoredActor;
List<CPos> path; List<CPos> path;
CPos? destination; CPos? destination;
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.RA.Move
this.nearEnough = nearEnough; this.nearEnough = nearEnough;
} }
public Move(Actor self, CPos destination, Actor ignoreBuilding) public Move(Actor self, CPos destination, Actor ignoredActor)
{ {
mobile = self.Trait<Mobile>(); mobile = self.Trait<Mobile>();
moveDisablers = self.TraitsImplementing<IDisableMove>(); moveDisablers = self.TraitsImplementing<IDisableMove>();
@@ -85,11 +85,11 @@ namespace OpenRA.Mods.RA.Move
getPath = () => getPath = () =>
self.World.WorldActor.Trait<PathFinder>().FindPath( self.World.WorldActor.Trait<PathFinder>().FindPath(
PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false) PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false)
.WithIgnoredBuilding(ignoreBuilding)); .WithIgnoredActor(ignoredActor));
this.destination = destination; this.destination = destination;
this.nearEnough = WRange.Zero; this.nearEnough = WRange.Zero;
this.ignoreBuilding = ignoreBuilding; this.ignoredActor = ignoredActor;
} }
public Move(Actor self, Target target, WRange range) public Move(Actor self, Target target, WRange range)
@@ -219,7 +219,7 @@ namespace OpenRA.Mods.RA.Move
var nextCell = path[path.Count - 1]; var nextCell = path[path.Count - 1];
// Next cell in the move is blocked by another actor // Next cell in the move is blocked by another actor
if (!mobile.CanEnterCell(nextCell, ignoreBuilding, true)) if (!mobile.CanEnterCell(nextCell, ignoredActor, true))
{ {
// Are we close enough? // Are we close enough?
var cellRange = nearEnough.Range / 1024; var cellRange = nearEnough.Range / 1024;
@@ -268,7 +268,7 @@ namespace OpenRA.Mods.RA.Move
hasWaited = false; hasWaited = false;
path.RemoveAt(path.Count - 1); path.RemoveAt(path.Count - 1);
var subCell = mobile.GetAvailableSubCell(nextCell, SubCell.Any, ignoreBuilding); var subCell = mobile.GetAvailableSubCell(nextCell, SubCell.Any, ignoredActor);
return Pair.New(nextCell, subCell); return Pair.New(nextCell, subCell);
} }

View File

@@ -69,9 +69,14 @@ namespace OpenRA.Mods.RA.Move
return emptyPath; return emptyPath;
} }
var fromPoint = PathSearch.FromPoint(world, mi, self, target, from, true)
.WithIgnoredActor(self);
var fromPointReverse = PathSearch.FromPoint(world, mi, self, from, target, true)
.WithIgnoredActor(self)
.Reverse();
var pb = FindBidiPath( var pb = FindBidiPath(
PathSearch.FromPoint(world, mi, self, target, from, true), fromPoint,
PathSearch.FromPoint(world, mi, self, from, target, true).Reverse() fromPointReverse
); );
CheckSanePath2(pb, from, target); CheckSanePath2(pb, from, target);

View File

@@ -23,7 +23,7 @@ namespace OpenRA.Mods.RA.Move
public PriorityQueue<PathDistance> Queue; public PriorityQueue<PathDistance> Queue;
public Func<CPos, int> Heuristic; public Func<CPos, int> Heuristic;
public bool CheckForBlocked; public bool CheckForBlocked;
public Actor IgnoreBuilding; public Actor IgnoredActor;
public bool InReverse; public bool InReverse;
public HashSet<CPos> Considered; public HashSet<CPos> Considered;
public Player Owner { get { return self.Owner; } } public Player Owner { get { return self.Owner; } }
@@ -108,9 +108,9 @@ namespace OpenRA.Mods.RA.Move
return this; return this;
} }
public PathSearch WithIgnoredBuilding(Actor b) public PathSearch WithIgnoredActor(Actor b)
{ {
IgnoreBuilding = b; IgnoredActor = b;
return this; return this;
} }
@@ -215,7 +215,7 @@ namespace OpenRA.Mods.RA.Move
if (costHere == int.MaxValue) if (costHere == int.MaxValue)
continue; continue;
if (!mobileInfo.CanEnterCell(world, self, newHere, IgnoreBuilding, CheckForBlocked ? CellConditions.TransientActors : CellConditions.None)) if (!mobileInfo.CanEnterCell(world, self, newHere, IgnoredActor, CheckForBlocked ? CellConditions.TransientActors : CellConditions.None))
continue; continue;
if (customBlock != null && customBlock(newHere)) if (customBlock != null && customBlock(newHere))