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:
ShadowCommander
2020-08-29 03:33:42 -07:00
committed by GitHub
parent f3315feba1
commit aa66aa2286
16 changed files with 701 additions and 9 deletions

View File

@@ -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."));
}
}
}
}