Machine Port Prototypes (#7659)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -2,9 +2,7 @@ using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.Doors.Systems;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.MachineLinking.System
|
||||
{
|
||||
@@ -12,6 +10,8 @@ namespace Content.Server.MachineLinking.System
|
||||
public sealed class DoorSignalControlSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly DoorSystem _doorSystem = default!;
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -21,20 +21,27 @@ namespace Content.Server.MachineLinking.System
|
||||
|
||||
private void OnInit(EntityUid uid, DoorSignalControlComponent component, ComponentInit args)
|
||||
{
|
||||
var receiver = EnsureComp<SignalReceiverComponent>(uid);
|
||||
foreach (string port in new[] { "Open", "Close", "Toggle" })
|
||||
if (!receiver.Inputs.ContainsKey(port))
|
||||
receiver.AddPort(port);
|
||||
_signalSystem.EnsureReceiverPorts(uid, component.OpenPort, component.ClosePort, component.TogglePort);
|
||||
}
|
||||
|
||||
private void OnSignalReceived(EntityUid uid, DoorSignalControlComponent component, SignalReceivedEvent args)
|
||||
{
|
||||
if (!TryComp(uid, out DoorComponent? door)) return;
|
||||
switch (args.Port)
|
||||
if (!TryComp(uid, out DoorComponent? door))
|
||||
return;
|
||||
|
||||
if (args.Port == component.OpenPort)
|
||||
{
|
||||
case "Open": if (door.State != DoorState.Open) _doorSystem.TryOpen(uid, door); break;
|
||||
case "Close": if (door.State != DoorState.Closed) _doorSystem.TryClose(uid, door); break;
|
||||
case "Toggle": _doorSystem.TryToggleDoor(uid); break;
|
||||
if (door.State != DoorState.Open)
|
||||
_doorSystem.TryOpen(uid, door);
|
||||
}
|
||||
else if (args.Port == component.ClosePort)
|
||||
{
|
||||
if (door.State != DoorState.Closed)
|
||||
_doorSystem.TryClose(uid, door);
|
||||
}
|
||||
else if (args.Port == component.TogglePort)
|
||||
{
|
||||
_doorSystem.TryToggleDoor(uid, door);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user