Move ChildActivity handling into base Activity class.
This commit is contained in:
@@ -65,26 +65,19 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// We have to make sure the actual "harvest" order is not skipped if a third order is queued,
|
||||
// so we keep deliveredLoad false.
|
||||
if (harv.IsFull)
|
||||
QueueChild(self, new DeliverResources(self), true);
|
||||
QueueChild(new DeliverResources(self));
|
||||
}
|
||||
|
||||
// If an explicit "deliver" order is given, the harvester goes immediately to the refinery.
|
||||
if (deliverActor != null)
|
||||
{
|
||||
QueueChild(self, new DeliverResources(self, deliverActor), true);
|
||||
QueueChild(new DeliverResources(self, deliverActor));
|
||||
hasDeliveredLoad = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (ChildActivity != null)
|
||||
{
|
||||
ChildActivity = ActivityUtils.RunActivity(self, ChildActivity);
|
||||
if (ChildActivity != null)
|
||||
return this;
|
||||
}
|
||||
|
||||
if (IsCanceling)
|
||||
return NextActivity;
|
||||
|
||||
@@ -102,7 +95,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Are we full or have nothing more to gather? Deliver resources.
|
||||
if (harv.IsFull || (!harv.IsEmpty && harv.LastSearchFailed))
|
||||
{
|
||||
QueueChild(self, new DeliverResources(self), true);
|
||||
QueueChild(new DeliverResources(self));
|
||||
hasDeliveredLoad = true;
|
||||
return this;
|
||||
}
|
||||
@@ -110,7 +103,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// After a failed search, wait and sit still for a bit before searching again.
|
||||
if (harv.LastSearchFailed && !hasWaited)
|
||||
{
|
||||
QueueChild(self, new Wait(harv.Info.WaitDuration), true);
|
||||
QueueChild(new Wait(harv.Info.WaitDuration));
|
||||
hasWaited = true;
|
||||
return this;
|
||||
}
|
||||
@@ -147,7 +140,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var unblockCell = deliveryLoc + harv.Info.UnblockCell;
|
||||
var moveTo = mobile.NearestMoveableCell(unblockCell, 1, 5);
|
||||
self.SetTargetLine(Target.FromCell(self.World, moveTo), Color.Green, false);
|
||||
QueueChild(self, mobile.MoveTo(moveTo, 1), true);
|
||||
QueueChild(mobile.MoveTo(moveTo, 1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +148,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
}
|
||||
|
||||
// If we get here, our search for resources was successful. Commence harvesting.
|
||||
QueueChild(self, new HarvestResource(self, closestHarvestableCell.Value), true);
|
||||
QueueChild(new HarvestResource(self, closestHarvestableCell.Value));
|
||||
lastHarvestedCell = closestHarvestableCell.Value;
|
||||
hasHarvestedCell = true;
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user