Files
crystall-punk-14/Content.Server/StationEvents/Events/BureaucraticErrorRule.cs
Nemanja 161fd6c83c Mega Antag Refactor (#25786)
* Mega Antag Refactor

* last minute delta save

* more workshopping

* more shit

* ok tested this for once

* okkkkk sure

* generic delays for starting rules

* well darn

* nukies partially

* ouagh

* ballin' faded and smonkin wed

* obliterated the diff

* Spread my arms and soak up congratulations

* I've got plenty of love, but nothing to show for it

* but there’s too much sunlight
Shining on my laptop monitor, so I
Can’t see anything with any amount of clarity

* ok this junk

* OOK!

* fubar

* most of sloth's review

* oh boy

* eek

* hell yea!

* ASDFJASDJFvsakcvjkzjnhhhyh
2024-04-25 11:31:45 +10:00

59 lines
2.2 KiB
C#

using System.Linq;
using Content.Server.GameTicking.Components;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Server.StationEvents.Components;
using JetBrains.Annotations;
using Robust.Shared.Random;
namespace Content.Server.StationEvents.Events;
[UsedImplicitly]
public sealed class BureaucraticErrorRule : StationEventSystem<BureaucraticErrorRuleComponent>
{
[Dependency] private readonly StationJobsSystem _stationJobs = default!;
protected override void Started(EntityUid uid, BureaucraticErrorRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
if (!TryGetRandomStation(out var chosenStation, HasComp<StationJobsComponent>))
return;
var jobList = _stationJobs.GetJobs(chosenStation.Value).Keys.ToList();
if (jobList.Count == 0)
return;
// Low chance to completely change up the late-join landscape by closing all positions except infinite slots.
// Lower chance than the /tg/ equivalent of this event.
if (RobustRandom.Prob(0.25f))
{
var chosenJob = RobustRandom.PickAndTake(jobList);
_stationJobs.MakeJobUnlimited(chosenStation.Value, chosenJob); // INFINITE chaos.
foreach (var job in jobList)
{
if (_stationJobs.IsJobUnlimited(chosenStation.Value, job))
continue;
_stationJobs.TrySetJobSlot(chosenStation.Value, job, 0);
}
}
else
{
var lower = (int) (jobList.Count * 0.20);
var upper = (int) (jobList.Count * 0.30);
// Changing every role is maybe a bit too chaotic so instead change 20-30% of them.
var num = RobustRandom.Next(lower, upper);
for (var i = 0; i < num; i++)
{
var chosenJob = RobustRandom.PickAndTake(jobList);
if (_stationJobs.IsJobUnlimited(chosenStation.Value, chosenJob))
continue;
_stationJobs.TryAdjustJobSlot(chosenStation.Value, chosenJob, RobustRandom.Next(-3, 6), clamp: true);
}
}
}
}