Merge Rearm and Repair into Resupply activity
Allows parallel rearming and repairing.
This commit is contained in:
@@ -541,16 +541,6 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return Info.LandableTerrainTypes.Contains(type);
|
||||
}
|
||||
|
||||
public bool CanRearmAt(Actor host)
|
||||
{
|
||||
return rearmable != null && rearmable.Info.RearmActors.Contains(host.Info.Name) && rearmable.RearmableAmmoPools.Any(p => !p.FullAmmo());
|
||||
}
|
||||
|
||||
public bool CanRepairAt(Actor host)
|
||||
{
|
||||
return repairable != null && repairable.Info.RepairActors.Contains(host.Info.Name) && self.GetDamageState() != DamageState.Undamaged;
|
||||
}
|
||||
|
||||
bool IsBlockedBy(Actor self, Actor otherActor, Actor ignoreActor)
|
||||
{
|
||||
// We are not blocked by the actor we are ignoring.
|
||||
@@ -580,14 +570,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual IEnumerable<Activity> GetResupplyActivities(Actor a)
|
||||
public bool CanRearmAt(Actor host)
|
||||
{
|
||||
// The ResupplyAircraft activity guarantees that we're on the helipad/repair depot
|
||||
if (CanRearmAt(a))
|
||||
yield return new Rearm(self, a, WDist.Zero);
|
||||
return rearmable != null && rearmable.Info.RearmActors.Contains(host.Info.Name) && rearmable.RearmableAmmoPools.Any(p => !p.FullAmmo());
|
||||
}
|
||||
|
||||
if (CanRepairAt(a))
|
||||
yield return new Repair(self, a, WDist.Zero);
|
||||
public bool CanRepairAt(Actor host)
|
||||
{
|
||||
return repairable != null && repairable.Info.RepairActors.Contains(host.Info.Name) && self.GetDamageState() != DamageState.Undamaged;
|
||||
}
|
||||
|
||||
public void ModifyDeathActorInit(Actor self, TypeDictionary init)
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
|
||||
var activity = a.CurrentActivity;
|
||||
var type = activity.GetType();
|
||||
if (type == typeof(Rearm) || type == typeof(ResupplyAircraft))
|
||||
if (type == typeof(Resupply) || type == typeof(ResupplyAircraft))
|
||||
return true;
|
||||
|
||||
var next = activity.NextActivity;
|
||||
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
return false;
|
||||
|
||||
var nextType = next.GetType();
|
||||
if (nextType == typeof(Rearm) || nextType == typeof(ResupplyAircraft))
|
||||
if (nextType == typeof(Resupply) || nextType == typeof(ResupplyAircraft))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -134,11 +134,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// TODO: This is hacky, but almost every single component affected
|
||||
// will need to be rewritten anyway, so this is OK for now.
|
||||
self.QueueActivity(movement.MoveTo(self.World.Map.CellContaining(targetActor.CenterPosition), targetActor));
|
||||
if (CanRearmAt(targetActor) && CanRearm())
|
||||
self.QueueActivity(new Rearm(self, targetActor, new WDist(512)));
|
||||
|
||||
// Add a CloseEnough range of 512 to ensure we're at the host actor
|
||||
self.QueueActivity(new Repair(self, targetActor, new WDist(512)));
|
||||
self.QueueActivity(new Resupply(self, targetActor, new WDist(512)));
|
||||
|
||||
var rp = targetActor.TraitOrDefault<RallyPoint>();
|
||||
if (rp != null)
|
||||
|
||||
@@ -31,14 +31,14 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
class RepairableNear : IIssueOrder, IResolveOrder, IOrderVoice
|
||||
{
|
||||
public readonly RepairableNearInfo Info;
|
||||
readonly Actor self;
|
||||
readonly RepairableNearInfo info;
|
||||
readonly IMove movement;
|
||||
|
||||
public RepairableNear(Actor self, RepairableNearInfo info)
|
||||
{
|
||||
this.self = self;
|
||||
this.info = info;
|
||||
Info = info;
|
||||
movement = self.Trait<IMove>();
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
bool CanRepairAt(Actor target)
|
||||
{
|
||||
return info.RepairActors.Contains(target.Info.Name);
|
||||
return Info.RepairActors.Contains(target.Info.Name);
|
||||
}
|
||||
|
||||
bool ShouldRepair()
|
||||
@@ -71,7 +71,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public string VoicePhraseForOrder(Actor self, Order order)
|
||||
{
|
||||
return order.OrderString == "RepairNear" && ShouldRepair() ? info.Voice : null;
|
||||
return order.OrderString == "RepairNear" && ShouldRepair() ? Info.Voice : null;
|
||||
}
|
||||
|
||||
public void ResolveOrder(Actor self, Order order)
|
||||
@@ -87,8 +87,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!order.Queued)
|
||||
self.CancelActivity();
|
||||
|
||||
self.QueueActivity(movement.MoveWithinRange(order.Target, info.CloseEnough, targetLineColor: Color.Green));
|
||||
self.QueueActivity(new Repair(self, order.Target.Actor, info.CloseEnough));
|
||||
self.QueueActivity(movement.MoveWithinRange(order.Target, Info.CloseEnough, targetLineColor: Color.Green));
|
||||
self.QueueActivity(new Resupply(self, order.Target.Actor, Info.CloseEnough));
|
||||
|
||||
self.SetTargetLine(order.Target, Color.Green, false);
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
var repairBuilding = self.World.ActorsWithTrait<RepairsUnits>()
|
||||
.Where(a => !a.Actor.IsDead && a.Actor.IsInWorld
|
||||
&& a.Actor.Owner.IsAlliedWith(self.Owner) &&
|
||||
info.RepairActors.Contains(a.Actor.Info.Name))
|
||||
Info.RepairActors.Contains(a.Actor.Info.Name))
|
||||
.OrderBy(p => (self.Location - p.Actor.Location).LengthSquared);
|
||||
|
||||
// Worst case FirstOrDefault() will return a TraitPair<null, null>, which is OK.
|
||||
|
||||
Reference in New Issue
Block a user