(1/2) #1210 Untangling QueueResupplyActivities
This commit is contained in:
@@ -176,5 +176,10 @@ namespace OpenRA
|
||||
{
|
||||
return string.Join(j, ts.Select(t => t.ToString()).ToArray());
|
||||
}
|
||||
|
||||
public static IEnumerable<T> Append<T>( this IEnumerable<T> ts, params T[] moreTs)
|
||||
{
|
||||
return ts.Concat(moreTs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Activity> 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<IOrderTargeter> Orders
|
||||
@@ -248,6 +254,21 @@ namespace OpenRA.Mods.RA.Air
|
||||
}
|
||||
}
|
||||
|
||||
public class ResupplyAircraft : Activity
|
||||
{
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
var aircraft = self.Trait<Aircraft>();
|
||||
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"; } }
|
||||
|
||||
Reference in New Issue
Block a user