From 8e602104afda1ea0b9a349a86c472ccb595814d3 Mon Sep 17 00:00:00 2001 From: James Dunne Date: Wed, 27 Jun 2012 18:00:42 -0500 Subject: [PATCH] Harvesters - made search radius configurable for both initial search from proc and search from harvest location. --- OpenRA.Mods.RA/Activities/FindResources.cs | 9 +++++++-- OpenRA.Mods.RA/Harvester.cs | 8 ++++++++ mods/cnc/rules/vehicles.yaml | 4 ++++ mods/d2k/rules/vehicles.yaml | 4 ++++ mods/ra/rules/vehicles.yaml | 4 ++++ 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Activities/FindResources.cs b/OpenRA.Mods.RA/Activities/FindResources.cs index 220ab71da0..4f8bd88a34 100755 --- a/OpenRA.Mods.RA/Activities/FindResources.cs +++ b/OpenRA.Mods.RA/Activities/FindResources.cs @@ -46,6 +46,11 @@ namespace OpenRA.Mods.RA.Activities var resLayer = self.World.WorldActor.Trait(); var territory = self.World.WorldActor.TraitOrDefault(); + // Determine where to search from and how far to search: + var searchFromLoc = harv.LastOrderLocation ?? harv.LinkedProc.Location; + int searchRadius = harv.LastOrderLocation.HasValue ? harvInfo.SearchFromOrderRadius : harvInfo.SearchFromProcRadius; + int searchRadiusSquared = searchRadius * searchRadius; + // Find harvestable resources nearby: var path = self.World.WorldActor.Trait().FindPath( PathSearch.Search(self.World, mobileInfo, self.Owner, true) @@ -68,8 +73,8 @@ namespace OpenRA.Mods.RA.Activities if (avoidCell.HasValue && loc == avoidCell.Value) return 1; // Don't harvest out of range: - int distSquared = (loc - (harv.LastOrderLocation ?? harv.LinkedProc.Location)).LengthSquared; - if (distSquared > (12 * 12)) + int distSquared = (loc - searchFromLoc).LengthSquared; + if (distSquared > searchRadiusSquared) return int.MaxValue; // Get the resource at this location: diff --git a/OpenRA.Mods.RA/Harvester.cs b/OpenRA.Mods.RA/Harvester.cs index cb12f4922e..20ff2da840 100644 --- a/OpenRA.Mods.RA/Harvester.cs +++ b/OpenRA.Mods.RA/Harvester.cs @@ -25,6 +25,14 @@ namespace OpenRA.Mods.RA public readonly int PipCount = 7; public readonly string[] Resources = { }; public readonly decimal FullyLoadedSpeed = .85m; + /// + /// Initial search radius (in cells) from the refinery (proc) that created us. + /// + public readonly int SearchFromProcRadius = 24; + /// + /// Search radius (in cells) from the last harvest order location to find more resources. + /// + public readonly int SearchFromOrderRadius = 12; public object Create(ActorInitializer init) { return new Harvester(init.self, this); } } diff --git a/mods/cnc/rules/vehicles.yaml b/mods/cnc/rules/vehicles.yaml index 703ff87418..1748d2eb5d 100644 --- a/mods/cnc/rules/vehicles.yaml +++ b/mods/cnc/rules/vehicles.yaml @@ -55,6 +55,10 @@ HARV: Resources: Tiberium, Blue Tiberium PipCount: 5 Capacity: 15 + # How far away from our linked proc (refinery) to find resources (in cells): + SearchFromProcRadius: 24 + # How far away from last harvest order location to find more resources (in cells): + SearchFromOrderRadius: 12 Mobile: Speed: 6 Health: diff --git a/mods/d2k/rules/vehicles.yaml b/mods/d2k/rules/vehicles.yaml index c742a6ec44..d1c0b7934f 100644 --- a/mods/d2k/rules/vehicles.yaml +++ b/mods/d2k/rules/vehicles.yaml @@ -46,6 +46,10 @@ HARVESTER: Capacity: 20 Resources: Spice UnloadTicksPerBale: 1 + # How far away from our linked proc (refinery) to find resources (in cells): + SearchFromProcRadius: 24 + # How far away from last harvest order location to find more resources (in cells): + SearchFromOrderRadius: 12 Health: HP: 600 Armor: diff --git a/mods/ra/rules/vehicles.yaml b/mods/ra/rules/vehicles.yaml index 191c0b9f78..fb0e0031f0 100644 --- a/mods/ra/rules/vehicles.yaml +++ b/mods/ra/rules/vehicles.yaml @@ -228,6 +228,10 @@ HARV: Capacity: 20 Resources: Ore,Gems UnloadTicksPerBale: 1 + # How far away from our linked proc (refinery) to find resources (in cells): + SearchFromProcRadius: 24 + # How far away from last harvest order location to find more resources (in cells): + SearchFromOrderRadius: 12 Health: HP: 600 Armor: