* started work * some more work, ui working (somewhat) * stuff * reorganization * some more reorg * conveyors * conveyors working * finalized (dis)connection added linkattempt added feedback text work on conveyors * removed command add rangecheck * fixed inrange check * handling * ui no longer kanser, ship it * adresses reviews * reformats file * reformats file Co-authored-by: Paul <ritter.paul1+git@googlemail.com>
36 lines
1.2 KiB
C#
36 lines
1.2 KiB
C#
using Content.Server.MachineLinking.Components;
|
|
using Content.Server.MachineLinking.Events;
|
|
using Content.Shared.Interaction;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.Server.MachineLinking.System
|
|
{
|
|
public class SignalSwitchSystem : EntitySystem
|
|
{
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<SignalSwitchComponent, InteractHandEvent>(OnInteracted);
|
|
SubscribeLocalEvent<SignalSwitchComponent, SignalValueRequestedEvent>(OnSignalValueRequested);
|
|
}
|
|
|
|
private void OnSignalValueRequested(EntityUid uid, SignalSwitchComponent component, SignalValueRequestedEvent args)
|
|
{
|
|
if (args.Port == "state")
|
|
{
|
|
args.Handled = true;
|
|
args.Signal = component.State;
|
|
}
|
|
}
|
|
|
|
private void OnInteracted(EntityUid uid, SignalSwitchComponent component, InteractHandEvent args)
|
|
{
|
|
component.State = !component.State;
|
|
RaiseLocalEvent(uid, new InvokePortEvent("state", component.State), false);
|
|
RaiseLocalEvent(uid, new InvokePortEvent("stateChange"), false);
|
|
args.Handled = true;
|
|
}
|
|
}
|
|
}
|