Rename variables for clarity.
This commit is contained in:
@@ -669,19 +669,19 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
FindAndDeployBackupMcv(self);
|
FindAndDeployBackupMcv(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPos FindNextResource(Actor self)
|
CPos FindNextResource(Actor harvester)
|
||||||
{
|
{
|
||||||
var harvInfo = self.Info.TraitInfo<HarvesterInfo>();
|
var harvInfo = harvester.Info.TraitInfo<HarvesterInfo>();
|
||||||
var mobileInfo = self.Info.TraitInfo<MobileInfo>();
|
var mobileInfo = harvester.Info.TraitInfo<MobileInfo>();
|
||||||
var passable = (uint)mobileInfo.GetMovementClass(World.TileSet);
|
var passable = (uint)mobileInfo.GetMovementClass(World.TileSet);
|
||||||
|
|
||||||
var path = pathfinder.FindPath(
|
var path = pathfinder.FindPath(
|
||||||
PathSearch.Search(World, mobileInfo, self, true,
|
PathSearch.Search(World, mobileInfo, harvester, true,
|
||||||
loc => domainIndex.IsPassable(self.Location, loc, passable) && self.CanHarvestAt(loc, resLayer, harvInfo, territory))
|
loc => domainIndex.IsPassable(harvester.Location, loc, passable) && harvester.CanHarvestAt(loc, resLayer, harvInfo, territory))
|
||||||
.WithCustomCost(loc => World.FindActorsInCircle(World.Map.CenterOfCell(loc), Info.HarvesterEnemyAvoidanceRadius)
|
.WithCustomCost(loc => World.FindActorsInCircle(World.Map.CenterOfCell(loc), Info.HarvesterEnemyAvoidanceRadius)
|
||||||
.Where(u => !u.IsDead && self.Owner.Stances[u.Owner] == Stance.Enemy)
|
.Where(u => !u.IsDead && harvester.Owner.Stances[u.Owner] == Stance.Enemy)
|
||||||
.Sum(u => Math.Max(WDist.Zero.Length, Info.HarvesterEnemyAvoidanceRadius.Length - (World.Map.CenterOfCell(loc) - u.CenterPosition).Length)))
|
.Sum(u => Math.Max(WDist.Zero.Length, Info.HarvesterEnemyAvoidanceRadius.Length - (World.Map.CenterOfCell(loc) - u.CenterPosition).Length)))
|
||||||
.FromPoint(self.Location));
|
.FromPoint(harvester.Location));
|
||||||
|
|
||||||
if (path.Count == 0)
|
if (path.Count == 0)
|
||||||
return CPos.Zero;
|
return CPos.Zero;
|
||||||
@@ -692,15 +692,15 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
void GiveOrdersToIdleHarvesters()
|
void GiveOrdersToIdleHarvesters()
|
||||||
{
|
{
|
||||||
// Find idle harvesters and give them orders:
|
// Find idle harvesters and give them orders:
|
||||||
foreach (var a in activeUnits)
|
foreach (var harvester in activeUnits)
|
||||||
{
|
{
|
||||||
var harv = a.TraitOrDefault<Harvester>();
|
var harv = harvester.TraitOrDefault<Harvester>();
|
||||||
if (harv == null)
|
if (harv == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!a.IsIdle)
|
if (!harvester.IsIdle)
|
||||||
{
|
{
|
||||||
var act = a.GetCurrentActivity();
|
var act = harvester.GetCurrentActivity();
|
||||||
|
|
||||||
// A Wait activity is technically idle:
|
// A Wait activity is technically idle:
|
||||||
if ((act.GetType() != typeof(Wait)) &&
|
if ((act.GetType() != typeof(Wait)) &&
|
||||||
@@ -712,9 +712,9 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Tell the idle harvester to quit slacking:
|
// Tell the idle harvester to quit slacking:
|
||||||
var newSafeResourcePatch = FindNextResource(a);
|
var newSafeResourcePatch = FindNextResource(harvester);
|
||||||
BotDebug("AI: Harvester {0} is idle. Ordering to {1} in search for new resources.".F(a, newSafeResourcePatch));
|
BotDebug("AI: Harvester {0} is idle. Ordering to {1} in search for new resources.".F(harvester, newSafeResourcePatch));
|
||||||
QueueOrder(new Order("Harvest", a, false) { TargetLocation = newSafeResourcePatch });
|
QueueOrder(new Order("Harvest", harvester, false) { TargetLocation = newSafeResourcePatch });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user