From c7d9d9613ec208c558f61d5283847592a0608bba Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 1 Dec 2018 11:59:58 +0000 Subject: [PATCH] Remove Order.TargetLocation from Harvester. --- .../Traits/BotModules/HarvesterBotModule.cs | 8 ++++---- OpenRA.Mods.Common/Traits/Harvester.cs | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs index b2d18f1bcb..066db61c5d 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/HarvesterBotModule.cs @@ -124,7 +124,7 @@ namespace OpenRA.Mods.Common.Traits // Tell the idle harvester to quit slacking: var newSafeResourcePatch = FindNextResource(h.Key, h.Value); AIUtils.BotDebug("AI: Harvester {0} is idle. Ordering to {1} in search for new resources.".F(h.Key, newSafeResourcePatch)); - bot.QueueOrder(new Order("Harvest", h.Key, Target.FromCell(world, newSafeResourcePatch), false)); + bot.QueueOrder(new Order("Harvest", h.Key, newSafeResourcePatch, false)); } // Less harvesters than refineries - build a new harvester @@ -138,7 +138,7 @@ namespace OpenRA.Mods.Common.Traits } } - CPos FindNextResource(Actor actor, HarvesterTraitWrapper harv) + Target FindNextResource(Actor actor, HarvesterTraitWrapper harv) { Func isValidResource = cell => domainIndex.IsPassable(actor.Location, cell, harv.LocomotorInfo) && @@ -153,9 +153,9 @@ namespace OpenRA.Mods.Common.Traits .FromPoint(actor.Location)); if (path.Count == 0) - return CPos.Zero; + return Target.Invalid; - return path[0]; + return Target.FromCell(world, path[0]); } } } diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index 06a2cbfede..edeff8f50d 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -391,11 +391,12 @@ namespace OpenRA.Mods.Common.Traits self.CancelActivity(); - CPos? loc; - if (order.TargetLocation != CPos.Zero) + CPos loc; + if (order.Target.Type != TargetType.Invalid) { // Find the nearest claimable cell to the order location (useful for group-select harvest): - loc = mobile.NearestCell(order.TargetLocation, p => mobile.CanEnterCell(p) && claimLayer.TryClaimCell(self, p), 1, 6); + var cell = self.World.Map.CellContaining(order.Target.CenterPosition); + loc = mobile.NearestCell(cell, p => mobile.CanEnterCell(p) && claimLayer.TryClaimCell(self, p), 1, 6); } else { @@ -403,7 +404,7 @@ namespace OpenRA.Mods.Common.Traits loc = self.Location; } - self.SetTargetLine(Target.FromCell(self.World, loc.Value), Color.Red); + self.SetTargetLine(Target.FromCell(self.World, loc), Color.Red); // FindResources takes care of calling INotifyHarvesterAction self.QueueActivity(new FindResources(self));