From 3d47584cd8df01e191620748137e3bd613a575b8 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 27 Dec 2010 15:33:59 +1300 Subject: [PATCH] use bidi pathing for moving into range (MoveToAdjacent-style hack) --- OpenRA.Mods.RA/Move/PathFinder.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/OpenRA.Mods.RA/Move/PathFinder.cs b/OpenRA.Mods.RA/Move/PathFinder.cs index 59035f05b0..2c85293dab 100755 --- a/OpenRA.Mods.RA/Move/PathFinder.cs +++ b/OpenRA.Mods.RA/Move/PathFinder.cs @@ -72,15 +72,18 @@ namespace OpenRA.Mods.RA.Move { using( new PerfSample( "Pathfinder" ) ) { - var mobileInfo = self.Info.Traits.Get(); + var mi = self.Info.Traits.Get(); var tilesInRange = world.FindTilesInCircle(target, range) - .Where( t => Mobile.CanEnterCell(self.World, mobileInfo, t, null, true)); + .Where( t => Mobile.CanEnterCell(self.World, mi, t, null, true)); - var path = FindPath( PathSearch.FromPoints( world, mobileInfo, tilesInRange, src, false ) - .WithCustomBlocker(AvoidUnitsNear(src, 4, self)) - .InReverse()); - path.Reverse(); - return path; + var path = FindBidiPath( + PathSearch.FromPoints(world, mi, tilesInRange, src, true) + .WithCustomBlocker(AvoidUnitsNear(src, 4, self)), + PathSearch.FromPoint(world, mi, src, target, true) + .WithCustomBlocker(AvoidUnitsNear(src, 4, self)) + .InReverse()); + + return path; } }