CatStation/Content.Shared/Trigger/Systems/AlertLevelChangeOnTriggerSystem.cs
slarticodefast 0b5bacf5c2
Refactor and predict Alert Levels (#41122)
* prediction

* fix

* reviews

* warnings

* cleanup

* grupdate

* bruh

---------

Co-authored-by: Princess Cheeseballs <66055347+Princess-Cheeseballs@users.noreply.github.com>
2026-07-27 05:11:33 +00:00

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