diff --git a/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs b/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs index 6d83ec0765..02c231e9a9 100644 --- a/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs +++ b/OpenRA.Mods.Common/Activities/FindAndDeliverResources.cs @@ -25,7 +25,6 @@ namespace OpenRA.Mods.Common.Activities readonly HarvesterInfo harvInfo; readonly Mobile mobile; readonly ResourceClaimLayer claimLayer; - readonly IPathFinder pathFinder; readonly DomainIndex domainIndex; Actor deliverActor; @@ -43,7 +42,6 @@ namespace OpenRA.Mods.Common.Activities harvInfo = self.Info.TraitInfo(); mobile = self.Trait(); claimLayer = self.World.WorldActor.Trait(); - pathFinder = self.World.WorldActor.Trait(); domainIndex = self.World.WorldActor.Trait(); this.deliverActor = deliverActor; } @@ -218,7 +216,7 @@ namespace OpenRA.Mods.Common.Activities }) .FromPoint(searchFromLoc) .FromPoint(self.Location)) - path = pathFinder.FindPath(search); + path = mobile.Pathfinder.FindPath(search); if (path.Count > 0) return path[0]; diff --git a/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs b/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs index 70df3029b9..89ac58e308 100644 --- a/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs +++ b/OpenRA.Mods.Common/Activities/Move/MoveAdjacentTo.cs @@ -24,7 +24,6 @@ namespace OpenRA.Mods.Common.Activities static readonly List NoPath = new List(); protected readonly Mobile Mobile; - readonly IPathFinder pathFinder; readonly DomainIndex domainIndex; readonly Color? targetLineColor; @@ -40,7 +39,6 @@ namespace OpenRA.Mods.Common.Activities this.target = target; this.targetLineColor = targetLineColor; Mobile = self.Trait(); - pathFinder = self.World.WorldActor.Trait(); domainIndex = self.World.WorldActor.Trait(); ChildHasPriority = false; @@ -136,7 +134,7 @@ namespace OpenRA.Mods.Common.Activities using (var fromSrc = PathSearch.FromPoints(self.World, Mobile.Locomotor, self, searchCells, loc, check)) using (var fromDest = PathSearch.FromPoint(self.World, Mobile.Locomotor, self, loc, lastVisibleTargetLocation, check).Reverse()) - return pathFinder.FindBidiPath(fromSrc, fromDest); + return Mobile.Pathfinder.FindBidiPath(fromSrc, fromDest); } public override IEnumerable GetTargets(Actor self) diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index 24e28d7006..72623d90e3 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -206,7 +206,7 @@ namespace OpenRA.Mods.Common.Traits // Prefer refineries with less occupancy (multiplier is to offset distance cost): return occupancy * Info.UnloadQueueCostModifier; })) - path = self.World.WorldActor.Trait().FindPath(search); + path = mobile.Pathfinder.FindPath(search); if (path.Count != 0) return refineries[path.Last()].First().Actor; diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index 9889bb19b5..b721be86a0 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -803,12 +803,11 @@ namespace OpenRA.Mods.Common.Traits if (CanEnterCell(above)) return above; - var pathFinder = self.World.WorldActor.Trait(); List path; using (var search = PathSearch.Search(self.World, Locomotor, self, BlockedByActor.All, loc => loc.Layer == 0 && CanEnterCell(loc)) .FromPoint(self.Location)) - path = pathFinder.FindPath(search); + path = Pathfinder.FindPath(search); if (path.Count > 0) return path[0];