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

@@ -48,6 +48,9 @@ namespace Content.Server.Atmos.Monitor.Components
[DataField("syncWith", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<TagPrototype>))] [DataField("syncWith", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<TagPrototype>))]
public HashSet<string> SyncWithTags { get; } = new(); public HashSet<string> SyncWithTags { get; } = new();
[DataField("monitorAlertTypes")]
public HashSet<AtmosMonitorThresholdType> MonitorAlertTypes { get; } = new();
/// <summary> /// <summary>
/// If this device should receive only. If it can only /// If this device should receive only. If it can only
/// receive, that means that attempting to sync outwards /// receive, that means that attempting to sync outwards

View File

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

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Server.Atmos.Monitor.Components; using Content.Server.Atmos.Monitor.Components;
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Server.Atmos.Piping.EntitySystems; using Content.Server.Atmos.Piping.EntitySystems;
@@ -31,8 +32,8 @@ namespace Content.Server.Atmos.Monitor.Systems
// Commands // Commands
public const string AtmosMonitorSetThresholdCmd = "atmos_monitor_set_threshold"; public const string AtmosMonitorSetThresholdCmd = "atmos_monitor_set_threshold";
// Packet data // Packet data
public const string AlertTypes = "atmos_monitor_alert_types";
public const string AtmosMonitorThresholdData = "atmos_monitor_threshold_data"; public const string AtmosMonitorThresholdData = "atmos_monitor_threshold_data";
@@ -315,6 +316,11 @@ namespace Content.Server.Atmos.Monitor.Systems
[AtmosAlarmableSystem.AlertSource] = tags.Tags [AtmosAlarmableSystem.AlertSource] = tags.Tags
}; };
if (alarms != null)
{
payload.Add(AtmosAlarmableSystem.AlertTypes, alarms.ToHashSet());
}
foreach (var addr in monitor.RegisteredDevices) foreach (var addr in monitor.RegisteredDevices)
{ {
_deviceNetSystem.QueuePacket(monitor.Owner, addr, payload); _deviceNetSystem.QueuePacket(monitor.Owner, addr, payload);

View File

@@ -23,6 +23,8 @@
- AirSensor - AirSensor
- GasVent - GasVent
- GasScrubber - GasScrubber
monitorAlertTypes:
- Temperature
- type: Tag - type: Tag
tags: tags:
- FireAlarm - FireAlarm