Device Linking and better linking ui (#13645)
Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com> Co-authored-by: Visne <39844191+Visne@users.noreply.github.com> Co-authored-by: ElectroJr <leonsfriedrich@gmail.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
using Content.Server.Atmos.Piping.Binary.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.MachineLinking.System;
|
||||
|
||||
namespace Content.Server.Atmos.Piping.Binary.EntitySystems;
|
||||
|
||||
public sealed class SignalControlledValveSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SignalLinkerSystem _signal = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signal = default!;
|
||||
[Dependency] private readonly GasValveSystem _valve = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -19,10 +20,10 @@ public sealed class SignalControlledValveSystem : EntitySystem
|
||||
|
||||
private void OnInit(EntityUid uid, SignalControlledValveComponent comp, ComponentInit args)
|
||||
{
|
||||
_signal.EnsureReceiverPorts(uid, comp.OpenPort, comp.ClosePort, comp.TogglePort);
|
||||
_signal.EnsureSinkPorts(uid, comp.OpenPort, comp.ClosePort, comp.TogglePort);
|
||||
}
|
||||
|
||||
private void OnSignalReceived(EntityUid uid, SignalControlledValveComponent comp, SignalReceivedEvent args)
|
||||
private void OnSignalReceived(EntityUid uid, SignalControlledValveComponent comp, ref SignalReceivedEvent args)
|
||||
{
|
||||
if (!TryComp<GasValveComponent>(uid, out var valve))
|
||||
return;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.Atmos.Monitor.Systems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.MachineLinking.System;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Power.Components;
|
||||
@@ -28,7 +27,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
[Dependency] private readonly SharedAmbientSoundSystem _ambientSoundSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
@@ -224,10 +223,10 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
private void OnInit(EntityUid uid, GasVentPumpComponent component, ComponentInit args)
|
||||
{
|
||||
if (component.CanLink)
|
||||
_signalSystem.EnsureReceiverPorts(uid, component.PressurizePort, component.DepressurizePort);
|
||||
_signalSystem.EnsureSinkPorts(uid, component.PressurizePort, component.DepressurizePort);
|
||||
}
|
||||
|
||||
private void OnSignalReceived(EntityUid uid, GasVentPumpComponent component, SignalReceivedEvent args)
|
||||
private void OnSignalReceived(EntityUid uid, GasVentPumpComponent component, ref SignalReceivedEvent args)
|
||||
{
|
||||
if (!component.CanLink)
|
||||
return;
|
||||
|
||||
@@ -2,7 +2,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Access.Systems;
|
||||
using Content.Server.Cargo.Components;
|
||||
using Content.Server.Labels.Components;
|
||||
using Content.Server.MachineLinking.System;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Access.Systems;
|
||||
@@ -34,7 +34,7 @@ namespace Content.Server.Cargo.Systems
|
||||
|
||||
[Dependency] private readonly IdCardSystem _idCardSystem = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||
[Dependency] private readonly SignalLinkerSystem _linker = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _linker = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly StationSystem _station = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
|
||||
@@ -74,7 +74,7 @@ public sealed partial class CargoSystem
|
||||
|
||||
private void OnInit(EntityUid uid, CargoTelepadComponent telepad, ComponentInit args)
|
||||
{
|
||||
_linker.EnsureReceiverPorts(uid, telepad.ReceiverPort);
|
||||
_linker.EnsureSinkPorts(uid, telepad.ReceiverPort);
|
||||
}
|
||||
|
||||
private void SetEnabled(CargoTelepadComponent component, ApcPowerReceiverComponent? receiver = null,
|
||||
|
||||
@@ -4,11 +4,10 @@ using Robust.Shared.Timing;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Medical.Components;
|
||||
using Content.Server.Cloning.Components;
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Mind.Components;
|
||||
using Content.Server.MachineLinking.System;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Robust.Server.GameObjects;
|
||||
@@ -16,7 +15,8 @@ using Robust.Server.Player;
|
||||
using Content.Shared.Cloning.CloningConsole;
|
||||
using Content.Shared.Cloning;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.MachineLinking.Events;
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
@@ -26,7 +26,7 @@ namespace Content.Server.Cloning
|
||||
[UsedImplicitly]
|
||||
public sealed class CloningConsoleSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly CloningSystem _cloningSystem = default!;
|
||||
@@ -48,7 +48,7 @@ namespace Content.Server.Cloning
|
||||
|
||||
private void OnInit(EntityUid uid, CloningConsoleComponent component, ComponentInit args)
|
||||
{
|
||||
_signalSystem.EnsureTransmitterPorts(uid, CloningConsoleComponent.ScannerPort, CloningConsoleComponent.PodPort);
|
||||
_signalSystem.EnsureSourcePorts(uid, CloningConsoleComponent.ScannerPort, CloningConsoleComponent.PodPort);
|
||||
}
|
||||
private void OnButtonPressed(EntityUid uid, CloningConsoleComponent consoleComponent, UiButtonPressedMessage args)
|
||||
{
|
||||
@@ -72,20 +72,20 @@ namespace Content.Server.Cloning
|
||||
|
||||
private void OnMapInit(EntityUid uid, CloningConsoleComponent component, MapInitEvent args)
|
||||
{
|
||||
if (!TryComp<SignalTransmitterComponent>(uid, out var receiver))
|
||||
if (!TryComp<DeviceLinkSourceComponent>(uid, out var receiver))
|
||||
return;
|
||||
|
||||
foreach (var port in receiver.Outputs.Values.SelectMany(ports => ports))
|
||||
{
|
||||
if (TryComp<MedicalScannerComponent>(port.Uid, out var scanner))
|
||||
if (TryComp<MedicalScannerComponent>(port, out var scanner))
|
||||
{
|
||||
component.GeneticScanner = port.Uid;
|
||||
component.GeneticScanner = port;
|
||||
scanner.ConnectedConsole = uid;
|
||||
}
|
||||
|
||||
if (TryComp<CloningPodComponent>(port.Uid, out var pod))
|
||||
if (TryComp<CloningPodComponent>(port, out var pod))
|
||||
{
|
||||
component.CloningPod = port.Uid;
|
||||
component.CloningPod = port;
|
||||
pod.ConnectedConsole = uid;
|
||||
}
|
||||
}
|
||||
@@ -93,15 +93,15 @@ namespace Content.Server.Cloning
|
||||
|
||||
private void OnNewLink(EntityUid uid, CloningConsoleComponent component, NewLinkEvent args)
|
||||
{
|
||||
if (TryComp<MedicalScannerComponent>(args.Receiver, out var scanner) && args.TransmitterPort == CloningConsoleComponent.ScannerPort)
|
||||
if (TryComp<MedicalScannerComponent>(args.Sink, out var scanner) && args.SourcePort == CloningConsoleComponent.ScannerPort)
|
||||
{
|
||||
component.GeneticScanner = args.Receiver;
|
||||
component.GeneticScanner = args.Sink;
|
||||
scanner.ConnectedConsole = uid;
|
||||
}
|
||||
|
||||
if (TryComp<CloningPodComponent>(args.Receiver, out var pod) && args.TransmitterPort == CloningConsoleComponent.PodPort)
|
||||
if (TryComp<CloningPodComponent>(args.Sink, out var pod) && args.SourcePort == CloningConsoleComponent.PodPort)
|
||||
{
|
||||
component.CloningPod = args.Receiver;
|
||||
component.CloningPod = args.Sink;
|
||||
pod.ConnectedConsole = uid;
|
||||
}
|
||||
RecheckConnections(uid, component.CloningPod, component.GeneticScanner, component);
|
||||
|
||||
@@ -10,15 +10,15 @@ using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.EUI;
|
||||
using Content.Server.Humanoid;
|
||||
using Content.Server.MachineLinking.System;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Shared.Chemistry.Components;
|
||||
using Content.Server.Fluids.EntitySystems;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.Materials;
|
||||
using Content.Server.Stack;
|
||||
using Content.Server.Jobs;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.Emag.Components;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Humanoid.Prototypes;
|
||||
@@ -43,7 +43,7 @@ namespace Content.Server.Cloning
|
||||
{
|
||||
public sealed class CloningSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = null!;
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly EuiManager _euiManager = null!;
|
||||
@@ -84,7 +84,7 @@ namespace Content.Server.Cloning
|
||||
private void OnComponentInit(EntityUid uid, CloningPodComponent clonePod, ComponentInit args)
|
||||
{
|
||||
clonePod.BodyContainer = _containerSystem.EnsureContainer<ContainerSlot>(clonePod.Owner, "clonepod-bodyContainer");
|
||||
_signalSystem.EnsureReceiverPorts(uid, CloningPodComponent.PodPort);
|
||||
_signalSystem.EnsureSinkPorts(uid, CloningPodComponent.PodPort);
|
||||
}
|
||||
|
||||
private void OnPartsRefreshed(EntityUid uid, CloningPodComponent component, RefreshPartsEvent args)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.MachineLinking.Components;
|
||||
namespace Content.Server.DeviceLinking.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for automatic linkage with buttons and other transmitters.
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.MachineLinking.Components;
|
||||
namespace Content.Server.DeviceLinking.Components;
|
||||
|
||||
/// <summary>
|
||||
/// This is used for automatic linkage with various receivers, like shutters.
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Shared.MachineLinking;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.MachineLinking.Components
|
||||
namespace Content.Server.DeviceLinking.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class DoorSignalControlComponent : Component
|
||||
@@ -2,7 +2,7 @@ using Content.Shared.MachineLinking;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.MachineLinking.Components
|
||||
namespace Content.Server.DeviceLinking.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Simple switch that will fire ports when toggled on or off. A button is jsut a switch that signals on the
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Shared.MachineLinking;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.MachineLinking.Components
|
||||
namespace Content.Server.DeviceLinking.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Sends out a signal to machine linked objects.
|
||||
@@ -1,7 +1,8 @@
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Content.Shared.MachineLinking;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.MachineLinking.Components
|
||||
namespace Content.Server.DeviceLinking.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class TwoWayLeverComponent : Component
|
||||
@@ -0,0 +1,6 @@
|
||||
using Content.Server.DeviceNetwork;
|
||||
|
||||
namespace Content.Server.DeviceLinking.Events;
|
||||
|
||||
[ByRefEvent]
|
||||
public readonly record struct SignalReceivedEvent(string Port, EntityUid? Trigger = null, NetworkPayload? Data = null);
|
||||
@@ -1,13 +1,14 @@
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.MachineLinking.System;
|
||||
|
||||
namespace Content.Server.MachineLinking.System;
|
||||
namespace Content.Server.DeviceLinking.Systems;
|
||||
|
||||
/// <summary>
|
||||
/// This handles automatically linking autolinked entities at round-start.
|
||||
/// </summary>
|
||||
public sealed class AutoLinkSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SignalLinkerSystem _signalLinkerSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _deviceLinkSystem = default!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
@@ -29,7 +30,7 @@ public sealed class AutoLinkSystem : EntitySystem
|
||||
if (rxXform.GridUid != xform.GridUid)
|
||||
continue;
|
||||
|
||||
_signalLinkerSystem.TryLinkDefaults(receiver.Owner, uid, null);
|
||||
_deviceLinkSystem.LinkDefaults(null, uid, receiver.Owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
114
Content.Server/DeviceLinking/Systems/DeviceLinkSystem.cs
Normal file
114
Content.Server/DeviceLinking/Systems/DeviceLinkSystem.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.DeviceLinking.Systems;
|
||||
|
||||
public sealed class DeviceLinkSystem : SharedDeviceLinkSystem
|
||||
{
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SignalTransmitterComponent, MapInitEvent>(OnTransmitterStartup);
|
||||
SubscribeLocalEvent<DeviceLinkSinkComponent, DeviceNetworkPacketEvent>(OnPacketReceived);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Moves existing links from machine linking to device linking to ensure linked things still work even when the map wasn't updated yet
|
||||
/// </summary>
|
||||
private void OnTransmitterStartup(EntityUid sourceUid, SignalTransmitterComponent transmitterComponent, MapInitEvent args)
|
||||
{
|
||||
if (!TryComp<DeviceLinkSourceComponent?>(sourceUid, out var sourceComponent))
|
||||
return;
|
||||
|
||||
Dictionary<EntityUid, List<(string, string)>> outputs = new();
|
||||
foreach (var (transmitterPort, receiverPorts) in transmitterComponent.Outputs)
|
||||
{
|
||||
|
||||
foreach (var receiverPort in receiverPorts)
|
||||
{
|
||||
outputs.GetOrNew(receiverPort.Uid).Add((transmitterPort, receiverPort.Port));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (sinkUid, links) in outputs)
|
||||
{
|
||||
SaveLinks(null, sourceUid, sinkUid, links, sourceComponent);
|
||||
}
|
||||
}
|
||||
|
||||
#region Sending & Receiving
|
||||
/// <summary>
|
||||
/// Sends a network payload directed at the sink entity.
|
||||
/// Just raises a <see cref="SignalReceivedEvent"/> without data if the source or the sink doesn't have a <see cref="DeviceNetworkComponent"/>
|
||||
/// </summary>
|
||||
/// <param name="uid">The source uid that invokes the port</param>
|
||||
/// <param name="port">The port to invoke</param>
|
||||
/// <param name="data">Optional data to send along</param>
|
||||
/// <param name="sourceComponent"></param>
|
||||
public void InvokePort(EntityUid uid, string port, NetworkPayload? data = null, DeviceLinkSourceComponent? sourceComponent = null)
|
||||
{
|
||||
if (!Resolve(uid, ref sourceComponent) || !sourceComponent.Outputs.TryGetValue(port, out var sinks))
|
||||
return;
|
||||
|
||||
foreach (var sinkUid in sinks)
|
||||
{
|
||||
if (!sourceComponent.LinkedPorts.TryGetValue(sinkUid, out var links))
|
||||
continue;
|
||||
|
||||
foreach (var (source, sink) in links)
|
||||
{
|
||||
if (source != port)
|
||||
continue;
|
||||
|
||||
//Just skip using device networking if the source or the sink doesn't support it
|
||||
if (!HasComp<DeviceNetworkComponent>(uid) || !TryComp<DeviceNetworkComponent?>(sinkUid, out var sinkNetworkComponent))
|
||||
{
|
||||
var eventArgs = new SignalReceivedEvent(sink, uid);
|
||||
|
||||
RaiseLocalEvent(sinkUid, ref eventArgs);
|
||||
continue;
|
||||
}
|
||||
|
||||
var payload = new NetworkPayload()
|
||||
{
|
||||
[InvokedPort] = sink
|
||||
};
|
||||
|
||||
if (data != null)
|
||||
{
|
||||
//Prevent overriding the invoked port
|
||||
data.Remove(InvokedPort);
|
||||
foreach (var (key, value) in data)
|
||||
{
|
||||
payload.Add(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
_deviceNetworkSystem.QueuePacket(uid, sinkNetworkComponent.Address, payload, sinkNetworkComponent.ReceiveFrequency);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the payload has a port defined and if the port is present on the sink.
|
||||
/// Raises a <see cref="SignalReceivedEvent"/> containing the payload when the check passes
|
||||
/// </summary>
|
||||
private void OnPacketReceived(EntityUid uid, DeviceLinkSinkComponent component, DeviceNetworkPacketEvent args)
|
||||
{
|
||||
if (!args.Data.TryGetValue(InvokedPort, out string? port) || !(component.Ports?.Contains(port) ?? false))
|
||||
return;
|
||||
|
||||
var eventArgs = new SignalReceivedEvent(port, args.Sender, args.Data);
|
||||
RaiseLocalEvent(uid, ref eventArgs);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
@@ -1,16 +1,17 @@
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.Doors.Systems;
|
||||
using Content.Server.MachineLinking.System;
|
||||
using Content.Shared.Doors.Components;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Content.Server.MachineLinking.System
|
||||
namespace Content.Server.DeviceLinking.Systems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class DoorSignalControlSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly DoorSystem _doorSystem = default!;
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -18,13 +19,13 @@ namespace Content.Server.MachineLinking.System
|
||||
SubscribeLocalEvent<DoorSignalControlComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<DoorSignalControlComponent, SignalReceivedEvent>(OnSignalReceived);
|
||||
}
|
||||
|
||||
|
||||
private void OnInit(EntityUid uid, DoorSignalControlComponent component, ComponentInit args)
|
||||
{
|
||||
_signalSystem.EnsureReceiverPorts(uid, component.OpenPort, component.ClosePort, component.TogglePort);
|
||||
_signalSystem.EnsureSinkPorts(uid, component.OpenPort, component.ClosePort, component.TogglePort);
|
||||
}
|
||||
|
||||
private void OnSignalReceived(EntityUid uid, DoorSignalControlComponent component, SignalReceivedEvent args)
|
||||
private void OnSignalReceived(EntityUid uid, DoorSignalControlComponent component, ref SignalReceivedEvent args)
|
||||
{
|
||||
if (!TryComp(uid, out DoorComponent? door))
|
||||
return;
|
||||
@@ -1,14 +1,15 @@
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.MachineLinking.System;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server.MachineLinking.System
|
||||
namespace Content.Server.DeviceLinking.Systems
|
||||
{
|
||||
public sealed class SignalSwitchSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -20,7 +21,7 @@ namespace Content.Server.MachineLinking.System
|
||||
|
||||
private void OnInit(EntityUid uid, SignalSwitchComponent component, ComponentInit args)
|
||||
{
|
||||
_signalSystem.EnsureTransmitterPorts(uid, component.OnPort, component.OffPort);
|
||||
_signalSystem.EnsureSourcePorts(uid, component.OnPort, component.OffPort);
|
||||
}
|
||||
|
||||
private void OnActivated(EntityUid uid, SignalSwitchComponent component, ActivateInWorldEvent args)
|
||||
@@ -1,13 +1,13 @@
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Timing;
|
||||
|
||||
namespace Content.Server.MachineLinking.System;
|
||||
namespace Content.Server.DeviceLinking.Systems;
|
||||
|
||||
public sealed class SignallerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SignalLinkerSystem _signal = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _link = default!;
|
||||
[Dependency] private readonly UseDelaySystem _useDelay = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -21,14 +21,14 @@ public sealed class SignallerSystem : EntitySystem
|
||||
|
||||
private void OnInit(EntityUid uid, SignallerComponent component, ComponentInit args)
|
||||
{
|
||||
_signal.EnsureTransmitterPorts(uid, component.Port);
|
||||
_link.EnsureSourcePorts(uid, component.Port);
|
||||
}
|
||||
|
||||
private void OnUseInHand(EntityUid uid, SignallerComponent component, UseInHandEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
_signal.InvokePort(uid, component.Port);
|
||||
_link.InvokePort(uid, component.Port);
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public sealed class SignallerSystem : EntitySystem
|
||||
if (hasUseDelay)
|
||||
_useDelay.BeginDelay(uid, useDelay);
|
||||
|
||||
_signal.InvokePort(uid, component.Port);
|
||||
_link.InvokePort(uid, component.Port);
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.DeviceLinking.Components;
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.MachineLinking;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.MachineLinking.System
|
||||
namespace Content.Server.DeviceLinking.Systems
|
||||
{
|
||||
public sealed class TwoWayLeverSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
|
||||
const string _leftToggleImage = "rotate_ccw.svg.192dpi.png";
|
||||
@@ -25,7 +24,7 @@ namespace Content.Server.MachineLinking.System
|
||||
|
||||
private void OnInit(EntityUid uid, TwoWayLeverComponent component, ComponentInit args)
|
||||
{
|
||||
_signalSystem.EnsureTransmitterPorts(uid, component.LeftPort, component.RightPort, component.MiddlePort);
|
||||
_signalSystem.EnsureSourcePorts(uid, component.LeftPort, component.RightPort, component.MiddlePort);
|
||||
}
|
||||
|
||||
private void OnActivated(EntityUid uid, TwoWayLeverComponent component, ActivateInWorldEvent args)
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Linq;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.Interaction;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
using System.Linq;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.UserInterface;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Content.Shared.DeviceNetwork;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Content.Shared.DeviceNetwork.Systems;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.DeviceNetwork.Systems;
|
||||
@@ -19,11 +25,14 @@ namespace Content.Server.DeviceNetwork.Systems;
|
||||
public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
{
|
||||
[Dependency] private readonly DeviceListSystem _deviceListSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _deviceLinkSystem = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessSystem = default!;
|
||||
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
|
||||
|
||||
[Dependency] private readonly AudioSystem _audioSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
|
||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -32,17 +41,23 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, MapInitEvent>(OnMapInit);
|
||||
|
||||
//Interaction
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, AfterInteractEvent>((uid, component, args) => OnUsed(uid, component, args.Target, args.User, args.CanReach)); //TODO: Replace with utility verb?
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, AfterInteractEvent>(AfterInteract); //TODO: Replace with utility verb?
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, ExaminedEvent>(DoExamine);
|
||||
|
||||
//Verbs
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, GetVerbsEvent<UtilityVerb>>(OnAddInteractVerb);
|
||||
SubscribeLocalEvent<DeviceNetworkComponent, GetVerbsEvent<AlternativeVerb>>(OnAddAlternativeSaveDeviceVerb);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, GetVerbsEvent<AlternativeVerb>>(OnAddSwitchModeVerb);
|
||||
|
||||
//UI
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, BoundUIClosedEvent>(OnUiClosed);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorRemoveDeviceMessage>(OnRemoveDevice);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorClearDevicesMessage>(OnClearDevice);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorLinksSaveMessage>(OnSaveLinks);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorClearLinksMessage>(OnClearLinks);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorToggleLinkMessage>(OnToggleLinks);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, NetworkConfiguratorButtonPressedMessage>(OnConfigButtonPressed);
|
||||
SubscribeLocalEvent<NetworkConfiguratorComponent, ActivatableUIOpenAttemptEvent>(OnUiOpenAttempt);
|
||||
|
||||
SubscribeLocalEvent<DeviceListComponent, ComponentRemove>(OnComponentRemoved);
|
||||
}
|
||||
@@ -62,14 +77,14 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
}
|
||||
|
||||
//The network configurator is a handheld device. There can only ever be an ui session open for the player holding the device.
|
||||
_uiSystem.GetUiOrNull(uid, NetworkConfiguratorUiKey.Configure)?.CloseAll();
|
||||
_uiSystem.TryCloseAll(uid, NetworkConfiguratorUiKey.Configure);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, NetworkConfiguratorComponent component, MapInitEvent args)
|
||||
{
|
||||
component.Devices.Clear();
|
||||
UpdateUiState(uid, component);
|
||||
UpdateListUiState(uid, component);
|
||||
}
|
||||
|
||||
private void TryAddNetworkDevice(EntityUid? targetUid, EntityUid configuratorUid, EntityUid userUid,
|
||||
@@ -118,18 +133,65 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
_popupSystem.PopupCursor(Loc.GetString("network-configurator-device-saved", ("address", device.Address), ("device", targetUid)),
|
||||
userUid, PopupType.Medium);
|
||||
|
||||
UpdateUiState(configurator.Owner, configurator);
|
||||
UpdateListUiState(configurator.Owner, configurator);
|
||||
}
|
||||
|
||||
private void TryLinkDevice(EntityUid uid, NetworkConfiguratorComponent configurator, EntityUid? target, EntityUid user)
|
||||
{
|
||||
if (!HasComp<DeviceLinkSourceComponent>(target) && !HasComp<DeviceLinkSinkComponent>(target))
|
||||
return;
|
||||
|
||||
if (configurator.ActiveDeviceLink == target)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("network-configurator-link-mode-stopped"), target.Value, user);
|
||||
configurator.ActiveDeviceLink = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasComp<DeviceLinkSourceComponent>(target) && HasComp<DeviceLinkSourceComponent>(configurator.ActiveDeviceLink)
|
||||
|| HasComp<DeviceLinkSinkComponent>(target) && HasComp<DeviceLinkSinkComponent>(configurator.ActiveDeviceLink))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (configurator.ActiveDeviceLink.HasValue)
|
||||
{
|
||||
OpenDeviceLinkUi( uid, target, user, configurator);
|
||||
return;
|
||||
}
|
||||
|
||||
_popupSystem.PopupEntity(Loc.GetString("network-configurator-link-mode-started", ("device", Name(target.Value))), target.Value, user);
|
||||
configurator.ActiveDeviceLink = target;
|
||||
}
|
||||
|
||||
private void TryLinkDefaults(EntityUid uid, NetworkConfiguratorComponent configurator, EntityUid? targetUid, EntityUid user)
|
||||
{
|
||||
if (!configurator.LinkModeActive || !configurator.ActiveDeviceLink.HasValue
|
||||
|| !targetUid.HasValue || configurator.ActiveDeviceLink == targetUid)
|
||||
return;
|
||||
|
||||
if (!HasComp<DeviceLinkSourceComponent>(targetUid) && !HasComp<DeviceLinkSinkComponent>(targetUid))
|
||||
return;
|
||||
|
||||
if (TryComp(configurator.ActiveDeviceLink, out DeviceLinkSourceComponent? activeSource) && TryComp(targetUid, out DeviceLinkSinkComponent? targetSink))
|
||||
{
|
||||
_deviceLinkSystem.LinkDefaults(user, configurator.ActiveDeviceLink.Value, targetUid.Value, activeSource, targetSink);
|
||||
}
|
||||
else if (TryComp(configurator.ActiveDeviceLink, out DeviceLinkSinkComponent? activeSink) && TryComp(targetUid, out DeviceLinkSourceComponent? targetSource))
|
||||
{
|
||||
_deviceLinkSystem.LinkDefaults(user, targetUid.Value, configurator.ActiveDeviceLink.Value, targetSource, activeSink);
|
||||
}
|
||||
}
|
||||
|
||||
private bool AccessCheck(EntityUid target, EntityUid? user, NetworkConfiguratorComponent component)
|
||||
{
|
||||
if (!TryComp(target, out AccessReaderComponent? reader) || user == null)
|
||||
return false;
|
||||
return true;
|
||||
|
||||
if (_accessSystem.IsAllowed(user.Value, reader))
|
||||
return true;
|
||||
|
||||
SoundSystem.Play(component.SoundNoAccess.GetSound(), Filter.Pvs(user.Value), target, AudioParams.Default.WithVolume(-2f).WithPitchScale(1.2f));
|
||||
_audioSystem.PlayPvs(component.SoundNoAccess, user.Value, AudioParams.Default.WithVolume(-2f).WithPitchScale(1.2f));
|
||||
_popupSystem.PopupEntity(Loc.GetString("network-configurator-device-access-denied"), target, user.Value);
|
||||
|
||||
return false;
|
||||
@@ -137,26 +199,80 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
|
||||
private void OnComponentRemoved(EntityUid uid, DeviceListComponent component, ComponentRemove args)
|
||||
{
|
||||
_uiSystem.GetUiOrNull(uid, NetworkConfiguratorUiKey.Configure)?.CloseAll();
|
||||
_uiSystem.TryCloseAll(uid, NetworkConfiguratorUiKey.Configure);
|
||||
}
|
||||
|
||||
private void SwitchMode(EntityUid? userUid, EntityUid configuratorUid, NetworkConfiguratorComponent configurator)
|
||||
{
|
||||
if (Delay(configurator))
|
||||
return;
|
||||
|
||||
configurator.LinkModeActive = !configurator.LinkModeActive;
|
||||
|
||||
if (!userUid.HasValue)
|
||||
return;
|
||||
|
||||
if (!configurator.LinkModeActive)
|
||||
configurator.ActiveDeviceLink = null;
|
||||
|
||||
var locString = configurator.LinkModeActive ? "network-configurator-mode-link" : "network-configurator-mode-list";
|
||||
_popupSystem.PopupEntity(Loc.GetString("network-configurator-switched-mode", ("mode", Loc.GetString(locString))),
|
||||
configuratorUid, userUid.Value);
|
||||
|
||||
Dirty(configurator);
|
||||
_appearanceSystem.SetData(configuratorUid, NetworkConfiguratorVisuals.Mode, configurator.LinkModeActive);
|
||||
|
||||
var pitch = configurator.LinkModeActive ? 1 : 0.8f;
|
||||
_audioSystem.PlayPvs(configurator.SoundSwitchMode, userUid.Value, AudioParams.Default.WithVolume(1.5f).WithPitchScale(pitch));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the last time this method was called is earlier than the configurators use delay.
|
||||
/// </summary>
|
||||
private bool Delay(NetworkConfiguratorComponent configurator)
|
||||
{
|
||||
var currentTime = _gameTiming.CurTime;
|
||||
if (currentTime < configurator.LastUseAttempt + configurator.UseDelay)
|
||||
return true;
|
||||
|
||||
configurator.LastUseAttempt = currentTime;
|
||||
return false;
|
||||
}
|
||||
|
||||
#region Interactions
|
||||
|
||||
private void DoExamine(EntityUid uid, NetworkConfiguratorComponent component, ExaminedEvent args)
|
||||
{
|
||||
var mode = component.LinkModeActive ? "network-configurator-examine-mode-link" : "network-configurator-examine-mode-list";
|
||||
args.PushMarkup(Loc.GetString("network-configurator-examine-current-mode", ("mode", Loc.GetString(mode))));
|
||||
}
|
||||
|
||||
private void AfterInteract(EntityUid uid, NetworkConfiguratorComponent component, AfterInteractEvent args)
|
||||
{
|
||||
OnUsed(uid, component, args.Target, args.User, args.CanReach);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Either adds a device to the device list or shows the config ui if the target is ant entity with a device list
|
||||
/// </summary>
|
||||
private void OnUsed(EntityUid uid, NetworkConfiguratorComponent component, EntityUid? target, EntityUid user, bool canReach = true)
|
||||
private void OnUsed(EntityUid uid, NetworkConfiguratorComponent configurator, EntityUid? target, EntityUid user, bool canReach = true)
|
||||
{
|
||||
if (!canReach)
|
||||
if (!canReach || !target.HasValue)
|
||||
return;
|
||||
|
||||
if (!HasComp<DeviceListComponent>(target))
|
||||
if (configurator.LinkModeActive)
|
||||
{
|
||||
TryAddNetworkDevice(target, user, component);
|
||||
TryLinkDevice(uid, configurator, target, user);
|
||||
return;
|
||||
}
|
||||
|
||||
OpenDeviceListUi(target, user, component);
|
||||
if (!HasComp<DeviceListComponent>(target))
|
||||
{
|
||||
TryAddNetworkDevice(target, user, configurator);
|
||||
return;
|
||||
}
|
||||
|
||||
OpenDeviceListUi(target, user, configurator);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -166,22 +282,32 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
/// <summary>
|
||||
/// Adds the interaction verb which is either configuring device lists or saving a device onto the configurator
|
||||
/// </summary>
|
||||
private void OnAddInteractVerb(EntityUid uid, NetworkConfiguratorComponent component, GetVerbsEvent<UtilityVerb> args)
|
||||
private void OnAddInteractVerb(EntityUid uid, NetworkConfiguratorComponent configurator, GetVerbsEvent<UtilityVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || !args.Using.HasValue || !HasComp<DeviceNetworkComponent>(args.Target))
|
||||
if (!args.CanAccess || !args.CanInteract || !args.Using.HasValue)
|
||||
return;
|
||||
|
||||
var isDeviceList = HasComp<DeviceListComponent>(args.Target);
|
||||
|
||||
UtilityVerb verb = new()
|
||||
var verb = new UtilityVerb
|
||||
{
|
||||
Text = Loc.GetString(isDeviceList ? "network-configurator-configure" : "network-configurator-save-device"),
|
||||
Icon = isDeviceList ?
|
||||
new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")) :
|
||||
new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/in.svg.192dpi.png")),
|
||||
Act = () => OnUsed(uid, component, args.Target, args.User),
|
||||
Act = () => OnUsed(uid, configurator, args.Target, args.User),
|
||||
Impact = LogImpact.Low
|
||||
};
|
||||
|
||||
if (configurator.LinkModeActive)
|
||||
{
|
||||
var linkStarted = configurator.ActiveDeviceLink.HasValue;
|
||||
verb.Text = Loc.GetString(linkStarted ? "network-configurator-link" : "network-configurator-start-link");
|
||||
verb.Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/in.svg.192dpi.png"));
|
||||
}
|
||||
else if (!HasComp<DeviceNetworkComponent>(args.Target))
|
||||
{
|
||||
var isDeviceList = HasComp<DeviceListComponent>(args.Target);
|
||||
verb.Text = Loc.GetString(isDeviceList ? "network-configurator-configure" : "network-configurator-save-device");
|
||||
verb.Icon = isDeviceList
|
||||
? new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/settings.svg.192dpi.png"))
|
||||
: new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/in.svg.192dpi.png"));
|
||||
}
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
@@ -193,8 +319,39 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
/// </summary>
|
||||
private void OnAddAlternativeSaveDeviceVerb(EntityUid uid, DeviceNetworkComponent component, GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || !args.Using.HasValue || !HasComp<NetworkConfiguratorComponent>(args.Using.Value)
|
||||
|| !HasComp<DeviceListComponent>(args.Target))
|
||||
if (!args.CanAccess || !args.CanInteract || !args.Using.HasValue
|
||||
|| !TryComp<NetworkConfiguratorComponent>(args.Using.Value, out var configurator))
|
||||
return;
|
||||
|
||||
if (!configurator.LinkModeActive && HasComp<DeviceListComponent>(args.Target))
|
||||
{
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Text = Loc.GetString("network-configurator-save-device"),
|
||||
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/in.svg.192dpi.png")),
|
||||
Act = () => TryAddNetworkDevice(args.Target, args.Using.Value, args.User),
|
||||
Impact = LogImpact.Low
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
return;
|
||||
}
|
||||
|
||||
if (configurator is {LinkModeActive: true, ActiveDeviceLink: { }} && (HasComp<DeviceLinkSinkComponent>(args.Target) || HasComp<DeviceLinkSourceComponent>(args.Target)))
|
||||
{
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Text = Loc.GetString("network-configurator-link-defaults"),
|
||||
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/in.svg.192dpi.png")),
|
||||
Act = () => TryLinkDefaults(args.Using.Value, configurator, args.Target, args.User),
|
||||
Impact = LogImpact.Low
|
||||
};
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAddSwitchModeVerb(EntityUid uid, NetworkConfiguratorComponent configurator, GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if (!args.CanAccess || !args.CanInteract || !args.Using.HasValue || !HasComp<NetworkConfiguratorComponent>(args.Target))
|
||||
return;
|
||||
|
||||
AlternativeVerb verb = new()
|
||||
@@ -211,11 +368,57 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
|
||||
#region UI
|
||||
|
||||
private void OpenDeviceLinkUi(EntityUid configuratorUid, EntityUid? targetUid, EntityUid userUid, NetworkConfiguratorComponent configurator)
|
||||
{
|
||||
if (Delay(configurator))
|
||||
return;
|
||||
|
||||
if (!targetUid.HasValue || !configurator.ActiveDeviceLink.HasValue || !TryComp(userUid, out ActorComponent? actor) || !AccessCheck(targetUid.Value, userUid, configurator))
|
||||
return;
|
||||
|
||||
|
||||
_uiSystem.TryOpen(configuratorUid, NetworkConfiguratorUiKey.Link, actor.PlayerSession);
|
||||
configurator.DeviceLinkTarget = targetUid;
|
||||
|
||||
|
||||
if (TryComp(configurator.ActiveDeviceLink, out DeviceLinkSourceComponent? activeSource) && TryComp(targetUid, out DeviceLinkSinkComponent? targetSink))
|
||||
{
|
||||
UpdateLinkUiState(configuratorUid, configurator.ActiveDeviceLink.Value, targetUid.Value, activeSource, targetSink);
|
||||
}
|
||||
else if (TryComp(configurator.ActiveDeviceLink, out DeviceLinkSinkComponent? activeSink)
|
||||
&& TryComp(targetUid, out DeviceLinkSourceComponent? targetSource))
|
||||
{
|
||||
UpdateLinkUiState(configuratorUid, targetUid.Value, configurator.ActiveDeviceLink.Value, targetSource, activeSink);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateLinkUiState(EntityUid configuratorUid, EntityUid sourceUid, EntityUid sinkUid,
|
||||
DeviceLinkSourceComponent? sourceComponent = null, DeviceLinkSinkComponent? sinkComponent = null,
|
||||
DeviceNetworkComponent? sourceNetworkComponent = null, DeviceNetworkComponent? sinkNetworkComponent = null)
|
||||
{
|
||||
if (!Resolve(sourceUid, ref sourceComponent) || !Resolve(sinkUid, ref sinkComponent))
|
||||
return;
|
||||
|
||||
var sources = _deviceLinkSystem.GetSourcePorts(sourceUid, sourceComponent);
|
||||
var sinks = _deviceLinkSystem.GetSinkPorts(sinkUid, sinkComponent);
|
||||
var links = _deviceLinkSystem.GetLinks(sourceUid, sinkUid, sourceComponent);
|
||||
var defaults = _deviceLinkSystem.GetDefaults(sources);
|
||||
|
||||
var sourceAddress = Resolve(sourceUid, ref sourceNetworkComponent) ? sourceNetworkComponent.Address : "";
|
||||
var sinkAddress = Resolve(sinkUid, ref sinkNetworkComponent) ? sinkNetworkComponent.Address : "";
|
||||
|
||||
var state = new DeviceLinkUserInterfaceState(sources, sinks, links, sourceAddress, sinkAddress, defaults);
|
||||
_uiSystem.TrySetUiState(configuratorUid, NetworkConfiguratorUiKey.Link, state);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the config ui. It can be used to modify the devices in the targets device list.
|
||||
/// </summary>
|
||||
private void OpenDeviceListUi(EntityUid? targetUid, EntityUid userUid, NetworkConfiguratorComponent configurator)
|
||||
{
|
||||
if (Delay(configurator))
|
||||
return;
|
||||
|
||||
if (!targetUid.HasValue || !TryComp(userUid, out ActorComponent? actor) || !AccessCheck(targetUid.Value, userUid, configurator))
|
||||
return;
|
||||
|
||||
@@ -233,7 +436,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
/// <summary>
|
||||
/// Sends the list of saved devices to the ui
|
||||
/// </summary>
|
||||
private void UpdateUiState(EntityUid uid, NetworkConfiguratorComponent component)
|
||||
private void UpdateListUiState(EntityUid uid, NetworkConfiguratorComponent component)
|
||||
{
|
||||
HashSet<(string address, string name)> devices = new();
|
||||
HashSet<string> invalidDevices = new();
|
||||
@@ -264,6 +467,12 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
private void OnUiClosed(EntityUid uid, NetworkConfiguratorComponent component, BoundUIClosedEvent args)
|
||||
{
|
||||
component.ActiveDeviceList = null;
|
||||
|
||||
if (args.UiKey is NetworkConfiguratorUiKey.Link)
|
||||
{
|
||||
component.ActiveDeviceLink = null;
|
||||
component.DeviceLinkTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -272,7 +481,7 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
private void OnRemoveDevice(EntityUid uid, NetworkConfiguratorComponent component, NetworkConfiguratorRemoveDeviceMessage args)
|
||||
{
|
||||
component.Devices.Remove(args.Address);
|
||||
UpdateUiState(uid, component);
|
||||
UpdateListUiState(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -281,7 +490,61 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
private void OnClearDevice(EntityUid uid, NetworkConfiguratorComponent component, NetworkConfiguratorClearDevicesMessage _)
|
||||
{
|
||||
component.Devices.Clear();
|
||||
UpdateUiState(uid, component);
|
||||
UpdateListUiState(uid, component);
|
||||
}
|
||||
|
||||
private void OnClearLinks(EntityUid uid, NetworkConfiguratorComponent configurator, NetworkConfiguratorClearLinksMessage args)
|
||||
{
|
||||
if (!configurator.ActiveDeviceLink.HasValue || !configurator.DeviceLinkTarget.HasValue)
|
||||
return;
|
||||
|
||||
if (HasComp<DeviceLinkSourceComponent>(configurator.ActiveDeviceLink))
|
||||
{
|
||||
_deviceLinkSystem.RemoveSinkFromSource(configurator.ActiveDeviceLink.Value, configurator.DeviceLinkTarget.Value);
|
||||
UpdateLinkUiState(uid, configurator.ActiveDeviceLink.Value, configurator.DeviceLinkTarget.Value);
|
||||
}
|
||||
else if (HasComp<DeviceLinkSourceComponent>(configurator.DeviceLinkTarget))
|
||||
{
|
||||
_deviceLinkSystem.RemoveSinkFromSource(configurator.DeviceLinkTarget.Value, configurator.ActiveDeviceLink.Value);
|
||||
UpdateLinkUiState(uid, configurator.DeviceLinkTarget.Value, configurator.ActiveDeviceLink.Value);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnToggleLinks(EntityUid uid, NetworkConfiguratorComponent configurator, NetworkConfiguratorToggleLinkMessage args)
|
||||
{
|
||||
if (!configurator.ActiveDeviceLink.HasValue || !configurator.DeviceLinkTarget.HasValue)
|
||||
return;
|
||||
|
||||
if (TryComp(configurator.ActiveDeviceLink, out DeviceLinkSourceComponent? activeSource))
|
||||
{
|
||||
_deviceLinkSystem.ToggleLink(args.Session.AttachedEntity, configurator.ActiveDeviceLink.Value, configurator.DeviceLinkTarget.Value, args.Source, args.Sink, activeSource);
|
||||
UpdateLinkUiState(uid, configurator.ActiveDeviceLink.Value, configurator.DeviceLinkTarget.Value, activeSource);
|
||||
}
|
||||
else if (TryComp(configurator.DeviceLinkTarget, out DeviceLinkSourceComponent? targetSource))
|
||||
{
|
||||
_deviceLinkSystem.ToggleLink(args.Session.AttachedEntity, configurator.DeviceLinkTarget.Value, configurator.ActiveDeviceLink.Value, args.Source, args.Sink, targetSource);
|
||||
UpdateLinkUiState(uid, configurator.DeviceLinkTarget.Value, configurator.ActiveDeviceLink.Value, targetSource);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves links set by the device link UI
|
||||
/// </summary>
|
||||
private void OnSaveLinks(EntityUid uid, NetworkConfiguratorComponent configurator, NetworkConfiguratorLinksSaveMessage args)
|
||||
{
|
||||
if (!configurator.ActiveDeviceLink.HasValue || !configurator.DeviceLinkTarget.HasValue)
|
||||
return;
|
||||
|
||||
if (TryComp(configurator.ActiveDeviceLink, out DeviceLinkSourceComponent? activeSource))
|
||||
{
|
||||
_deviceLinkSystem.SaveLinks(args.Session.AttachedEntity, configurator.ActiveDeviceLink.Value, configurator.DeviceLinkTarget.Value, args.Links, activeSource);
|
||||
UpdateLinkUiState(uid, configurator.ActiveDeviceLink.Value, configurator.DeviceLinkTarget.Value, activeSource);
|
||||
}
|
||||
else if (TryComp(configurator.DeviceLinkTarget, out DeviceLinkSourceComponent? targetSource))
|
||||
{
|
||||
_deviceLinkSystem.SaveLinks(args.Session.AttachedEntity, configurator.DeviceLinkTarget.Value, configurator.ActiveDeviceLink.Value, args.Links, targetSource);
|
||||
UpdateLinkUiState(uid, configurator.DeviceLinkTarget.Value, configurator.ActiveDeviceLink.Value, targetSource);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -307,11 +570,9 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
break;
|
||||
case NetworkConfiguratorButtonKey.Copy:
|
||||
component.Devices = _deviceListSystem.GetDeviceList(component.ActiveDeviceList.Value);
|
||||
UpdateUiState(uid, component);
|
||||
UpdateListUiState(uid, component);
|
||||
return;
|
||||
case NetworkConfiguratorButtonKey.Show:
|
||||
// This should be done client-side.
|
||||
// _deviceListSystem.ToggleVisualization(component.ActiveDeviceList.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -330,5 +591,11 @@ public sealed class NetworkConfiguratorSystem : SharedNetworkConfiguratorSystem
|
||||
_deviceListSystem.GetDeviceList(component.ActiveDeviceList.Value)
|
||||
.Select(v => (v.Key, MetaData(v.Value).EntityName)).ToHashSet()));
|
||||
}
|
||||
|
||||
private void OnUiOpenAttempt(EntityUid uid, NetworkConfiguratorComponent configurator, ActivatableUIOpenAttemptEvent args)
|
||||
{
|
||||
if (configurator.LinkModeActive)
|
||||
args.Cancel();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Tools.Components;
|
||||
@@ -8,7 +9,6 @@ using Content.Shared.Doors.Systems;
|
||||
using Content.Shared.Interaction;
|
||||
using Robust.Server.GameObjects;
|
||||
using Content.Shared.Wires;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.MachineLinking.System;
|
||||
|
||||
namespace Content.Server.Doors.Systems
|
||||
@@ -44,7 +44,7 @@ namespace Content.Server.Doors.Systems
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSignalReceived(EntityUid uid, AirlockComponent component, SignalReceivedEvent args)
|
||||
private void OnSignalReceived(EntityUid uid, AirlockComponent component, ref SignalReceivedEvent args)
|
||||
{
|
||||
if (args.Port == component.AutoClosePort)
|
||||
{
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.Explosion.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.MachineLinking.System;
|
||||
|
||||
namespace Content.Server.Explosion.EntitySystems
|
||||
{
|
||||
public sealed partial class TriggerSystem
|
||||
{
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
private void InitializeSignal()
|
||||
{
|
||||
SubscribeLocalEvent<TriggerOnSignalComponent,SignalReceivedEvent>(OnSignalReceived);
|
||||
SubscribeLocalEvent<TriggerOnSignalComponent,ComponentInit>(OnInit);
|
||||
}
|
||||
|
||||
private void OnSignalReceived(EntityUid uid, TriggerOnSignalComponent component, SignalReceivedEvent args)
|
||||
private void OnSignalReceived(EntityUid uid, TriggerOnSignalComponent component, ref SignalReceivedEvent args)
|
||||
{
|
||||
if (args.Port != component.Port)
|
||||
return;
|
||||
@@ -23,7 +22,7 @@ namespace Content.Server.Explosion.EntitySystems
|
||||
}
|
||||
private void OnInit(EntityUid uid, TriggerOnSignalComponent component, ComponentInit args)
|
||||
{
|
||||
_signalSystem.EnsureReceiverPorts(uid, component.Port);
|
||||
_signalSystem.EnsureSinkPorts(uid, component.Port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,6 @@ using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.Ghost;
|
||||
using Content.Server.Light.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.MachineLinking.System;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Temperature.Components;
|
||||
using Content.Shared.Audio;
|
||||
@@ -22,6 +20,8 @@ using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Server.Emp;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
|
||||
namespace Content.Server.Light.EntitySystems
|
||||
{
|
||||
@@ -37,7 +37,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger= default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
@@ -69,7 +69,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
private void OnInit(EntityUid uid, PoweredLightComponent light, ComponentInit args)
|
||||
{
|
||||
light.LightBulbContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, LightBulbContainer);
|
||||
_signalSystem.EnsureReceiverPorts(uid, light.OnPort, light.OffPort, light.TogglePort);
|
||||
_signalSystem.EnsureSinkPorts(uid, light.OnPort, light.OffPort, light.TogglePort);
|
||||
}
|
||||
|
||||
private void OnMapInit(EntityUid uid, PoweredLightComponent light, MapInitEvent args)
|
||||
@@ -354,7 +354,7 @@ namespace Content.Server.Light.EntitySystems
|
||||
_appearance.SetData(uid, PoweredLightVisuals.Blinking, isNowBlinking, appearance);
|
||||
}
|
||||
|
||||
private void OnSignalReceived(EntityUid uid, PoweredLightComponent component, SignalReceivedEvent args)
|
||||
private void OnSignalReceived(EntityUid uid, PoweredLightComponent component, ref SignalReceivedEvent args)
|
||||
{
|
||||
if (args.Port == component.OffPort)
|
||||
SetState(uid, false, component);
|
||||
|
||||
@@ -3,13 +3,13 @@ using Content.Server.MachineLinking.System;
|
||||
namespace Content.Server.MachineLinking.Components
|
||||
{
|
||||
[DataDefinition]
|
||||
public struct PortIdentifier
|
||||
public readonly struct PortIdentifier
|
||||
{
|
||||
[DataField("uid")]
|
||||
public EntityUid Uid;
|
||||
public readonly EntityUid Uid;
|
||||
|
||||
[DataField("port")]
|
||||
public string Port;
|
||||
public readonly string Port;
|
||||
|
||||
public PortIdentifier(EntityUid uid, string port)
|
||||
{
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Content.Server.MachineLinking.Events
|
||||
{
|
||||
public sealed class PortDisconnectedEvent : EntityEventArgs
|
||||
{
|
||||
public readonly string Port;
|
||||
|
||||
public PortDisconnectedEvent(string port)
|
||||
{
|
||||
Port = port;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
namespace Content.Server.MachineLinking.Events
|
||||
{
|
||||
public sealed class SignalReceivedEvent : EntityEventArgs
|
||||
{
|
||||
public readonly string Port;
|
||||
public readonly EntityUid? Trigger;
|
||||
|
||||
public SignalReceivedEvent(string port, EntityUid? trigger)
|
||||
{
|
||||
Port = port;
|
||||
Trigger = trigger;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
using System.Linq;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Tools;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.MachineLinking;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Shared.MachineLinking.Events;
|
||||
using Content.Server.Database;
|
||||
|
||||
namespace Content.Server.MachineLinking.System
|
||||
{
|
||||
@@ -140,7 +138,10 @@ namespace Content.Server.MachineLinking.System
|
||||
return;
|
||||
|
||||
foreach (var receiver in receivers)
|
||||
RaiseLocalEvent(receiver.Uid, new SignalReceivedEvent(receiver.Port, uid), false);
|
||||
{
|
||||
var eventArgs = new SignalReceivedEvent(receiver.Port, uid);
|
||||
RaiseLocalEvent(receiver.Uid, ref eventArgs);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTransmitterStartup(EntityUid uid, SignalTransmitterComponent transmitter, ComponentStartup args)
|
||||
|
||||
@@ -1,30 +1,28 @@
|
||||
using Content.Server.Climbing;
|
||||
using Content.Server.Cloning;
|
||||
using Content.Server.Medical.Components;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Destructible;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.DragDrop;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Containers;
|
||||
using Content.Server.MachineLinking.System;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.Cloning.Components;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Mobs.Components;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Server.Containers;
|
||||
using Robust.Server.GameObjects;
|
||||
using static Content.Shared.MedicalScanner.SharedMedicalScannerComponent; // Hmm...
|
||||
|
||||
namespace Content.Server.Medical
|
||||
{
|
||||
public sealed class MedicalScannerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||
[Dependency] private readonly ClimbSystem _climbSystem = default!;
|
||||
[Dependency] private readonly CloningConsoleSystem _cloningConsoleSystem = default!;
|
||||
@@ -70,7 +68,7 @@ namespace Content.Server.Medical
|
||||
{
|
||||
base.Initialize();
|
||||
scannerComponent.BodyContainer = _containerSystem.EnsureContainer<ContainerSlot>(uid, $"scanner-bodyContainer");
|
||||
_signalSystem.EnsureReceiverPorts(uid, MedicalScannerComponent.ScannerPort);
|
||||
_signalSystem.EnsureSinkPorts(uid, MedicalScannerComponent.ScannerPort);
|
||||
}
|
||||
|
||||
private void OnRelayMovement(EntityUid uid, MedicalScannerComponent scannerComponent, ref ContainerRelayMovementEntityEvent args)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Content.Server.MachineLinking.Events;
|
||||
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.MachineLinking.System;
|
||||
using Content.Server.Materials;
|
||||
using Content.Server.Power.Components;
|
||||
@@ -9,7 +11,6 @@ using Content.Shared.Physics.Controllers;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Content.Server.Physics.Controllers;
|
||||
@@ -17,8 +18,8 @@ namespace Content.Server.Physics.Controllers;
|
||||
public sealed class ConveyorController : SharedConveyorController
|
||||
{
|
||||
[Dependency] private readonly FixtureSystem _fixtures = default!;
|
||||
[Dependency] private readonly DeviceLinkSystem _signalSystem = default!;
|
||||
[Dependency] private readonly MaterialReclaimerSystem _materialReclaimer = default!;
|
||||
[Dependency] private readonly SignalLinkerSystem _signalSystem = default!;
|
||||
[Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
|
||||
@@ -37,7 +38,7 @@ public sealed class ConveyorController : SharedConveyorController
|
||||
|
||||
private void OnInit(EntityUid uid, ConveyorComponent component, ComponentInit args)
|
||||
{
|
||||
_signalSystem.EnsureReceiverPorts(uid, component.ReversePort, component.ForwardPort, component.OffPort);
|
||||
_signalSystem.EnsureSinkPorts(uid, component.ReversePort, component.ForwardPort, component.OffPort);
|
||||
|
||||
if (TryComp<PhysicsComponent>(uid, out var physics))
|
||||
{
|
||||
@@ -76,7 +77,7 @@ public sealed class ConveyorController : SharedConveyorController
|
||||
_appearance.SetData(uid, ConveyorVisuals.State, component.Powered ? component.State : ConveyorState.Off);
|
||||
}
|
||||
|
||||
private void OnSignalReceived(EntityUid uid, ConveyorComponent component, SignalReceivedEvent args)
|
||||
private void OnSignalReceived(EntityUid uid, ConveyorComponent component, ref SignalReceivedEvent args)
|
||||
{
|
||||
if (args.Port == component.OffPort)
|
||||
SetState(uid, ConveyorState.Off, component);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.MachineLinking.Components;
|
||||
using Content.Server.MachineLinking.Events;
|
||||
using Content.Server.Paper;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Research.Systems;
|
||||
@@ -10,7 +10,7 @@ using Content.Server.Xenoarchaeology.Equipment.Components;
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts;
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.MachineLinking.Events;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Research.Components;
|
||||
using Content.Shared.Xenoarchaeology.Equipment;
|
||||
@@ -168,10 +168,10 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
|
||||
|
||||
private void OnNewLink(EntityUid uid, AnalysisConsoleComponent component, NewLinkEvent args)
|
||||
{
|
||||
if (!TryComp<ArtifactAnalyzerComponent>(args.Receiver, out var analyzer))
|
||||
if (!TryComp<ArtifactAnalyzerComponent>(args.Sink, out var analyzer))
|
||||
return;
|
||||
|
||||
component.AnalyzerEntity = args.Receiver;
|
||||
component.AnalyzerEntity = args.Sink;
|
||||
analyzer.Console = uid;
|
||||
|
||||
UpdateUserInterface(uid, component);
|
||||
|
||||
Reference in New Issue
Block a user