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(
aircraft.GetResupplyActivities(host)
.Append(new AllowYieldingReservation(self))
.Append(new WaitFor(() => NextActivity != null || aircraft.ReservedActor == null))
.Append(new WaitFor(() => NextInQueue != null || aircraft.ReservedActor == null))
.ToArray());
}
else
{
// 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(
aircraft.GetResupplyActivities(host)
.Append(new AllowYieldingReservation(self))
.Append(new TakeOff(self)).Append(NextActivity).ToArray());
.Append(new TakeOff(self)).Append(NextInQueue).ToArray());
}
}
else
inner = ActivityUtils.RunActivity(self, inner);
// The inner == NextActivity check is needed here because of the TakeOff issue mentioned in the comment above.
return inner == null || inner == NextActivity ? NextActivity : this;
// The inner == NextInQueue check is needed here because of the TakeOff issue mentioned in the comment above.
return inner == null || inner == NextInQueue ? NextActivity : this;
}
public override bool Cancel(Actor self)

View File

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

View File

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

View File

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