* Station event refactor * Remove clientside `IStationEventManager` we can just use prototypes * Basic API idea * Cruft * first attempt at epicness * okay yeah this shit is really clean * sort out minor stuff * Convert `BreakerFlip` * `BureaucraticError` + general cleanup * `DiseaseOutbreak` * `FalseAlarm` * `GasLeak` * `KudzuGrowth` * `MeteorSwarm` * `MouseMigration` * misc errors * `PowerGridCheck` * `RandomSentience` * `VentClog` * `VentCritters` * `ZombieOutbreak` * Rewrite basic event scheduler * Minor fixes and logging * ooooops * errors + fix * linter * completions, `RuleStarted` property, update loop fixes * Tweaks * Fix #9462 * Basic scheduler update fix, and fixes #8174 * Add test * UI cleanup * really this was just for testing
41 lines
1.2 KiB
C#
41 lines
1.2 KiB
C#
using System.Linq;
|
|
using Content.Server.Power.Components;
|
|
using Content.Server.Power.EntitySystems;
|
|
using JetBrains.Annotations;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.StationEvents.Events;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class BreakerFlip : StationEventSystem
|
|
{
|
|
[Dependency] private readonly ApcSystem _apcSystem = default!;
|
|
|
|
public override string Prototype => "BreakerFlip";
|
|
|
|
public override void Added()
|
|
{
|
|
base.Added();
|
|
|
|
var str = Loc.GetString("station-event-breaker-flip-announcement", ("data", Loc.GetString(Loc.GetString($"random-sentience-event-data-{RobustRandom.Next(1, 6)}"))));
|
|
ChatSystem.DispatchGlobalAnnouncement(str, playDefaultSound: false, colorOverride: Color.Gold);
|
|
}
|
|
|
|
public override void Started()
|
|
{
|
|
base.Started();
|
|
|
|
var allApcs = EntityQuery<ApcComponent>().ToList();
|
|
var toDisable = Math.Min(RobustRandom.Next(3, 7), allApcs.Count);
|
|
if (toDisable == 0)
|
|
return;
|
|
|
|
RobustRandom.Shuffle(allApcs);
|
|
|
|
for (var i = 0; i < toDisable; i++)
|
|
{
|
|
_apcSystem.ApcToggleBreaker(allApcs[i].Owner, allApcs[i]);
|
|
}
|
|
}
|
|
}
|