Make LastSearchFailed local to FindAndDeliverResources.

This commit is contained in:
Paul Chote
2019-08-24 22:38:12 +00:00
committed by reaperrr
parent 1d2b3ac917
commit 815ea1e13b
3 changed files with 13 additions and 11 deletions

View File

@@ -36,6 +36,8 @@ namespace OpenRA.Mods.Common.Activities
bool hasHarvestedCell;
bool hasWaited;
public bool LastSearchFailed { get; private set; }
public FindAndDeliverResources(Actor self, Actor deliverActor = null)
{
harv = self.Trait<Harvester>();
@@ -86,7 +88,7 @@ namespace OpenRA.Mods.Common.Activities
if (NextActivity != null)
{
// Interrupt automated harvesting after clearing the first cell.
if (!harvInfo.QueueFullLoad && (hasHarvestedCell || harv.LastSearchFailed))
if (!harvInfo.QueueFullLoad && (hasHarvestedCell || LastSearchFailed))
return true;
// Interrupt automated harvesting after first complete harvest cycle.
@@ -95,7 +97,7 @@ namespace OpenRA.Mods.Common.Activities
}
// Are we full or have nothing more to gather? Deliver resources.
if (harv.IsFull || (!harv.IsEmpty && harv.LastSearchFailed))
if (harv.IsFull || (!harv.IsEmpty && LastSearchFailed))
{
QueueChild(new DeliverResources(self));
hasDeliveredLoad = true;
@@ -103,7 +105,7 @@ namespace OpenRA.Mods.Common.Activities
}
// After a failed search, wait and sit still for a bit before searching again.
if (harv.LastSearchFailed && !hasWaited)
if (LastSearchFailed && !hasWaited)
{
QueueChild(new Wait(harv.Info.WaitDuration));
hasWaited = true;
@@ -121,17 +123,17 @@ namespace OpenRA.Mods.Common.Activities
{
lastHarvestedCell = null; // Forces search from backup position.
closestHarvestableCell = ClosestHarvestablePos(self);
harv.LastSearchFailed = !closestHarvestableCell.HasValue;
LastSearchFailed = !closestHarvestableCell.HasValue;
}
else
harv.LastSearchFailed = true;
LastSearchFailed = true;
}
else
harv.LastSearchFailed = false;
LastSearchFailed = false;
// If no harvestable position could be found and we are at the refinery, get out of the way
// of the refinery entrance.
if (harv.LastSearchFailed)
if (LastSearchFailed)
{
var lastproc = harv.LastLinkedProc ?? harv.LinkedProc;
if (lastproc != null && !lastproc.Disposed)

View File

@@ -111,8 +111,10 @@ namespace OpenRA.Mods.Common.Traits
{
if (!h.Key.IsIdle)
{
var act = h.Key.CurrentActivity;
if (!h.Value.Harvester.LastSearchFailed || act.NextActivity == null || !(act.NextActivity is FindAndDeliverResources))
var act = h.Key.CurrentActivity as FindAndDeliverResources;
// Ignore this actor if FindAndDeliverResources is working fine or it is performing a different activity
if (act == null || !act.LastSearchFailed)
continue;
}

View File

@@ -103,8 +103,6 @@ namespace OpenRA.Mods.Common.Traits
int conditionToken = ConditionManager.InvalidConditionToken;
HarvesterResourceMultiplier[] resourceMultipliers;
[Sync]
public bool LastSearchFailed;
[Sync]
public Actor OwnerLinkedProc = null;