Simplify ResupplyAircraft
By moving part of the take-off prevention (when TakeOffOnResupply is set to false) to Aircraft. Main reason & advantage is that dropping the 'WaitFor' child makes this activity always end when resupplies are done, which makes it more compatible with being queued as ChildActivity itself (for example by ReturnToBase).
This commit is contained in:
@@ -28,18 +28,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (host == null)
|
||||
return;
|
||||
|
||||
if (!aircraft.Info.TakeOffOnResupply)
|
||||
{
|
||||
ChildActivity = ActivityUtils.SequenceActivities(self, aircraft.GetResupplyActivities(host).ToArray());
|
||||
QueueChild(self, new AllowYieldingReservation(self));
|
||||
QueueChild(self, new WaitFor(() => NextActivity != null || aircraft.ReservedActor == null));
|
||||
}
|
||||
else
|
||||
{
|
||||
ChildActivity = ActivityUtils.SequenceActivities(self, aircraft.GetResupplyActivities(host).ToArray());
|
||||
QueueChild(self, new AllowYieldingReservation(self));
|
||||
var resupplyActivities = aircraft.GetResupplyActivities(host).ToArray();
|
||||
if (resupplyActivities.Any())
|
||||
QueueChild(self, ActivityUtils.SequenceActivities(self, resupplyActivities));
|
||||
|
||||
QueueChild(self, new AllowYieldingReservation(self));
|
||||
|
||||
if (aircraft.Info.TakeOffOnResupply)
|
||||
QueueChild(self, new TakeOff(self, (a, b, c) => NextActivity == null && b.NextActivity == null));
|
||||
}
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
|
||||
@@ -528,7 +528,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
self.QueueActivity(new HeliLand(self, true));
|
||||
}
|
||||
else if (!Info.CanHover)
|
||||
else if (!Info.CanHover && (Info.TakeOffOnResupply || ReservedActor == null || self.World.Map.DistanceAboveTerrain(CenterPosition) != Info.LandAltitude))
|
||||
self.QueueActivity(new FlyCircle(self, -1, Info.IdleTurnSpeed > -1 ? Info.IdleTurnSpeed : TurnSpeed));
|
||||
|
||||
// Temporary HACK for the AutoCarryall special case (needs CanHover, but also HeliFlyCircle on idle).
|
||||
|
||||
Reference in New Issue
Block a user