Remove devices from device lists when they get deleted (#16783)

* Implement device network device shutdown subscribtion
Implement removing devices from device lists when they get deleted

* Improve name and doc comment for DeviceShutDownEvent

* Change ShutdownSubscriber data field tag

* Change UpdateRemovalSubscription name to UpdateShutdownSubscription
This commit is contained in:
Julian Giebel
2023-05-26 00:08:22 +02:00
committed by GitHub
parent a02753545d
commit 2bb1fde4dc
8 changed files with 157 additions and 67 deletions

View File

@@ -2,7 +2,7 @@ using System.Linq;
using Content.Shared.DeviceNetwork.Components;
using Robust.Shared.GameStates;
namespace Content.Shared.DeviceNetwork;
namespace Content.Shared.DeviceNetwork.Systems;
public abstract class SharedDeviceListSystem : EntitySystem
{
@@ -36,6 +36,8 @@ public abstract class SharedDeviceListSystem : EntitySystem
deviceList.Devices = newDevices;
UpdateShutdownSubscription(uid, devicesList, oldDevices);
RaiseLocalEvent(uid, new DeviceListUpdateEvent(oldDevices, devicesList));
Dirty(deviceList);
@@ -52,6 +54,10 @@ public abstract class SharedDeviceListSystem : EntitySystem
return component.Devices;
}
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(comp.Devices, comp.IsAllowList, comp.HandleIncomingPackets);