Files
tbd-station-14/Content.Server/Atmos/Monitor/Systems/FireAlarmSystem.cs
Flipp Syder b1584793bf 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>
2022-01-02 15:56:24 +11:00

43 lines
1.5 KiB
C#

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);
}
}
}
}
}