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:
@@ -31,16 +31,25 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[WeaponReference]
|
||||
[Desc("Has to be defined here and in weapons.yaml.")]
|
||||
public readonly string Weapon = null;
|
||||
|
||||
[Desc("Which limited ammo pool (if present) should this armament be assigned to.")]
|
||||
public readonly string AmmoPoolName = "primary";
|
||||
|
||||
[Desc("Which turret (if present) should this armament be assigned to.")]
|
||||
public readonly string Turret = "primary";
|
||||
|
||||
[Desc("Time (in frames) until the weapon can fire again.")]
|
||||
public readonly int FireDelay = 0;
|
||||
|
||||
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
|
||||
public readonly WVec[] LocalOffset = { };
|
||||
|
||||
[Desc("Muzzle yaw relative to turret or body.")]
|
||||
public readonly WAngle[] LocalYaw = { };
|
||||
|
||||
[Desc("Move the turret backwards when firing.")]
|
||||
public readonly WRange Recoil = WRange.Zero;
|
||||
|
||||
[Desc("Recoil recovery per-frame")]
|
||||
public readonly WRange RecoilRecovery = new WRange(9);
|
||||
|
||||
@@ -64,7 +73,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
readonly Actor self;
|
||||
Lazy<Turreted> turret;
|
||||
Lazy<IBodyOrientation> coords;
|
||||
Lazy<LimitedAmmo> limitedAmmo;
|
||||
Lazy<AmmoPool> ammoPool;
|
||||
List<Pair<int, Action>> delayedActions = new List<Pair<int, Action>>();
|
||||
|
||||
public WRange Recoil;
|
||||
@@ -79,7 +88,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// We can't resolve these until runtime
|
||||
turret = Exts.Lazy(() => self.TraitsImplementing<Turreted>().FirstOrDefault(t => t.Name == info.Turret));
|
||||
coords = Exts.Lazy(() => self.Trait<IBodyOrientation>());
|
||||
limitedAmmo = Exts.Lazy(() => self.TraitOrDefault<LimitedAmmo>());
|
||||
ammoPool = Exts.Lazy(() => self.TraitsImplementing<AmmoPool>().FirstOrDefault(la => la.Info.Name == info.AmmoPoolName));
|
||||
|
||||
Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
||||
Burst = Weapon.Burst;
|
||||
@@ -136,7 +145,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (IsReloading)
|
||||
return null;
|
||||
|
||||
if (limitedAmmo.Value != null && !limitedAmmo.Value.HasAmmo())
|
||||
if (ammoPool.Value != null && !ammoPool.Value.HasAmmo())
|
||||
return null;
|
||||
|
||||
if (!target.IsInRange(self.CenterPosition, Weapon.Range))
|
||||
|
||||
Reference in New Issue
Block a user