Adjust existing activities for changed NextActivity semantics

To make sure existing checks against NextActivity don't check the parent activity by mistake
This commit is contained in:
Oliver Brakmann
2016-12-04 20:50:00 +01:00
parent 4105f9ed22
commit e49b3d6458
4 changed files with 15 additions and 12 deletions

View File

@@ -43,24 +43,24 @@ namespace OpenRA.Mods.Common.Activities
inner = ActivityUtils.SequenceActivities( inner = ActivityUtils.SequenceActivities(
aircraft.GetResupplyActivities(host) aircraft.GetResupplyActivities(host)
.Append(new AllowYieldingReservation(self)) .Append(new AllowYieldingReservation(self))
.Append(new WaitFor(() => NextActivity != null || aircraft.ReservedActor == null)) .Append(new WaitFor(() => NextInQueue != null || aircraft.ReservedActor == null))
.ToArray()); .ToArray());
} }
else else
{ {
// Helicopters should take off from their helipad immediately after resupplying. // Helicopters should take off from their helipad immediately after resupplying.
// HACK: Append NextActivity to TakeOff to avoid moving to the Rallypoint (if NextActivity is non-null). // HACK: Append NextInQueue to TakeOff to avoid moving to the Rallypoint (if NextInQueue is non-null).
inner = ActivityUtils.SequenceActivities( inner = ActivityUtils.SequenceActivities(
aircraft.GetResupplyActivities(host) aircraft.GetResupplyActivities(host)
.Append(new AllowYieldingReservation(self)) .Append(new AllowYieldingReservation(self))
.Append(new TakeOff(self)).Append(NextActivity).ToArray()); .Append(new TakeOff(self)).Append(NextInQueue).ToArray());
} }
} }
else else
inner = ActivityUtils.RunActivity(self, inner); inner = ActivityUtils.RunActivity(self, inner);
// The inner == NextActivity check is needed here because of the TakeOff issue mentioned in the comment above. // The inner == NextInQueue check is needed here because of the TakeOff issue mentioned in the comment above.
return inner == null || inner == NextActivity ? NextActivity : this; return inner == null || inner == NextInQueue ? NextActivity : this;
} }
public override bool Cancel(Actor self) public override bool Cancel(Actor self)

View File

@@ -37,10 +37,10 @@ namespace OpenRA.Mods.Common.Activities
var destination = rp != null ? rp.Location : var destination = rp != null ? rp.Location :
(hasHost ? self.World.Map.CellContaining(host.CenterPosition) : self.Location); (hasHost ? self.World.Map.CellContaining(host.CenterPosition) : self.Location);
if (NextActivity == null) if (NextInQueue == null)
return new AttackMoveActivity(self, move.MoveTo(destination, 1)); return new AttackMoveActivity(self, move.MoveTo(destination, 1));
else else
return NextActivity; return NextInQueue;
} }
} }
} }

View File

@@ -35,8 +35,8 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (NextActivity != null) if (NextInQueue != null)
return NextActivity; return NextInQueue;
// Find the nearest best refinery if not explicitly ordered to a specific refinery: // Find the nearest best refinery if not explicitly ordered to a specific refinery:
if (harv.OwnerLinkedProc == null || !harv.OwnerLinkedProc.IsInWorld) if (harv.OwnerLinkedProc == null || !harv.OwnerLinkedProc.IsInWorld)

View File

@@ -51,9 +51,12 @@ namespace OpenRA.Mods.Common.Activities
public override Activity Tick(Actor self) public override Activity Tick(Actor self)
{ {
if (IsCanceled || NextActivity != null) if (IsCanceled)
return NextActivity; return NextActivity;
if (NextInQueue != null)
return NextInQueue;
var deliver = new DeliverResources(self); var deliver = new DeliverResources(self);
if (harv.IsFull) if (harv.IsFull)
@@ -81,8 +84,8 @@ namespace OpenRA.Mods.Common.Activities
var randFrames = self.World.SharedRandom.Next(100, 175); var randFrames = self.World.SharedRandom.Next(100, 175);
// Avoid creating an activity cycle // Avoid creating an activity cycle
var next = NextActivity; var next = NextInQueue;
NextActivity = null; NextInQueue = null;
return ActivityUtils.SequenceActivities(next, new Wait(randFrames), this); return ActivityUtils.SequenceActivities(next, new Wait(randFrames), this);
} }
else else