* Update StationSpawningSystem.cs Web-edit to allow feeding in an existing entity. * Update StationSpawningSystem.cs value type moment * Update StationSpawningSystem.cs * Oh goddamnit this is a refactor now. * awawawa * aaaaaaaaaaa * ee * forgot records. * no records? no records. * What's in a name? * Sloth forcing me to do the refactor properly smh. * e * optional evac in test. * tests pls work * awa --------- Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
60 lines
2.3 KiB
C#
60 lines
2.3 KiB
C#
using System.Linq;
|
|
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;
|
|
|
|
var mod = GetSeverityModifier();
|
|
|
|
// 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(Math.Min(0.25f * MathF.Sqrt(mod), 1.0f)))
|
|
{
|
|
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 * Math.Min(1.0f, 0.20 * mod));
|
|
var upper = (int) (jobList.Count * Math.Min(1.0f, 0.30 * mod));
|
|
// 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);
|
|
}
|
|
}
|
|
}
|
|
}
|