Clear and reregister devices for atmos alarms (#11391)

* deregister sensors upon device list update and re-register after clearing devices

* fire alarms, too

* adds the last set of known devices to the device list update event

* update UI upon clearing everything out

* addresses reviews
This commit is contained in:
Flipp Syder
2022-10-01 09:36:59 -07:00
committed by GitHub
parent 2b6c1de174
commit 8389bde2c0
5 changed files with 55 additions and 4 deletions

View File

@@ -24,6 +24,7 @@ public abstract class SharedDeviceListSystem : EntitySystem
if (!Resolve(uid, ref deviceList))
return DeviceListUpdateResult.NoComponent;
var oldDevices = deviceList.Devices.ToList();
var newDevices = merge ? new HashSet<EntityUid>(deviceList.Devices) : new();
var devicesList = devices.ToList();
@@ -35,7 +36,7 @@ public abstract class SharedDeviceListSystem : EntitySystem
deviceList.Devices = newDevices;
RaiseLocalEvent(uid, new DeviceListUpdateEvent(devicesList));
RaiseLocalEvent(uid, new DeviceListUpdateEvent(oldDevices, devicesList));
Dirty(deviceList);
@@ -71,11 +72,13 @@ public abstract class SharedDeviceListSystem : EntitySystem
public sealed class DeviceListUpdateEvent : EntityEventArgs
{
public DeviceListUpdateEvent(List<EntityUid> devices)
public DeviceListUpdateEvent(List<EntityUid> oldDevices, List<EntityUid> devices)
{
OldDevices = oldDevices;
Devices = devices;
}
public List<EntityUid> OldDevices { get; }
public List<EntityUid> Devices { get; }
}