2021-08-27 17:46:02 +02:00
|
|
|
using Content.Server.MachineLinking.Components;
|
|
|
|
|
using Content.Server.MachineLinking.Events;
|
|
|
|
|
using Content.Shared.Interaction;
|
2021-10-10 03:43:50 -07:00
|
|
|
using JetBrains.Annotations;
|
2021-08-27 17:46:02 +02:00
|
|
|
using Robust.Shared.GameObjects;
|
2022-04-22 02:54:39 -04:00
|
|
|
using Content.Shared.Interaction.Events;
|
2021-08-27 17:46:02 +02:00
|
|
|
|
|
|
|
|
namespace Content.Server.MachineLinking.System
|
|
|
|
|
{
|
2021-10-10 03:43:50 -07:00
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class SignalButtonSystem : EntitySystem
|
2021-08-27 17:46:02 +02:00
|
|
|
{
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2022-04-04 01:13:03 -05:00
|
|
|
SubscribeLocalEvent<SignalButtonComponent, ComponentInit>(OnInit);
|
2022-04-24 11:45:37 +12:00
|
|
|
SubscribeLocalEvent<SignalButtonComponent, ActivateInWorldEvent>(OnActivated);
|
2021-08-27 17:46:02 +02:00
|
|
|
}
|
|
|
|
|
|
2022-04-04 01:13:03 -05:00
|
|
|
private void OnInit(EntityUid uid, SignalButtonComponent component, ComponentInit args)
|
|
|
|
|
{
|
|
|
|
|
var transmitter = EnsureComp<SignalTransmitterComponent>(uid);
|
|
|
|
|
if (!transmitter.Outputs.ContainsKey("Pressed"))
|
|
|
|
|
transmitter.AddPort("Pressed");
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-24 11:45:37 +12:00
|
|
|
private void OnActivated(EntityUid uid, SignalButtonComponent component, ActivateInWorldEvent args)
|
2021-08-27 17:46:02 +02:00
|
|
|
{
|
2022-04-04 01:13:03 -05:00
|
|
|
RaiseLocalEvent(uid, new InvokePortEvent("Pressed"), false);
|
2021-08-27 17:46:02 +02:00
|
|
|
args.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-24 11:45:37 +12:00
|
|
|
}
|