Files
OldThink/Content.Server/MachineLinking/System/SignalButtonSystem.cs

34 lines
1.1 KiB
C#
Raw Normal View History

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;
using Robust.Shared.GameObjects;
using Content.Shared.Interaction.Events;
namespace Content.Server.MachineLinking.System
{
2021-10-10 03:43:50 -07:00
[UsedImplicitly]
public sealed class SignalButtonSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
2022-04-04 01:13:03 -05:00
SubscribeLocalEvent<SignalButtonComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<SignalButtonComponent, ActivateInWorldEvent>(OnActivated);
}
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");
}
private void OnActivated(EntityUid uid, SignalButtonComponent component, ActivateInWorldEvent args)
{
2022-04-04 01:13:03 -05:00
RaiseLocalEvent(uid, new InvokePortEvent("Pressed"), false);
args.Handled = true;
}
}
}