diff --git a/OpenRA.Mods.RA/Activities/Harvest.cs b/OpenRA.Mods.RA/Activities/Harvest.cs index fd0728f6e8..f21ea30603 100755 --- a/OpenRA.Mods.RA/Activities/Harvest.cs +++ b/OpenRA.Mods.RA/Activities/Harvest.cs @@ -31,7 +31,7 @@ namespace OpenRA.Mods.RA.Activities var mobile = self.Trait(); var mobileInfo = self.Info.Traits.Get(); var res = self.World.WorldActor.Trait(); - var path = self.World.WorldActor.Trait().FindPath(PathSearch.Search(self.World, mobileInfo, true) + var path = self.World.WorldActor.Trait().FindPath(PathSearch.Search(self.World, mobileInfo, self.Owner, true) .WithHeuristic(loc => (res.GetResource(loc) != null && harvInfo.Resources.Contains( res.GetResource(loc).info.Name )) ? 0 : 1) .FromPoint(self.Location)); diff --git a/OpenRA.Mods.RA/Activities/MoveAdjacentTo.cs b/OpenRA.Mods.RA/Activities/MoveAdjacentTo.cs index 5a05037a9c..0294408ba0 100755 --- a/OpenRA.Mods.RA/Activities/MoveAdjacentTo.cs +++ b/OpenRA.Mods.RA/Activities/MoveAdjacentTo.cs @@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Activities cells = new OpenRA.FileFormats.Pair[] { Pair.New(target.Location, SubCell.FullCell) }; - var ps1 = new PathSearch( self.World, mobile.Info ) + var ps1 = new PathSearch( self.World, mobile.Info, self.Owner ) { checkForBlocked = true, heuristic = location => 0, @@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA.Activities } ps1.heuristic = PathSearch.DefaultEstimator( mobile.toCell ); - var ps2 = PathSearch.FromPoint( self.World, mobile.Info, mobile.toCell, target.Location, true ); + var ps2 = PathSearch.FromPoint( self.World, mobile.Info, self.Owner, mobile.toCell, target.Location, true ); var ret = self.World.WorldActor.Trait().FindBidiPath( ps1, ps2 ); if( ret.Count > 0 ) ret.RemoveAt( 0 ); diff --git a/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs b/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs index df63f35753..0d42e55957 100644 --- a/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs @@ -63,7 +63,7 @@ namespace OpenRA.Mods.RA.Crates var mi = Rules.Info[Info.Unit].Traits.GetOrDefault(); for (var i = -1; i < 2; i++) for (var j = -1; j < 2; j++) - if (mi.CanEnterCell(self.World, near + new int2(i, j), null, true)) + if (mi.CanEnterCell(self.World, self.Owner, near + new int2(i, j), null, true)) yield return near + new int2(i, j); } diff --git a/OpenRA.Mods.RA/Harvester.cs b/OpenRA.Mods.RA/Harvester.cs index 2df3b0c3a0..7269964234 100644 --- a/OpenRA.Mods.RA/Harvester.cs +++ b/OpenRA.Mods.RA/Harvester.cs @@ -75,7 +75,7 @@ namespace OpenRA.Mods.RA .ToList(); var mi = self.Info.Traits.Get(); var path = self.World.WorldActor.Trait().FindPath( - PathSearch.FromPoints(self.World, mi, + PathSearch.FromPoints(self.World, mi, self.Owner, refs.Select(r => r.Actor.Location + r.Trait.DeliverOffset), self.Location, false)); path.Reverse(); diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index e176317e04..d27c9e2cc0 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -75,7 +75,7 @@ namespace OpenRA.Mods.RA.Move {SubCell.FullCell, new int2(0,0)}, }; - public bool CanEnterCell(World world, int2 cell, Actor ignoreActor, bool checkTransientActors) + public bool CanEnterCell(World world, Player owner, int2 cell, Actor ignoreActor, bool checkTransientActors) { if (MovementCostForCell(world, cell) == int.MaxValue) return false; @@ -326,7 +326,7 @@ namespace OpenRA.Mods.RA.Move public bool CanEnterCell(int2 cell, Actor ignoreActor, bool checkTransientActors) { - return Info.CanEnterCell(self.World, cell, ignoreActor, checkTransientActors); + return Info.CanEnterCell(self.World, self.Owner, cell, ignoreActor, checkTransientActors); } public void FinishedMoving(Actor self) diff --git a/OpenRA.Mods.RA/Move/Move.cs b/OpenRA.Mods.RA/Move/Move.cs index c1bfd31f34..d67ccfef8a 100755 --- a/OpenRA.Mods.RA/Move/Move.cs +++ b/OpenRA.Mods.RA/Move/Move.cs @@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Move { this.getPath = (self,mobile) => self.World.WorldActor.Trait().FindPath( - PathSearch.FromPoint( self.World, mobile.Info, mobile.toCell, destination, false ) + PathSearch.FromPoint( self.World, mobile.Info, self.Owner, mobile.toCell, destination, false ) .WithoutLaneBias()); this.destination = destination; this.nearEnough = 0; @@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA.Move { this.getPath = (self,mobile) => self.World.WorldActor.Trait().FindPath( - PathSearch.FromPoint( self.World, mobile.Info, mobile.toCell, destination, false ) + PathSearch.FromPoint( self.World, mobile.Info, self.Owner, mobile.toCell, destination, false ) .WithIgnoredBuilding( ignoreBuilding )); this.destination = destination; diff --git a/OpenRA.Mods.RA/Move/PathFinder.cs b/OpenRA.Mods.RA/Move/PathFinder.cs index 633e3c7a47..b9bfc6ade0 100755 --- a/OpenRA.Mods.RA/Move/PathFinder.cs +++ b/OpenRA.Mods.RA/Move/PathFinder.cs @@ -54,8 +54,8 @@ namespace OpenRA.Mods.RA.Move var mi = self.Info.Traits.Get(); var pb = FindBidiPath( - PathSearch.FromPoint(world, mi, target, from, true), - PathSearch.FromPoint(world, mi, from, target, true) + PathSearch.FromPoint(world, mi, self.Owner, target, from, true), + PathSearch.FromPoint(world, mi, self.Owner, from, target, true) .InReverse()); CheckSanePath2(pb, from, target); @@ -72,11 +72,11 @@ namespace OpenRA.Mods.RA.Move { var mi = self.Info.Traits.Get(); var tilesInRange = world.FindTilesInCircle(target, range) - .Where( t => mi.CanEnterCell(self.World, t, null, true)); + .Where( t => mi.CanEnterCell(self.World, self.Owner, t, null, true)); var path = FindBidiPath( - PathSearch.FromPoints(world, mi, tilesInRange, src, true), - PathSearch.FromPoint(world, mi, src, target, true) + PathSearch.FromPoints(world, mi, self.Owner, tilesInRange, src, true), + PathSearch.FromPoint(world, mi, self.Owner, src, target, true) .InReverse()); return path; diff --git a/OpenRA.Mods.RA/Move/PathSearch.cs b/OpenRA.Mods.RA/Move/PathSearch.cs index da1d3201f9..1d21c18991 100755 --- a/OpenRA.Mods.RA/Move/PathSearch.cs +++ b/OpenRA.Mods.RA/Move/PathSearch.cs @@ -27,12 +27,14 @@ namespace OpenRA.Mods.RA.Move public bool inReverse; MobileInfo mobileInfo; + Player owner; - public PathSearch(World world, MobileInfo mobileInfo) + public PathSearch(World world, MobileInfo mobileInfo, Player owner) { this.world = world; cellInfo = InitCellInfo(); this.mobileInfo = mobileInfo; + this.owner = owner; queue = new PriorityQueue(); } @@ -103,7 +105,7 @@ namespace OpenRA.Mods.RA.Move if (costHere == int.MaxValue) continue; - if (!mobileInfo.CanEnterCell(world, newHere, ignoreBuilding, checkForBlocked)) + if (!mobileInfo.CanEnterCell(world, owner, newHere, ignoreBuilding, checkForBlocked)) continue; if (customBlock != null && customBlock(newHere)) @@ -160,16 +162,16 @@ namespace OpenRA.Mods.RA.Move queue.Add( new PathDistance( heuristic( location ), location ) ); } - public static PathSearch Search( World world, MobileInfo mi, bool checkForBlocked ) + public static PathSearch Search( World world, MobileInfo mi, Player owner, bool checkForBlocked ) { - var search = new PathSearch(world, mi) { + var search = new PathSearch(world, mi, owner) { checkForBlocked = checkForBlocked }; return search; } - public static PathSearch FromPoint( World world, MobileInfo mi, int2 from, int2 target, bool checkForBlocked ) + public static PathSearch FromPoint( World world, MobileInfo mi, Player owner, int2 from, int2 target, bool checkForBlocked ) { - var search = new PathSearch(world, mi) { + var search = new PathSearch(world, mi, owner) { heuristic = DefaultEstimator( target ), checkForBlocked = checkForBlocked }; @@ -177,9 +179,9 @@ namespace OpenRA.Mods.RA.Move return search; } - public static PathSearch FromPoints(World world, MobileInfo mi, IEnumerable froms, int2 target, bool checkForBlocked) + public static PathSearch FromPoints(World world, MobileInfo mi, Player owner, IEnumerable froms, int2 target, bool checkForBlocked) { - var search = new PathSearch(world, mi) + var search = new PathSearch(world, mi, owner) { heuristic = DefaultEstimator(target), checkForBlocked = checkForBlocked diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index 9671a2af86..aee456a973 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -124,7 +124,7 @@ namespace OpenRA.Mods.RA var mobileInfo = producee.Traits.GetOrDefault(); return mobileInfo == null || - mobileInfo.CanEnterCell(self.World, self.Location + s.ExitCell, self, true); + mobileInfo.CanEnterCell(self.World, self.Owner, self.Location + s.ExitCell, self, true); } } }