diff --git a/OpenRA.FileFormats/Exts.cs b/OpenRA.FileFormats/Exts.cs index d48cc49b49..bb0085ceb3 100755 --- a/OpenRA.FileFormats/Exts.cs +++ b/OpenRA.FileFormats/Exts.cs @@ -176,5 +176,10 @@ namespace OpenRA { return string.Join(j, ts.Select(t => t.ToString()).ToArray()); } + + public static IEnumerable Append( this IEnumerable ts, params T[] moreTs) + { + return ts.Concat(moreTs); + } } } diff --git a/OpenRA.Mods.RA/Air/Aircraft.cs b/OpenRA.Mods.RA/Air/Aircraft.cs index eb9cf23dd5..41cacc3708 100755 --- a/OpenRA.Mods.RA/Air/Aircraft.cs +++ b/OpenRA.Mods.RA/Air/Aircraft.cs @@ -205,12 +205,18 @@ namespace OpenRA.Mods.RA.Air } public void QueueResupplyActivities(Actor a) + { + foreach( var act in GetResupplyActivities(a) ) + self.QueueActivity(act); + } + + public IEnumerable GetResupplyActivities(Actor a) { var name = a.Info.Name; if (Info.RearmBuildings.Contains(name)) - self.QueueActivity(new Rearm(self)); + yield return new Rearm(self); if (Info.RepairBuildings.Contains(name)) - self.QueueActivity(new Repair(a)); + yield return new Repair(a); } public IEnumerable Orders @@ -248,6 +254,21 @@ namespace OpenRA.Mods.RA.Air } } + public class ResupplyAircraft : Activity + { + public override Activity Tick(Actor self) + { + var aircraft = self.Trait(); + var host = aircraft.GetActorBelow(); + + if (host == null) + return NextActivity; + + return Util.SequenceActivities( + aircraft.GetResupplyActivities(host).Append(NextActivity).ToArray()); + } + } + class AircraftMoveOrderTargeter : IOrderTargeter { public string OrderID { get { return "Move"; } }