Adds fire/air alarms (#5018)
Co-authored-by: Vera Aguilera Puerto <6766154+Zumorica@users.noreply.github.com> Co-authored-by: E F R <602406+Efruit@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
using System;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.Atmos.Monitor.Systems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.DeviceNetwork;
|
||||
using Content.Server.DeviceNetwork.Components;
|
||||
using Content.Server.DeviceNetwork.Systems;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Atmos.Monitor.Components;
|
||||
using Content.Shared.Atmos.Piping.Unary.Components;
|
||||
using Content.Shared.Atmos.Visuals;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -16,6 +25,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
public class GasVentPumpSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly DeviceNetworkSystem _deviceNetSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -23,6 +33,9 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
|
||||
SubscribeLocalEvent<GasVentPumpComponent, AtmosDeviceUpdateEvent>(OnGasVentPumpUpdated);
|
||||
SubscribeLocalEvent<GasVentPumpComponent, AtmosDeviceDisabledEvent>(OnGasVentPumpLeaveAtmosphere);
|
||||
SubscribeLocalEvent<GasVentPumpComponent, AtmosMonitorAlarmEvent>(OnAtmosAlarm);
|
||||
SubscribeLocalEvent<GasVentPumpComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
SubscribeLocalEvent<GasVentPumpComponent, PacketSentEvent>(OnPacketRecv);
|
||||
}
|
||||
|
||||
private void OnGasVentPumpUpdated(EntityUid uid, GasVentPumpComponent vent, AtmosDeviceUpdateEvent args)
|
||||
@@ -99,5 +112,56 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
appearance.SetData(VentPumpVisuals.State, VentPumpState.Off);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAtmosAlarm(EntityUid uid, GasVentPumpComponent component, AtmosMonitorAlarmEvent args)
|
||||
{
|
||||
if (args.HighestNetworkType == AtmosMonitorAlarmType.Danger)
|
||||
{
|
||||
component.Enabled = false;
|
||||
}
|
||||
else if (args.HighestNetworkType == AtmosMonitorAlarmType.Normal)
|
||||
{
|
||||
component.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, GasVentPumpComponent component, PowerChangedEvent args)
|
||||
{
|
||||
component.Enabled = args.Powered;
|
||||
}
|
||||
|
||||
private void OnPacketRecv(EntityUid uid, GasVentPumpComponent component, PacketSentEvent args)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(uid, out DeviceNetworkComponent netConn)
|
||||
|| !EntityManager.TryGetComponent(uid, out AtmosAlarmableComponent alarmable)
|
||||
|| !args.Data.TryGetValue(DeviceNetworkConstants.Command, out var cmd))
|
||||
return;
|
||||
|
||||
var payload = new NetworkPayload();
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case AirAlarmSystem.AirAlarmSyncCmd:
|
||||
payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSyncData);
|
||||
payload.Add(AirAlarmSystem.AirAlarmSyncData, component.ToAirAlarmData());
|
||||
|
||||
_deviceNetSystem.QueuePacket(uid, args.SenderAddress, AirAlarmSystem.Freq, payload);
|
||||
|
||||
return;
|
||||
case AirAlarmSystem.AirAlarmSetData:
|
||||
if (!args.Data.TryGetValue(AirAlarmSystem.AirAlarmSetData, out GasVentPumpData? setData))
|
||||
break;
|
||||
|
||||
component.FromAirAlarmData(setData);
|
||||
alarmable.IgnoreAlarms = setData.IgnoreAlarms;
|
||||
payload.Add(DeviceNetworkConstants.Command, AirAlarmSystem.AirAlarmSetDataStatus);
|
||||
payload.Add(AirAlarmSystem.AirAlarmSetDataStatus, true);
|
||||
|
||||
_deviceNetSystem.QueuePacket(uid, string.Empty, AirAlarmSystem.Freq, payload, true);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user