mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* prediction * fix * reviews * warnings * cleanup * grupdate * bruh --------- Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using Content.Shared.AlertLevel;
|
|
using Content.Shared.Trigger.Components.Effects;
|
|
using Content.Shared.Station;
|
|
|
|
namespace Content.Shared.Trigger.Systems;
|
|
|
|
public sealed partial class AlertLevelChangeOnTriggerSystem : EntitySystem
|
|
{
|
|
[Dependency] private AlertLevelSystem _alertLevel = default!;
|
|
[Dependency] private SharedStationSystem _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;
|
|
|
|
_alertLevel.SetLevel(
|
|
stationUid.Value,
|
|
ent.Comp.Level,
|
|
playSound: ent.Comp.PlaySound,
|
|
announce: ent.Comp.Announce,
|
|
force: ent.Comp.Force);
|
|
|
|
args.Handled = true;
|
|
}
|
|
}
|