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

@@ -1,5 +1,6 @@
using Content.Server.AlertLevel;
using Content.Server.Atmos.Monitor.Components;
using Content.Server.DeviceNetwork.Components;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
@@ -32,6 +33,17 @@ public sealed class FireAlarmSystem : EntitySystem
private void OnDeviceListSync(EntityUid uid, FireAlarmComponent component, DeviceListUpdateEvent args)
{
var query = GetEntityQuery<DeviceNetworkComponent>();
foreach (var device in args.OldDevices)
{
if (!query.TryGetComponent(device, out var deviceNet))
{
continue;
}
_atmosDevNet.Deregister(uid, deviceNet.Address);
}
_atmosDevNet.Register(uid, null);
_atmosDevNet.Sync(uid, null);
}