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:
Flipp Syder
2022-01-01 20:56:24 -08:00
committed by GitHub
parent 903f796b0f
commit b1584793bf
71 changed files with 4340 additions and 29 deletions

View File

@@ -0,0 +1,42 @@
using Content.Server.Atmos.Monitor.Components;
using Content.Server.Power.Components;
using Content.Shared.Atmos.Monitor;
using Content.Shared.Interaction;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Atmos.Monitor.Systems
{
public class FireAlarmSystem : EntitySystem
{
[Dependency] private readonly AtmosMonitorSystem _monitorSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
public override void Initialize()
{
SubscribeLocalEvent<FireAlarmComponent, InteractHandEvent>(OnInteractHand);
}
private void OnInteractHand(EntityUid uid, FireAlarmComponent component, InteractHandEvent args)
{
if (!_interactionSystem.InRangeUnobstructed(args.User, args.Target))
return;
if (EntityManager.TryGetComponent(args.User, out ActorComponent? actor)
&& EntityManager.TryGetComponent(uid, out AtmosMonitorComponent? monitor)
&& EntityManager.TryGetComponent(uid, out ApcPowerReceiverComponent? power)
&& power.Powered)
{
if (monitor.HighestAlarmInNetwork == AtmosMonitorAlarmType.Normal)
{
_monitorSystem.Alert(uid, AtmosMonitorAlarmType.Danger);
}
else
{
_monitorSystem.ResetAll(uid);
}
}
}
}
}