mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-09-15 14:52:26 +02:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
33 lines
1.0 KiB
C#
33 lines
1.0 KiB
C#
using Content.Server.AlertLevel;
|
|
using Content.Shared.Trigger;
|
|
using Content.Shared.Trigger.Components.Effects;
|
|
using Content.Server.Station.Systems;
|
|
|
|
namespace Content.Server.Trigger.Systems;
|
|
|
|
public sealed partial class AlertLevelChangeOnTriggerSystem : EntitySystem
|
|
{
|
|
[Dependency] private AlertLevelSystem _alertLevelSystem = default!;
|
|
[Dependency] private StationSystem _station = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<AlertLevelChangeOnTriggerComponent, TriggerEvent>(OnTrigger);
|
|
}
|
|
|
|
private void OnTrigger(Entity<AlertLevelChangeOnTriggerComponent> ent, ref TriggerEvent args)
|
|
{
|
|
if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
|
|
return;
|
|
|
|
var stationUid = _station.GetOwningStation(ent.Owner);
|
|
if (stationUid == null)
|
|
return;
|
|
|
|
_alertLevelSystem.SetLevel(stationUid.Value, ent.Comp.Level, ent.Comp.PlaySound, ent.Comp.Announce, ent.Comp.Force);
|
|
args.Handled = true;
|
|
}
|
|
}
|