mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 19:01:13 +03:00
* Resolve StationEvent warnings * fix misuses of ent after rename, paracusia flip * oh god more rules * comments, whitespace, unnecessary precision * comments, NotNull->IsNull oops * more consistent ent vs. ent.Owner, whitespace * Greytide: "with accress from... access groups"
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using Content.Server.StationEvents.Components;
|
|
using Content.Shared.AlertLevel;
|
|
using Content.Shared.GameTicking.Components;
|
|
using Content.Shared.Station.Components;
|
|
|
|
namespace Content.Server.StationEvents.Events;
|
|
|
|
/// <summary>
|
|
/// Handler for events setting the station alert level.
|
|
/// </summary>
|
|
/// <seealso cref="AlertLevelInterceptionRuleComponent"/>
|
|
public sealed partial class AlertLevelInterceptionRule : StationEventSystem<AlertLevelInterceptionRuleComponent>
|
|
{
|
|
[Dependency] private AlertLevelSystem _alertLevel = default!;
|
|
|
|
protected override void Started(Entity<AlertLevelInterceptionRuleComponent, GameRuleComponent> ent,
|
|
ref GameRuleStartedEvent args)
|
|
{
|
|
base.Started(ent, ref args);
|
|
|
|
if (!Station.TryGetRandomStation<StationEventEligibleComponent>(out var chosenStation))
|
|
return;
|
|
|
|
if (!_alertLevel.TryGetLevel(chosenStation.Value.Owner, out var level)
|
|
|| !_alertLevel.TryGetDefaultLevel(chosenStation.Value.Owner, out var defaultLevel)
|
|
|| level != defaultLevel)
|
|
return;
|
|
|
|
_alertLevel.SetLevel(chosenStation.Value.Owner,
|
|
ent.Comp1.AlertLevel,
|
|
force: true);
|
|
}
|
|
}
|