Ammunition stock has one owner; a named AmmoType makes a one-round magazine
Loadouts.StockAmmunition is the single owner of crate stocking. The generator calls it for generated ships and turrets, and Loadouts.Materialize calls it at the end, which covers every Loadout-built entity: scenario stage.Fit/Preset, the boss in ZoneGenerator, and the console-built ship. Paths left alone: Unpack of a pack or save (an entity's cargo is its own and a saved game's cargo is never touched on load), scenario stage.Cargo (adds on top of the stock), the LoadoutCommit validation build (discarded). The new-run player ship is stage.Generated and so already stocked by the generator. A hull with no bay gets no crates and a log line. InstantWeapon: a weapon that names an AmmoType is magazine-fed with an effective magazine of max(1, MagazineSize): every round leaves the magazine and the reload takes a crate. A weapon with no AmmoType and a magazine of 0 or 1 stays free. HUD shows rounds/reserve for every AmmoType weapon. ConstantWeapon keeps its own per-interval crate draw. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
1a8ced9ab6
commit
c21fad28f5
6 changed files with 148 additions and 28 deletions
|
|
@ -133,13 +133,13 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo
|
|||
public InstantWeapon(InstantWeaponData data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
_ammo = data.MagazineSize;
|
||||
_ammo = Magazine;
|
||||
}
|
||||
|
||||
public InstantWeapon(InstantWeaponData data, ConsumableItemEffect item) : base(data, item)
|
||||
{
|
||||
_data = data;
|
||||
_ammo = data.MagazineSize;
|
||||
_ammo = Magazine;
|
||||
}
|
||||
|
||||
protected void Trigger()
|
||||
|
|
@ -229,9 +229,9 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo
|
|||
if (!_coolingDown || !(_cooldown < 0)) return false;
|
||||
_overshoot = min(-_cooldown * CountdownSpan, dt);
|
||||
_coolingDown = false;
|
||||
if (_data.MagazineSize > 0 && _ammo == 0 && TakeReloadRound())
|
||||
if (Magazine > 0 && _ammo == 0 && TakeReloadRound())
|
||||
{
|
||||
_ammo = _data.MagazineSize;
|
||||
_ammo = Magazine;
|
||||
OnReloadComplete?.Invoke();
|
||||
}
|
||||
else
|
||||
|
|
@ -250,7 +250,7 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo
|
|||
return true;
|
||||
}
|
||||
|
||||
private float CountdownSpan => max(ShortestCycle, _data.MagazineSize > 0 && _ammo == 0 ? _data.ReloadTime : Cooldown);
|
||||
private float CountdownSpan => max(ShortestCycle, Magazine > 0 && _ammo == 0 ? _data.ReloadTime : Cooldown);
|
||||
|
||||
// A countdown that starts outside a round (a charge failing) carries the last one's overshoot like every restart.
|
||||
protected void StartCountdown()
|
||||
|
|
@ -266,9 +266,13 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo
|
|||
return overshoot;
|
||||
}
|
||||
|
||||
// A weapon that names an AmmoType is magazine-fed whatever MagazineSize says: its magazine is at least one round, every round
|
||||
// leaves it and the reload takes a crate. A weapon with no AmmoType and a magazine of one or none fires free.
|
||||
private int Magazine => _data.AmmoType.IsSet() ? max(1, _data.MagazineSize) : _data.MagazineSize;
|
||||
|
||||
private bool UseAmmo(float dt)
|
||||
{
|
||||
if (_data.MagazineSize <= 1) return true;
|
||||
if (!_data.AmmoType.IsSet() && _data.MagazineSize <= 1) return true;
|
||||
|
||||
if (_ammo > 0)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue