alarmables now check if the type of alarm matches the alarms they can check (optional)

This commit is contained in:
vulppine
2022-08-22 11:30:37 -07:00
parent a3909f0aaf
commit 84027b4e67
4 changed files with 26 additions and 10 deletions

View File

@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Server.Atmos.Monitor.Components;
using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Components;
@@ -27,6 +28,8 @@ namespace Content.Server.Atmos.Monitor.Systems
public const string AlertSource = "atmos_alarm_source";
public const string AlertTypes = "atmos_alarm_types";
/// <summary>
/// Syncs alerts from this alarm receiver to other alarm receivers.
/// Creates a network effect as a result. Note: if the alert receiver
@@ -63,15 +66,7 @@ namespace Content.Server.Atmos.Monitor.Systems
return;
}
var isValid = false;
foreach (var source in sourceTags)
{
if (component.SyncWithTags.Contains(source))
{
isValid = true;
break;
}
}
var isValid = sourceTags.Any(source => component.SyncWithTags.Contains(source));
if (!isValid)
{
@@ -88,6 +83,16 @@ namespace Content.Server.Atmos.Monitor.Systems
return;
}
if (args.Data.TryGetValue(AlertTypes, out HashSet<AtmosMonitorThresholdType>? types))
{
isValid = types.Any(type => component.MonitorAlertTypes.Contains(type));
if (!isValid)
{
break;
}
}
if (!component.NetworkAlarmStates.ContainsKey(args.SenderAddress))
{
component.NetworkAlarmStates.Add(args.SenderAddress, state);