Files
tbd-station-14/Content.Server/GameTicking/Rules/SecretRuleSystem.cs
Kara b9a0894d7c Event refactor (#9589)
* 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
2022-07-10 20:48:41 -05:00

44 lines
1.3 KiB
C#

using System.Linq;
using Content.Server.GameTicking.Presets;
using Content.Server.GameTicking.Rules.Configurations;
using Content.Shared.Random;
using Content.Shared.Random.Helpers;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Server.GameTicking.Rules;
public sealed class SecretRuleSystem : GameRuleSystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly GameTicker _ticker = default!;
public override string Prototype => "Secret";
public override void Started()
{
PickRule();
}
public override void Ended()
{
// noop
// Preset should already handle it.
return;
}
private void PickRule()
{
// TODO: This doesn't consider what can't start due to minimum player count, but currently there's no way to know anyway.
// as they use cvars.
var preset = _prototypeManager.Index<WeightedRandomPrototype>("Secret").Pick(_random);
Logger.InfoS("gamepreset", $"Selected {preset} for secret.");
foreach (var rule in _prototypeManager.Index<GamePresetPrototype>(preset).Rules)
{
_ticker.AddGameRule(_prototypeManager.Index<GameRulePrototype>(rule));
}
}
}