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>
43 lines
1.5 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|