Move ChildActivity handling into base Activity class.

This commit is contained in:
tovl
2019-04-30 22:45:02 +02:00
committed by teinarss
parent 37379daf3c
commit b9c302a73a
43 changed files with 139 additions and 342 deletions

View File

@@ -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;