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,7 +1,7 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.DeviceNetwork;
|
||||
namespace Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
|
||||
@@ -1,14 +1,24 @@
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Content.Shared.DeviceNetwork.Systems;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
|
||||
namespace Content.Shared.DeviceNetwork;
|
||||
namespace Content.Shared.DeviceNetwork.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
[Access(typeof(SharedNetworkConfiguratorSystem))]
|
||||
public sealed class NetworkConfiguratorComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Determines whether the configurator is in linking mode or list mode
|
||||
/// </summary>
|
||||
[DataField("linkModeActive")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool LinkModeActive = false;
|
||||
|
||||
/// <summary>
|
||||
/// The entity containing a <see cref="DeviceListComponent"/> this configurator is currently interacting with
|
||||
/// </summary>
|
||||
@@ -16,22 +26,48 @@ public sealed class NetworkConfiguratorComponent : Component
|
||||
public EntityUid? ActiveDeviceList = null;
|
||||
|
||||
/// <summary>
|
||||
/// The list of devices stored in the configurator-
|
||||
/// The entity containing a <see cref="DeviceLinkSourceComponent"/> or <see cref="DeviceLinkSinkComponent"/> this configurator is currently interacting with.<br/>
|
||||
/// If this is set the configurator is in linking mode.
|
||||
/// </summary>
|
||||
[DataField("activeDeviceLink")]
|
||||
public EntityUid? ActiveDeviceLink = null;
|
||||
|
||||
/// <summary>
|
||||
/// The target device this configurator is currently linking with the <see cref="ActiveDeviceLink"/>
|
||||
/// </summary>
|
||||
[DataField("deviceLinkTarget")]
|
||||
public EntityUid? DeviceLinkTarget = null;
|
||||
|
||||
/// <summary>
|
||||
/// The list of devices stored in the configurator
|
||||
/// </summary>
|
||||
[DataField("devices")]
|
||||
public Dictionary<string, EntityUid> Devices = new();
|
||||
|
||||
[DataField("useDelay")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan UseDelay = TimeSpan.FromSeconds(0.5);
|
||||
|
||||
[DataField("lastUseAttempt", customTypeSerializer:typeof(TimeOffsetSerializer))]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan LastUseAttempt;
|
||||
|
||||
[DataField("soundNoAccess")]
|
||||
public SoundSpecifier SoundNoAccess = new SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
|
||||
|
||||
[DataField("soundSwitchMode")]
|
||||
public SoundSpecifier SoundSwitchMode = new SoundPathSpecifier("/Audio/Machines/beep.ogg");
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NetworkConfiguratorComponentState : ComponentState
|
||||
{
|
||||
public readonly EntityUid? ActiveDeviceList;
|
||||
public readonly bool LinkModeActive;
|
||||
|
||||
public NetworkConfiguratorComponentState(EntityUid? activeDeviceList)
|
||||
public NetworkConfiguratorComponentState(EntityUid? activeDeviceList, bool linkModeActive)
|
||||
{
|
||||
ActiveDeviceList = activeDeviceList;
|
||||
LinkModeActive = linkModeActive;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ namespace Content.Shared.DeviceNetwork;
|
||||
public enum NetworkConfiguratorUiKey
|
||||
{
|
||||
List,
|
||||
Configure
|
||||
Configure,
|
||||
Link
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
@@ -52,3 +53,33 @@ public sealed class NetworkConfiguratorButtonPressedMessage : BoundUserInterface
|
||||
ButtonKey = buttonKey;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NetworkConfiguratorClearLinksMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NetworkConfiguratorToggleLinkMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly string Source;
|
||||
public readonly string Sink;
|
||||
|
||||
public NetworkConfiguratorToggleLinkMessage(string source, string sink)
|
||||
{
|
||||
Source = source;
|
||||
Sink = sink;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class NetworkConfiguratorLinksSaveMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public readonly List<(string source, string sink)> Links;
|
||||
|
||||
public NetworkConfiguratorLinksSaveMessage(List<(string source, string sink)> links)
|
||||
{
|
||||
Links = links;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using Content.Shared.DeviceLinking;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.DeviceNetwork;
|
||||
|
||||
@@ -23,3 +24,24 @@ public sealed class DeviceListUserInterfaceState : BoundUserInterfaceState
|
||||
DeviceList = deviceList;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class DeviceLinkUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public readonly List<SourcePortPrototype> Sources;
|
||||
public readonly List<SinkPortPrototype> Sinks;
|
||||
public readonly HashSet<(string source, string sink)> Links;
|
||||
public readonly List<(string source, string sink)>? Defaults;
|
||||
public readonly string SourceAddress;
|
||||
public readonly string SinkAddress;
|
||||
|
||||
public DeviceLinkUserInterfaceState(List<SourcePortPrototype> sources, List<SinkPortPrototype> sinks, HashSet<(string source, string sink)> links, string sourceAddress, string sinkAddress, List<(string source, string sink)>? defaults = default)
|
||||
{
|
||||
Links = links;
|
||||
SourceAddress = sourceAddress;
|
||||
SinkAddress = sinkAddress;
|
||||
Defaults = defaults;
|
||||
Sources = sources;
|
||||
Sinks = sinks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.DeviceNetwork;
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.DeviceNetwork;
|
||||
namespace Content.Shared.DeviceNetwork.Systems;
|
||||
|
||||
public abstract class SharedNetworkConfiguratorSystem : EntitySystem
|
||||
{
|
||||
@@ -17,7 +18,7 @@ public abstract class SharedNetworkConfiguratorSystem : EntitySystem
|
||||
private void GetNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp,
|
||||
ref ComponentGetState args)
|
||||
{
|
||||
args.State = new NetworkConfiguratorComponentState(comp.ActiveDeviceList);
|
||||
args.State = new NetworkConfiguratorComponentState(comp.ActiveDeviceList, comp.LinkModeActive);
|
||||
}
|
||||
|
||||
private void HandleNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp,
|
||||
@@ -29,9 +30,22 @@ public abstract class SharedNetworkConfiguratorSystem : EntitySystem
|
||||
}
|
||||
|
||||
comp.ActiveDeviceList = state.ActiveDeviceList;
|
||||
comp.LinkModeActive = state.LinkModeActive;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ClearAllOverlaysEvent : InstantActionEvent
|
||||
{
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum NetworkConfiguratorVisuals
|
||||
{
|
||||
Mode
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum NetworkConfiguratorLayers
|
||||
{
|
||||
ModeLight
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user