diff --git a/Content.Shared/Magic/SharedMagicSystem.cs b/Content.Shared/Magic/SharedMagicSystem.cs index 19d649d1f3..6afba65a39 100644 --- a/Content.Shared/Magic/SharedMagicSystem.cs +++ b/Content.Shared/Magic/SharedMagicSystem.cs @@ -1,6 +1,8 @@ using System.Numerics; using Content.Shared.Body.Components; using Content.Shared.Body.Systems; +using Content.Shared.Charges.Components; +using Content.Shared.Charges.Systems; using Content.Shared.Coordinates.Helpers; using Content.Shared.Doors.Components; using Content.Shared.Doors.Systems; @@ -63,6 +65,7 @@ public abstract class SharedMagicSystem : EntitySystem [Dependency] private readonly SharedMindSystem _mind = default!; [Dependency] private readonly SharedStunSystem _stun = default!; [Dependency] private readonly TurfSystem _turf = default!; + [Dependency] private readonly SharedChargesSystem _charges = default!; private static readonly ProtoId InvalidForGlobalSpawnSpellTag = "InvalidForGlobalSpawnSpell"; @@ -444,10 +447,13 @@ public abstract class SharedMagicSystem : EntitySystem ev.Handled = true; - if (wand == null || !TryComp(wand, out var basicAmmoComp) || basicAmmoComp.Count == null) + if (wand == null) return; - _gunSystem.UpdateBasicEntityAmmoCount(wand.Value, basicAmmoComp.Count.Value + ev.Charge, basicAmmoComp); + if (TryComp(wand, out var basicAmmoComp) && basicAmmoComp.Count != null) + _gunSystem.UpdateBasicEntityAmmoCount(wand.Value, basicAmmoComp.Count.Value + ev.Charge, basicAmmoComp); + else if (TryComp(wand, out var charges)) + _charges.AddCharges((wand.Value, charges), ev.Charge); } // End Charge Spells #endregion