CatStation/Content.Server/StationEvents/Events/AlertLevelInterceptionRule.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

28 lines
996 B
C#

using Content.Server.StationEvents.Components;
using Content.Shared.AlertLevel;
using Content.Shared.GameTicking.Components;
namespace Content.Server.StationEvents.Events;
public sealed partial class AlertLevelInterceptionRule : StationEventSystem<AlertLevelInterceptionRuleComponent>
{
[Dependency] private AlertLevelSystem _alertLevel = default!;
protected override void Started(EntityUid uid, AlertLevelInterceptionRuleComponent component, GameRuleComponent gameRule,
GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
if (!TryGetRandomStation(out var chosenStation))
return;
if (!_alertLevel.TryGetLevel(chosenStation.Value, out var level)
|| !_alertLevel.TryGetDefaultLevel(chosenStation.Value, out var defaultLevel)
|| level != defaultLevel)
return;
_alertLevel.SetLevel(chosenStation.Value,
component.AlertLevel,
force: true);
}
}