35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
using Content.Shared.Containers;
|
|
using Content.Shared.Weapons.Ranged.Components;
|
|
using Content.Shared.Weapons.Ranged.Events;
|
|
|
|
namespace Content.Shared.Weapons.Ranged.Systems;
|
|
|
|
public partial class SharedGunSystem
|
|
{
|
|
private void InitializeClothing()
|
|
{
|
|
SubscribeLocalEvent<ClothingSlotAmmoProviderComponent, TakeAmmoEvent>(OnClothingTakeAmmo);
|
|
SubscribeLocalEvent<ClothingSlotAmmoProviderComponent, GetAmmoCountEvent>(OnClothingAmmoCount);
|
|
}
|
|
|
|
private void OnClothingTakeAmmo(EntityUid uid, ClothingSlotAmmoProviderComponent component, TakeAmmoEvent args)
|
|
{
|
|
var getConnectedContainerEvent = new GetConnectedContainerEvent();
|
|
RaiseLocalEvent(uid, ref getConnectedContainerEvent);
|
|
if(!getConnectedContainerEvent.ContainerEntity.HasValue)
|
|
return;
|
|
|
|
RaiseLocalEvent(getConnectedContainerEvent.ContainerEntity.Value, args);
|
|
}
|
|
|
|
private void OnClothingAmmoCount(EntityUid uid, ClothingSlotAmmoProviderComponent component, ref GetAmmoCountEvent args)
|
|
{
|
|
var getConnectedContainerEvent = new GetConnectedContainerEvent();
|
|
RaiseLocalEvent(uid, ref getConnectedContainerEvent);
|
|
if (!getConnectedContainerEvent.ContainerEntity.HasValue)
|
|
return;
|
|
|
|
RaiseLocalEvent(getConnectedContainerEvent.ContainerEntity.Value, ref args);
|
|
}
|
|
}
|