alarmables now check if the type of alarm matches the alarms they can check (optional)
This commit is contained in:
@@ -48,6 +48,9 @@ namespace Content.Server.Atmos.Monitor.Components
|
||||
[DataField("syncWith", customTypeSerializer: typeof(PrototypeIdHashSetSerializer<TagPrototype>))]
|
||||
public HashSet<string> SyncWithTags { get; } = new();
|
||||
|
||||
[DataField("monitorAlertTypes")]
|
||||
public HashSet<AtmosMonitorThresholdType> MonitorAlertTypes { get; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// If this device should receive only. If it can only
|
||||
/// receive, that means that attempting to sync outwards
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.EntitySystems;
|
||||
@@ -31,8 +32,8 @@ namespace Content.Server.Atmos.Monitor.Systems
|
||||
// Commands
|
||||
public const string AtmosMonitorSetThresholdCmd = "atmos_monitor_set_threshold";
|
||||
|
||||
|
||||
// Packet data
|
||||
public const string AlertTypes = "atmos_monitor_alert_types";
|
||||
|
||||
public const string AtmosMonitorThresholdData = "atmos_monitor_threshold_data";
|
||||
|
||||
@@ -315,6 +316,11 @@ namespace Content.Server.Atmos.Monitor.Systems
|
||||
[AtmosAlarmableSystem.AlertSource] = tags.Tags
|
||||
};
|
||||
|
||||
if (alarms != null)
|
||||
{
|
||||
payload.Add(AtmosAlarmableSystem.AlertTypes, alarms.ToHashSet());
|
||||
}
|
||||
|
||||
foreach (var addr in monitor.RegisteredDevices)
|
||||
{
|
||||
_deviceNetSystem.QueuePacket(monitor.Owner, addr, payload);
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
- AirSensor
|
||||
- GasVent
|
||||
- GasScrubber
|
||||
monitorAlertTypes:
|
||||
- Temperature
|
||||
- type: Tag
|
||||
tags:
|
||||
- FireAlarm
|
||||
|
||||
Reference in New Issue
Block a user