Files
OldThink/Content.Server/White/ShockClothing/ShockClothingSystem.cs
Aviu00 21000c5b1f Collars
(cherry picked from commit 045439676ee03c51d377d318624d46ff84ae07d8)
2024-03-02 16:25:20 +03:00

43 lines
1.5 KiB
C#

using Content.Server.DeviceLinking.Events;
using Content.Server.DeviceLinking.Systems;
using Content.Server.Electrocution;
using Robust.Server.Containers;
using Robust.Shared.Audio.Systems;
namespace Content.Server.White.ShockClothing;
public sealed class ShockClothingSystem : EntitySystem
{
[Dependency] private readonly DeviceLinkSystem _deviceLink = default!;
[Dependency] private readonly ElectrocutionSystem _electrocution = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ShockClothingComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<ShockClothingComponent, SignalReceivedEvent>(OnSignalReceived);
}
private void OnInit(EntityUid uid, ShockClothingComponent component, ComponentInit args)
{
_deviceLink.EnsureSinkPorts(uid, component.TriggerPort);
}
private void OnSignalReceived(EntityUid uid, ShockClothingComponent component, ref SignalReceivedEvent args)
{
if (args.Port != component.TriggerPort)
return;
_audio.PlayPvs(component.ZapSound, uid);
if (!_containerSystem.TryGetContainingContainer(uid, out var container))
return;
_electrocution.TryDoElectrocution(container.Owner, uid, 1, TimeSpan.FromSeconds(5), true,
ignoreInsulation: true);
}
}