New component: change alert level on trigger (#36581)
* adds component that lets change alert level on trigger * oops, put stuff on wrong folder * missclick, forgor a file * slarti finds ways to improve code * Apply suggestions from code review --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using Content.Server.AlertLevel;
|
||||
using Content.Server.Explosion.EntitySystems;
|
||||
using Content.Server.Station.Systems;
|
||||
|
||||
namespace Content.Server.AlertLevel.Systems;
|
||||
|
||||
public sealed class AlertLevelChangeOnTriggerSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AlertLevelSystem _alertLevelSystem = default!;
|
||||
[Dependency] private readonly StationSystem _station = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<AlertLevelChangeOnTriggerComponent, TriggerEvent>(OnTrigger);
|
||||
}
|
||||
|
||||
private void OnTrigger(Entity<AlertLevelChangeOnTriggerComponent> ent, ref TriggerEvent args)
|
||||
{
|
||||
var stationUid = _station.GetOwningStation(ent.Owner);
|
||||
if (!stationUid.HasValue)
|
||||
return;
|
||||
|
||||
_alertLevelSystem.SetLevel(stationUid.Value, ent.Comp.Level, ent.Comp.PlaySound, ent.Comp.Announce, ent.Comp.Force);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user