mirror of
https://github.com/space-wizards/space-station-14.git
synced 2026-02-15 03:31:30 +01:00
* Entity<T>, skipping Magazine and ChamberMagazine * missed some * AUGH!! * ballistic examine * dotnet hates me * WHY ARE YOU CALLED THAT!!!! * cheers aada
35 lines
1014 B
C#
35 lines
1014 B
C#
using Content.Shared.Interaction;
|
|
using Content.Shared.Weapons.Ranged.Components;
|
|
|
|
namespace Content.Shared.Weapons.Ranged.Systems;
|
|
|
|
/// <summary>
|
|
/// Recharges ammo whenever the gun is cycled.
|
|
/// </summary>
|
|
public sealed class RechargeCycleAmmoSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedGunSystem _gun = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<RechargeCycleAmmoComponent, ActivateInWorldEvent>(OnRechargeCycled);
|
|
}
|
|
|
|
private void OnRechargeCycled(Entity<RechargeCycleAmmoComponent> ent, ref ActivateInWorldEvent args)
|
|
{
|
|
if (!args.Complex)
|
|
return;
|
|
|
|
if (!TryComp<BasicEntityAmmoProviderComponent>(ent, out var basic) || args.Handled)
|
|
return;
|
|
|
|
if (basic.Count >= basic.Capacity || basic.Count == null)
|
|
return;
|
|
|
|
_gun.UpdateBasicEntityAmmoCount((ent, basic), basic.Count.Value + 1);
|
|
Dirty(ent, basic);
|
|
args.Handled = true;
|
|
}
|
|
}
|