42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using Content.Server.GameObjects.Components.MachineLinking.Signals;
|
|
using Content.Shared.Interfaces;
|
|
using Content.Shared.Interfaces.GameObjects.Components;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
using Robust.Shared.Localization;
|
|
|
|
namespace Content.Server.GameObjects.Components.MachineLinking
|
|
{
|
|
[RegisterComponent]
|
|
public class SignalButtonComponent : Component, IActivate, IInteractHand
|
|
{
|
|
public override string Name => "SignalButton";
|
|
|
|
public void Activate(ActivateEventArgs eventArgs)
|
|
{
|
|
TransmitSignal(eventArgs.User);
|
|
}
|
|
|
|
public bool InteractHand(InteractHandEventArgs eventArgs)
|
|
{
|
|
TransmitSignal(eventArgs.User);
|
|
return true;
|
|
}
|
|
|
|
private void TransmitSignal(IEntity user)
|
|
{
|
|
if (!Owner.TryGetComponent<SignalTransmitterComponent>(out var transmitter))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (transmitter.TransmitSignal(user, new ToggleSignal()))
|
|
{
|
|
// Since the button doesn't have an animation, I'm going to use a popup message
|
|
Owner.PopupMessage(user, Loc.GetString("Click."));
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|