Add ReloadAmmoPool and adapt AmmoPool
Refactored and simplified Rearm activity. Uses local Reload now. Removed AmmoPool.SelfReloads.
This commit is contained in:
@@ -21,7 +21,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
readonly Target target;
|
||||
readonly Aircraft aircraft;
|
||||
readonly AttackPlane attackPlane;
|
||||
readonly AmmoPool[] ammoPools;
|
||||
|
||||
int ticksUntilTurn;
|
||||
|
||||
@@ -30,7 +29,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
this.target = target;
|
||||
aircraft = self.Trait<Aircraft>();
|
||||
attackPlane = self.TraitOrDefault<AttackPlane>();
|
||||
ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
|
||||
ticksUntilTurn = attackPlane.AttackPlaneInfo.AttackTurnDelay;
|
||||
}
|
||||
|
||||
@@ -46,8 +44,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (!target.IsValidFor(self))
|
||||
return NextActivity;
|
||||
|
||||
// TODO: This should check whether there is ammo left that is actually suitable for the target
|
||||
if (ammoPools.All(x => !x.Info.SelfReloads && !x.HasAmmo()))
|
||||
// If all valid weapons have depleted their ammo, return to RearmBuilding to reload and then resume the activity
|
||||
if (attackPlane.Armaments.All(x => x.OutOfAmmo || !x.Weapon.IsValidAgainst(target, self.World, self)))
|
||||
return ActivityUtils.SequenceActivities(new ReturnToBase(self, aircraft.Info.AbortOnResupply), this);
|
||||
|
||||
if (attackPlane != null)
|
||||
|
||||
@@ -21,7 +21,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
readonly Aircraft helicopter;
|
||||
readonly AttackHeli attackHeli;
|
||||
readonly AmmoPool[] ammoPools;
|
||||
readonly bool attackOnlyVisibleTargets;
|
||||
|
||||
Target target;
|
||||
@@ -46,7 +45,6 @@ namespace OpenRA.Mods.Common.Activities
|
||||
Target = target;
|
||||
helicopter = self.Trait<Aircraft>();
|
||||
attackHeli = self.Trait<AttackHeli>();
|
||||
ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
|
||||
this.attackOnlyVisibleTargets = attackOnlyVisibleTargets;
|
||||
}
|
||||
|
||||
@@ -74,8 +72,8 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return new HeliFly(self, newTarget);
|
||||
}
|
||||
|
||||
// If any AmmoPool is depleted and no weapon is valid against target, return to helipad to reload and then resume the activity
|
||||
if (ammoPools.Any(x => !x.Info.SelfReloads && !x.HasAmmo()) && !attackHeli.HasAnyValidWeapons(target))
|
||||
// If all valid weapons have depleted their ammo, return to RearmBuilding to reload and then resume the activity
|
||||
if (attackHeli.Armaments.All(x => x.OutOfAmmo || !x.Weapon.IsValidAgainst(target, self.World, self)))
|
||||
return ActivityUtils.SequenceActivities(new HeliReturnToBase(self, helicopter.Info.AbortOnResupply), this);
|
||||
|
||||
var dist = targetPos - pos;
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return true;
|
||||
|
||||
return heli.Info.RearmBuildings.Contains(dest.Info.Name) && self.TraitsImplementing<AmmoPool>()
|
||||
.Any(p => !p.Info.SelfReloads && !p.FullAmmo());
|
||||
.Any(p => !p.SelfReloads && !p.FullAmmo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return true;
|
||||
|
||||
return planeInfo.RearmBuildings.Contains(dest.Info.Name) && self.TraitsImplementing<AmmoPool>()
|
||||
.Any(p => !p.Info.SelfReloads && !p.FullAmmo());
|
||||
.Any(p => !p.SelfReloads && !p.FullAmmo());
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
|
||||
Reference in New Issue
Block a user