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,8 +1,12 @@
|
||||
using Content.Server.Doors.Components;
|
||||
using Content.Server.Atmos.Monitor.Components;
|
||||
using Content.Server.Atmos.Monitor.Systems;
|
||||
using Content.Server.Doors.Components;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Doors;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Log;
|
||||
|
||||
namespace Content.Server.Doors.Systems
|
||||
{
|
||||
@@ -18,6 +22,7 @@ namespace Content.Server.Doors.Systems
|
||||
SubscribeLocalEvent<FirelockComponent, DoorClickShouldActivateEvent>(OnDoorClickShouldActivate);
|
||||
SubscribeLocalEvent<FirelockComponent, BeforeDoorPryEvent>(OnBeforeDoorPry);
|
||||
SubscribeLocalEvent<FirelockComponent, BeforeDoorAutoCloseEvent>(OnBeforeDoorAutoclose);
|
||||
SubscribeLocalEvent<FirelockComponent, AtmosMonitorAlarmEvent>(OnAtmosAlarm);
|
||||
}
|
||||
|
||||
private void OnBeforeDoorOpened(EntityUid uid, FirelockComponent component, BeforeDoorOpenedEvent args)
|
||||
@@ -62,8 +67,31 @@ namespace Content.Server.Doors.Systems
|
||||
|
||||
private void OnBeforeDoorAutoclose(EntityUid uid, FirelockComponent component, BeforeDoorAutoCloseEvent args)
|
||||
{
|
||||
// Firelocks can't autoclose, they must be manually closed
|
||||
args.Cancel();
|
||||
// Make firelocks autoclose, but only if the last alarm type it
|
||||
// remembers was a danger. This is to prevent people from
|
||||
// flooding hallways with endless bad air/fire.
|
||||
if (!EntityManager.TryGetComponent(uid, out AtmosAlarmableComponent alarmable))
|
||||
{
|
||||
args.Cancel();
|
||||
return;
|
||||
}
|
||||
if (alarmable.HighestNetworkState != AtmosMonitorAlarmType.Danger)
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnAtmosAlarm(EntityUid uid, FirelockComponent component, AtmosMonitorAlarmEvent args)
|
||||
{
|
||||
if (component.DoorComponent == null) return;
|
||||
|
||||
if (args.HighestNetworkType == AtmosMonitorAlarmType.Normal)
|
||||
{
|
||||
if (component.DoorComponent.State == SharedDoorComponent.DoorState.Closed)
|
||||
component.DoorComponent.Open();
|
||||
}
|
||||
else if (args.HighestNetworkType == AtmosMonitorAlarmType.Danger)
|
||||
{
|
||||
component.EmergencyPressureStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user