Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -1,17 +1,10 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.DeviceNetwork.Systems;
|
||||
|
||||
public abstract class SharedDeviceListSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<DeviceListComponent, ComponentGetState>(GetDeviceListState);
|
||||
SubscribeLocalEvent<DeviceListComponent, ComponentHandleState>(HandleDeviceListState);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the device list stored on this entity.
|
||||
/// </summary>
|
||||
@@ -57,23 +50,6 @@ public abstract class SharedDeviceListSystem : EntitySystem
|
||||
protected virtual void UpdateShutdownSubscription(EntityUid uid, List<EntityUid> devicesList, List<EntityUid> oldDevices)
|
||||
{
|
||||
}
|
||||
|
||||
private void GetDeviceListState(EntityUid uid, DeviceListComponent comp, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new DeviceListComponentState(GetNetEntitySet(comp.Devices), comp.IsAllowList, comp.HandleIncomingPackets);
|
||||
}
|
||||
|
||||
private void HandleDeviceListState(EntityUid uid, DeviceListComponent comp, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not DeviceListComponentState state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
comp.Devices = EnsureEntitySet<DeviceListComponent>(state.Devices, uid);
|
||||
comp.HandleIncomingPackets = state.HandleIncomingPackets;
|
||||
comp.IsAllowList = state.IsAllowList;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class DeviceListUpdateEvent : EntityEventArgs
|
||||
|
||||
@@ -1,37 +1,10 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.DeviceNetwork.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.DeviceNetwork.Systems;
|
||||
|
||||
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(GetNetEntity(comp.ActiveDeviceList), comp.LinkModeActive);
|
||||
}
|
||||
|
||||
private void HandleNetworkConfiguratorState(EntityUid uid, NetworkConfiguratorComponent comp,
|
||||
ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not NetworkConfiguratorComponentState state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
comp.ActiveDeviceList = EnsureEntity<NetworkConfiguratorComponent>(state.ActiveDeviceList, uid);
|
||||
comp.LinkModeActive = state.LinkModeActive;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed partial class ClearAllOverlaysEvent : InstantActionEvent
|
||||
|
||||
Reference in New Issue
Block a user