Refactors LimitedAmmo to AmmoPool.
Removes Reloads trait. This enables adding multiple AmmoPools via @ differentiators and Name which adds the possibility to assign each armament to a specific ammo pool. Furthermore, this moves all Reloads functionality onto AmmoPool. Now a combination of all three is possible on a single actor: no limited ammo, limited ammo that can reload on its own, and limited ammo which needs to be reloaded at a rearm actor. Additionally moves RearmSound from Minelayer to AmmoPool.
This commit is contained in:
@@ -229,7 +229,7 @@ namespace OpenRA.Mods.Common.AI
|
||||
return null;
|
||||
|
||||
var unit = buildableThings.Random(Random);
|
||||
return HasAdequateAirUnits(unit) ? unit : null;
|
||||
return HasAdequateAirUnitReloadBuildings(unit) ? unit : null;
|
||||
}
|
||||
|
||||
ActorInfo ChooseUnitToBuild(ProductionQueue queue)
|
||||
@@ -246,7 +246,7 @@ namespace OpenRA.Mods.Common.AI
|
||||
foreach (var unit in Info.UnitsToBuild.Shuffle(Random))
|
||||
if (buildableThings.Any(b => b.Name == unit.Key))
|
||||
if (myUnits.Count(a => a == unit.Key) < unit.Value * myUnits.Count)
|
||||
if (HasAdequateAirUnits(Map.Rules.Actors[unit.Key]))
|
||||
if (HasAdequateAirUnitReloadBuildings(Map.Rules.Actors[unit.Key]))
|
||||
return Map.Rules.Actors[unit.Key];
|
||||
|
||||
return null;
|
||||
@@ -318,13 +318,18 @@ namespace OpenRA.Mods.Common.AI
|
||||
}
|
||||
|
||||
// For mods like RA (number of building must match the number of aircraft)
|
||||
bool HasAdequateAirUnits(ActorInfo actorInfo)
|
||||
bool HasAdequateAirUnitReloadBuildings(ActorInfo actorInfo)
|
||||
{
|
||||
if (!actorInfo.Traits.Contains<ReloadsInfo>() && actorInfo.Traits.Contains<LimitedAmmoInfo>()
|
||||
&& actorInfo.Traits.Contains<AircraftInfo>())
|
||||
var aircraftInfo = actorInfo.Traits.GetOrDefault<AircraftInfo>();
|
||||
if (aircraftInfo == null)
|
||||
return true;
|
||||
|
||||
var ammoPoolsInfo = actorInfo.Traits.WithInterface<AmmoPoolInfo>();
|
||||
|
||||
if (ammoPoolsInfo.Any(x => !x.SelfReloads))
|
||||
{
|
||||
var countOwnAir = CountUnits(actorInfo.Name, Player);
|
||||
var countBuildings = CountBuilding(actorInfo.Traits.Get<AircraftInfo>().RearmBuildings.FirstOrDefault(), Player);
|
||||
var countBuildings = CountBuilding(aircraftInfo.RearmBuildings.FirstOrDefault(), Player);
|
||||
if (countOwnAir >= countBuildings)
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -104,19 +104,20 @@ namespace OpenRA.Mods.Common.AI
|
||||
|
||||
protected static bool FullAmmo(Actor a)
|
||||
{
|
||||
var limitedAmmo = a.TraitOrDefault<LimitedAmmo>();
|
||||
return limitedAmmo != null && limitedAmmo.FullAmmo();
|
||||
var ammoPools = a.TraitsImplementing<AmmoPool>();
|
||||
return ammoPools.All(x => x.FullAmmo());
|
||||
}
|
||||
|
||||
protected static bool HasAmmo(Actor a)
|
||||
{
|
||||
var limitedAmmo = a.TraitOrDefault<LimitedAmmo>();
|
||||
return limitedAmmo != null && limitedAmmo.HasAmmo();
|
||||
var ammoPools = a.TraitsImplementing<AmmoPool>();
|
||||
return ammoPools.All(x => x.HasAmmo());
|
||||
}
|
||||
|
||||
protected static bool ReloadsAutomatically(Actor a)
|
||||
{
|
||||
return a.HasTrait<Reloads>();
|
||||
var ammoPools = a.TraitsImplementing<AmmoPool>();
|
||||
return ammoPools.All(x => x.Info.SelfReloads);
|
||||
}
|
||||
|
||||
protected static bool IsRearm(Actor a)
|
||||
|
||||
Reference in New Issue
Block a user