Harvesters - made search radius configurable for both initial search from proc and search from harvest location.

This commit is contained in:
James Dunne
2012-06-27 18:00:42 -05:00
parent aac78773f4
commit 8e602104af
5 changed files with 27 additions and 2 deletions

View File

@@ -46,6 +46,11 @@ namespace OpenRA.Mods.RA.Activities
var resLayer = self.World.WorldActor.Trait<ResourceLayer>();
var territory = self.World.WorldActor.TraitOrDefault<ResourceClaimLayer>();
// 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<PathFinder>().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:

View File

@@ -25,6 +25,14 @@ namespace OpenRA.Mods.RA
public readonly int PipCount = 7;
public readonly string[] Resources = { };
public readonly decimal FullyLoadedSpeed = .85m;
/// <summary>
/// Initial search radius (in cells) from the refinery (proc) that created us.
/// </summary>
public readonly int SearchFromProcRadius = 24;
/// <summary>
/// Search radius (in cells) from the last harvest order location to find more resources.
/// </summary>
public readonly int SearchFromOrderRadius = 12;
public object Create(ActorInitializer init) { return new Harvester(init.self, this); }
}