From 9fd25937fbfaae5be914a243466efbd871d46ff1 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Wed, 17 Aug 2022 15:44:43 +1200 Subject: [PATCH] Fix empty guns (#10650) --- .../Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs index 5bc7cf9d5d..148afd9eb1 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs @@ -127,8 +127,13 @@ public abstract partial class SharedGunSystem private void OnBallisticMapInit(EntityUid uid, BallisticAmmoProviderComponent component, MapInitEvent args) { + // TODO this should be part of the prototype, not set on map init. + // Alternatively, just track spawned count, instead of unspawned count. if (component.FillProto != null) - component.UnspawnedCount -= Math.Min(component.UnspawnedCount, component.Container.ContainedEntities.Count); + { + component.UnspawnedCount = Math.Max(0, component.Capacity - component.Container.ContainedEntities.Count); + Dirty(component); + } } protected int GetBallisticShots(BallisticAmmoProviderComponent component)