Implement machine linking (#1784)
* Implement machine linking * Cleanup and rename Signals * Implement signal button * Add machine linking signal mapping * Fix signallink command help * Add localization to signal linking and allow infinite range * Add feedback for when a transmitter is not connected to any receivers Refactor PopupMessage to use the entity extension Refactor dependencies to not have to disable warnings
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
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, SignalState.Toggle))
|
||||
{
|
||||
// Since the button doesn't have an animation, I'm going to use a popup message
|
||||
Owner.PopupMessage(user, Loc.GetString("Click."));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user