set thresholds from network, reset command, removes OnFire from sensor data
This commit is contained in:
@@ -143,6 +143,21 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reset a single sensor's state.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="uid"></param>
|
||||||
|
/// <param name="address"></param>
|
||||||
|
private void ResetSensor(EntityUid uid, string address)
|
||||||
|
{
|
||||||
|
var payload = new NetworkPayload
|
||||||
|
{
|
||||||
|
[DeviceNetworkConstants.Command] = AtmosMonitorSystem.AtmosMonitorAlarmResetCmd,
|
||||||
|
};
|
||||||
|
|
||||||
|
_deviceNet.QueuePacket(uid, address, payload);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sync this air alarm's mode with the rest of the network.
|
/// Sync this air alarm's mode with the rest of the network.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -39,12 +39,17 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public const string AtmosMonitorAlarmSyncCmd = "atmos_monitor_alarm_sync";
|
public const string AtmosMonitorAlarmSyncCmd = "atmos_monitor_alarm_sync";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Command to reset a single alarm.
|
||||||
|
/// </summary>
|
||||||
|
public const string AtmosMonitorAlarmResetCmd = "atmos_monitor_alarm_reset";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Command to reset all alarms on a network.
|
/// Command to reset all alarms on a network.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string AtmosMonitorAlarmResetAllCmd = "atmos_monitor_alarm_reset_all";
|
public const string AtmosMonitorAlarmResetAllCmd = "atmos_monitor_alarm_reset_all";
|
||||||
|
|
||||||
public const string AtmosMonitorSetThresholdData = "atmos_monitor_set_threshold";
|
public const string AtmosMonitorSetThresholdCmd = "atmos_monitor_set_threshold";
|
||||||
|
|
||||||
// Packet data
|
// Packet data
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -69,6 +74,10 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
|
|
||||||
public const string AtmosMonitorThresholdData = "atmos_monitor_threshold_data";
|
public const string AtmosMonitorThresholdData = "atmos_monitor_threshold_data";
|
||||||
|
|
||||||
|
public const string AtmosMonitorThresholdDataType = "atmos_monitor_threshold_type";
|
||||||
|
|
||||||
|
public const string AtmosMonitorThresholdGasType = "atmos_monitor_threshold_gas";
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<AtmosMonitorComponent, ComponentInit>(OnAtmosMonitorInit);
|
SubscribeLocalEvent<AtmosMonitorComponent, ComponentInit>(OnAtmosMonitorInit);
|
||||||
@@ -190,6 +199,10 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
&& !component.NetworkAlarmStates.TryAdd(args.SenderAddress, state))
|
&& !component.NetworkAlarmStates.TryAdd(args.SenderAddress, state))
|
||||||
component.NetworkAlarmStates[args.SenderAddress] = state;
|
component.NetworkAlarmStates[args.SenderAddress] = state;
|
||||||
break;
|
break;
|
||||||
|
case AtmosMonitorAlarmResetCmd:
|
||||||
|
Reset(uid);
|
||||||
|
// Don't clear alarm states here.
|
||||||
|
break;
|
||||||
case AtmosMonitorAlarmResetAllCmd:
|
case AtmosMonitorAlarmResetAllCmd:
|
||||||
if (args.Data.TryGetValue(AtmosMonitorAlarmSrc, out string? resetSrc)
|
if (args.Data.TryGetValue(AtmosMonitorAlarmSrc, out string? resetSrc)
|
||||||
&& alarmable.AlarmedByPrototypes.Contains(resetSrc))
|
&& alarmable.AlarmedByPrototypes.Contains(resetSrc))
|
||||||
@@ -197,6 +210,15 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
component.LastAlarmState = AtmosMonitorAlarmType.Normal;
|
component.LastAlarmState = AtmosMonitorAlarmType.Normal;
|
||||||
component.NetworkAlarmStates.Clear();
|
component.NetworkAlarmStates.Clear();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case AtmosMonitorSetThresholdCmd:
|
||||||
|
if (args.Data.TryGetValue(AtmosMonitorThresholdData, out AtmosAlarmThreshold? thresholdData)
|
||||||
|
&& args.Data.TryGetValue(AtmosMonitorThresholdDataType, out AtmosMonitorThresholdType? thresholdType))
|
||||||
|
{
|
||||||
|
args.Data.TryGetValue(AtmosMonitorThresholdGasType, out Gas? gas);
|
||||||
|
SetThreshold(uid, thresholdType.Value, thresholdData, gas);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case AirAlarmSystem.AirAlarmSyncCmd:
|
case AirAlarmSystem.AirAlarmSyncCmd:
|
||||||
var payload = new NetworkPayload();
|
var payload = new NetworkPayload();
|
||||||
@@ -213,9 +235,8 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
component.TileGas.Pressure,
|
component.TileGas.Pressure,
|
||||||
component.TileGas.Temperature,
|
component.TileGas.Temperature,
|
||||||
component.TileGas.TotalMoles,
|
component.TileGas.TotalMoles,
|
||||||
component.HighestAlarmInNetwork,
|
component.LastAlarmState,
|
||||||
gases,
|
gases,
|
||||||
false,
|
|
||||||
component.PressureThreshold ?? new(),
|
component.PressureThreshold ?? new(),
|
||||||
component.TemperatureThreshold ?? new(),
|
component.TemperatureThreshold ?? new(),
|
||||||
component.GasThresholds ?? new()
|
component.GasThresholds ?? new()
|
||||||
@@ -225,15 +246,6 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
_deviceNetSystem.QueuePacket(uid, args.SenderAddress, payload);
|
_deviceNetSystem.QueuePacket(uid, args.SenderAddress, payload);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (component.DisplayMaxAlarmInNet)
|
|
||||||
{
|
|
||||||
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent))
|
|
||||||
appearanceComponent.SetData(AtmosMonitorVisuals.AlarmType, component.HighestAlarmInNetwork);
|
|
||||||
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnPowerChangedEvent(EntityUid uid, AtmosMonitorComponent component, PowerChangedEvent args)
|
private void OnPowerChangedEvent(EntityUid uid, AtmosMonitorComponent component, PowerChangedEvent args)
|
||||||
@@ -262,9 +274,6 @@ namespace Content.Server.Atmos.Monitor.Systems
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent))
|
|
||||||
appearanceComponent.SetData(AtmosMonitorVisuals.AlarmType, component.LastAlarmState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFireEvent(EntityUid uid, AtmosMonitorComponent component, ref TileFireEvent args)
|
private void OnFireEvent(EntityUid uid, AtmosMonitorComponent component, ref TileFireEvent args)
|
||||||
|
|||||||
@@ -4,14 +4,13 @@ namespace Content.Shared.Atmos.Monitor;
|
|||||||
|
|
||||||
public sealed class AtmosSensorData : IAtmosDeviceData
|
public sealed class AtmosSensorData : IAtmosDeviceData
|
||||||
{
|
{
|
||||||
public AtmosSensorData(float pressure, float temperature, float totalMoles, AtmosMonitorAlarmType alarmState, Dictionary<Gas, float> gases, bool onFire, AtmosAlarmThreshold pressureThreshold, AtmosAlarmThreshold temperatureThreshold, Dictionary<Gas, AtmosAlarmThreshold> gasThresholds)
|
public AtmosSensorData(float pressure, float temperature, float totalMoles, AtmosMonitorAlarmType alarmState, Dictionary<Gas, float> gases, AtmosAlarmThreshold pressureThreshold, AtmosAlarmThreshold temperatureThreshold, Dictionary<Gas, AtmosAlarmThreshold> gasThresholds)
|
||||||
{
|
{
|
||||||
Pressure = pressure;
|
Pressure = pressure;
|
||||||
Temperature = temperature;
|
Temperature = temperature;
|
||||||
TotalMoles = totalMoles;
|
TotalMoles = totalMoles;
|
||||||
AlarmState = alarmState;
|
AlarmState = alarmState;
|
||||||
Gases = gases;
|
Gases = gases;
|
||||||
OnFire = onFire;
|
|
||||||
PressureThreshold = pressureThreshold;
|
PressureThreshold = pressureThreshold;
|
||||||
TemperatureThreshold = temperatureThreshold;
|
TemperatureThreshold = temperatureThreshold;
|
||||||
GasThresholds = gasThresholds;
|
GasThresholds = gasThresholds;
|
||||||
@@ -43,10 +42,6 @@ public sealed class AtmosSensorData : IAtmosDeviceData
|
|||||||
/// Current number of gases on this sensor.
|
/// Current number of gases on this sensor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<Gas, float> Gases { get; }
|
public Dictionary<Gas, float> Gases { get; }
|
||||||
/// <summary>
|
|
||||||
/// If this sensor is currently detecting a fire.
|
|
||||||
/// </summary>
|
|
||||||
public bool OnFire { get; }
|
|
||||||
|
|
||||||
public AtmosAlarmThreshold PressureThreshold { get; }
|
public AtmosAlarmThreshold PressureThreshold { get; }
|
||||||
public AtmosAlarmThreshold TemperatureThreshold { get; }
|
public AtmosAlarmThreshold TemperatureThreshold { get; }
|
||||||
|
|||||||
Reference in New Issue
Block a user