Files
tbd-station-14/Content.Shared/DeviceNetwork/Systems/SharedNetworkConfiguratorSystem.cs
Flipp Syder 9ace52a6c1 Device link visualizer (#11054)
* shuffles devicelist to shared, adds an overlay for devicelist

* adds space property to overlay

* moves networkconfigurator to shared, makes devicelistsystem clientside check activedevicelist

* dirties components upon change, adds networkedcomponent to sharednetworkconfigurator

* state handlers for networked components

* whoops

* lots of shuffling, renaming, and access changes

* randomizes color for every new entity added to the overlay

* adds a client-side action to clear all network overlays if they're active

* clones action (oops)

* localization, adds a command for clearing network link overlays (in case the action disappears)

* moves the entity manager up into the bui fields

* makes that a dependency

* attempts to just directly get the color from the dict when drawing, now

* fixes up a few comments

* adds dirty on init to devicelistcomponent

* hacky solution related to mapping with a networkconfigurator

* more stricter bound on that hacky solution

* just checks if the life stage is initialized instead of if the entity was initialized

* moves getalldevices to shared

* readds linq import

* tries to ensure that the show button is toggled on if the device we're trying to configure is currently being tracked by the overlay

* some reorganization
2022-09-05 19:55:44 -05:00

53 lines
1.4 KiB
C#

using Content.Shared.Actions;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.DeviceNetwork;
public abstract class SharedNetworkConfiguratorSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<NetworkConfiguratorComponent, ComponentGetState>(GetNetworkConfiguratorState);
SubscribeLocalEvent<NetworkConfiguratorComponent, ComponentHandleState>(HandleNetworkConfiguratorState);
}
private void GetNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp,
ref ComponentGetState args)
{
args.State = new NetworkConfiguratorComponentState(comp.ActiveDeviceList);
}
private void HandleNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp,
ref ComponentHandleState args)
{
if (args.Current is not NetworkConfiguratorComponentState state)
{
return;
}
comp.ActiveDeviceList = state.ActiveDeviceList;
}
}
[Serializable, NetSerializable]
public sealed class ManualDeviceListSyncMessage : BoundUserInterfaceMessage
{
public ManualDeviceListSyncMessage(EntityUid? device, HashSet<EntityUid>? devices)
{
Device = device;
Devices = devices;
}
public EntityUid? Device { get; }
public HashSet<EntityUid>? Devices { get; }
}
public sealed class ClearAllOverlaysEvent : InstantActionEvent
{
}