Make LastSearchFailed local to FindAndDeliverResources.
This commit is contained in:
@@ -36,6 +36,8 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
bool hasHarvestedCell;
|
bool hasHarvestedCell;
|
||||||
bool hasWaited;
|
bool hasWaited;
|
||||||
|
|
||||||
|
public bool LastSearchFailed { get; private set; }
|
||||||
|
|
||||||
public FindAndDeliverResources(Actor self, Actor deliverActor = null)
|
public FindAndDeliverResources(Actor self, Actor deliverActor = null)
|
||||||
{
|
{
|
||||||
harv = self.Trait<Harvester>();
|
harv = self.Trait<Harvester>();
|
||||||
@@ -86,7 +88,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (NextActivity != null)
|
if (NextActivity != null)
|
||||||
{
|
{
|
||||||
// Interrupt automated harvesting after clearing the first cell.
|
// Interrupt automated harvesting after clearing the first cell.
|
||||||
if (!harvInfo.QueueFullLoad && (hasHarvestedCell || harv.LastSearchFailed))
|
if (!harvInfo.QueueFullLoad && (hasHarvestedCell || LastSearchFailed))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Interrupt automated harvesting after first complete harvest cycle.
|
// 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.
|
// 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));
|
QueueChild(new DeliverResources(self));
|
||||||
hasDeliveredLoad = true;
|
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.
|
// 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));
|
QueueChild(new Wait(harv.Info.WaitDuration));
|
||||||
hasWaited = true;
|
hasWaited = true;
|
||||||
@@ -121,17 +123,17 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
lastHarvestedCell = null; // Forces search from backup position.
|
lastHarvestedCell = null; // Forces search from backup position.
|
||||||
closestHarvestableCell = ClosestHarvestablePos(self);
|
closestHarvestableCell = ClosestHarvestablePos(self);
|
||||||
harv.LastSearchFailed = !closestHarvestableCell.HasValue;
|
LastSearchFailed = !closestHarvestableCell.HasValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
harv.LastSearchFailed = true;
|
LastSearchFailed = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
harv.LastSearchFailed = false;
|
LastSearchFailed = false;
|
||||||
|
|
||||||
// If no harvestable position could be found and we are at the refinery, get out of the way
|
// If no harvestable position could be found and we are at the refinery, get out of the way
|
||||||
// of the refinery entrance.
|
// of the refinery entrance.
|
||||||
if (harv.LastSearchFailed)
|
if (LastSearchFailed)
|
||||||
{
|
{
|
||||||
var lastproc = harv.LastLinkedProc ?? harv.LinkedProc;
|
var lastproc = harv.LastLinkedProc ?? harv.LinkedProc;
|
||||||
if (lastproc != null && !lastproc.Disposed)
|
if (lastproc != null && !lastproc.Disposed)
|
||||||
|
|||||||
@@ -111,8 +111,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
if (!h.Key.IsIdle)
|
if (!h.Key.IsIdle)
|
||||||
{
|
{
|
||||||
var act = h.Key.CurrentActivity;
|
var act = h.Key.CurrentActivity as FindAndDeliverResources;
|
||||||
if (!h.Value.Harvester.LastSearchFailed || act.NextActivity == null || !(act.NextActivity is FindAndDeliverResources))
|
|
||||||
|
// Ignore this actor if FindAndDeliverResources is working fine or it is performing a different activity
|
||||||
|
if (act == null || !act.LastSearchFailed)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -103,8 +103,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
int conditionToken = ConditionManager.InvalidConditionToken;
|
int conditionToken = ConditionManager.InvalidConditionToken;
|
||||||
HarvesterResourceMultiplier[] resourceMultipliers;
|
HarvesterResourceMultiplier[] resourceMultipliers;
|
||||||
|
|
||||||
[Sync]
|
|
||||||
public bool LastSearchFailed;
|
|
||||||
|
|
||||||
[Sync]
|
[Sync]
|
||||||
public Actor OwnerLinkedProc = null;
|
public Actor OwnerLinkedProc = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user