Files
OldThink/Content.Server/_Amour/Vibrator/VibratorSystem.cs

43 lines
1.3 KiB
C#
Raw Normal View History

2024-02-12 18:00:47 +03:00
using Content.Server.DeviceLinking.Events;
using Content.Server.DeviceLinking.Systems;
using Content.Shared._Amour.Vibrator;
using Content.Shared.Interaction.Events;
namespace Content.Server._Amour.Vibrator;
public sealed class VibratorSystem : SharedVibratorSystem
{
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<VibratorComponent, UseInHandEvent>(OnUseInHand);
SubscribeLocalEvent<VibratorComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<VibratorComponent, SignalReceivedEvent>(OnsignalReceived);
2024-02-12 18:00:47 +03:00
}
private void OnsignalReceived(EntityUid uid, VibratorComponent component, ref SignalReceivedEvent args)
2024-02-12 18:00:47 +03:00
{
if (args.Port != component.TogglePort)
2024-02-12 18:00:47 +03:00
return;
ToggleVibration(uid, component);
2024-02-12 18:00:47 +03:00
}
private void OnInit(EntityUid uid, VibratorComponent component, ComponentInit args)
{
_signalSystem.EnsureSinkPorts(uid, component.TogglePort);
2024-02-12 18:00:47 +03:00
}
private void OnUseInHand(EntityUid uid, VibratorComponent component, UseInHandEvent args)
{
if (args.Handled)
return;
ToggleVibration(uid, component);
args.Handled = true;
2024-02-12 18:00:47 +03:00
}
}