public sealed class WeaponStateWhat one holder's weapon is doing: ammunition, heat, kick, and whether it can fire.
Remarks
Deterministic and side-effect free about geometry. Firing produces a shot number and a cone width; where the pellets went is Deviate, a pure function both ends compute. That is what makes the server's check of a client's claim possible at all — it recomputes the cone rather than believing one.
⚠ Spread and recoil are separate, and keeping them apart is the design. Recoil is a learnable pattern — the tenth bullet goes where the tenth bullet always goes — and spread is the randomness. A game that folds them together can tune "hard to control" and "unpredictable" only together, which is why every weapon in such a game feels the same.
Fields and properties (11)
public WeaponTemplate WeaponWhich weapon.
public int MagazineHow many rounds are in it.
public int ReserveHow many are carried beyond it. Zero when the weapon carries unlimited spares.
public uint ShotsHow many shots this holder has fired with it. Part of every pellet's seed.
public bool IsReloadingWhether it is being reloaded.
public float ReloadRemainingHow much of the reload is left, in seconds.
public ShotDirection RecoilWhere the weapon has been kicked to, cumulative and in degrees.
public float SpreadHow wide the cone is right now, in degrees.
public bool IsMovingWhether the holder is moving. Widens the cone.
public bool IsAimingWhether the holder is aiming down the sights. Narrows it.
public float EffectiveSpreadThe cone the next shot would use, with the movement and aim multipliers applied.
Methods (8)
public WeaponState(WeaponTemplate weapon)Makes a state for a weapon, with a full magazine.
public FireFailure CanFire(bool triggerDown = true)Whether a shot could happen right now.
public FireFailure TryFire(out ShotFired shot, bool triggerDown = true)Fires one shot.
public void ReleaseTrigger()Says the trigger was let go, which is what ends a burst and a semi-automatic's shot.
public bool BeginReload()Starts a reload.
public bool CancelReload()Stops a reload where it is.
public void Tick(float delta)Advances the fire interval, the reload, the spread's recovery and the recoil's.
public void Refill()Puts everything back: full magazine, no kick, no spread. What a respawn does.
Used by (4)
- ContentVixen.Gameplay.Shooting.Tests
- HitClaimValidatorTestsVixen.Gameplay.Shooting.Tests
- RewindBudgetTestsVixen.Gameplay.Shooting.Tests
- WeaponStateTestsVixen.Gameplay.Shooting.Tests