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:
@@ -168,6 +168,24 @@ public sealed class AirAlarmSystem : EntitySystem
|
||||
|
||||
private void OnDeviceListUpdate(EntityUid uid, AirAlarmComponent component, DeviceListUpdateEvent args)
|
||||
{
|
||||
var query = GetEntityQuery<DeviceNetworkComponent>();
|
||||
foreach (var device in args.OldDevices)
|
||||
{
|
||||
if (!query.TryGetComponent(device, out var deviceNet))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_atmosDevNetSystem.Deregister(uid, deviceNet.Address);
|
||||
}
|
||||
|
||||
component.ScrubberData.Clear();
|
||||
component.SensorData.Clear();
|
||||
component.VentData.Clear();
|
||||
component.KnownDevices.Clear();
|
||||
|
||||
UpdateUI(uid, component);
|
||||
|
||||
SyncRegisterAllDevices(uid);
|
||||
}
|
||||
|
||||
@@ -294,8 +312,8 @@ public sealed class AirAlarmSystem : EntitySystem
|
||||
}
|
||||
|
||||
var addr = string.Empty;
|
||||
if (EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? netConn)) addr = netConn.Address;
|
||||
|
||||
if (EntityManager.TryGetComponent(uid, out DeviceNetworkComponent? netConn))
|
||||
addr = netConn.Address;
|
||||
|
||||
if (args.AlarmType == AtmosAlarmType.Danger)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user