StationSystem/jobs/partial spawning refactor (#7580)
* Partial work on StationSystem refactor. * WIP station jobs API. * forgor to fire off grid events. * Partial implementation of StationSpawningSystem * whoops infinite loop. * Spawners should work now. * it compiles. * tfw * Vestigial code cleanup. * fix station deletion. * attempt to make tests go brr * add latejoin spawnpoints to test maps. * make sure the station still exists while destructing spawners. * forgot an exists check. * destruction order check. * hopefully fix final test. * fail-safe radstorm. * Deep-clean job code further. This is bugged!!!!! * Fix job bug. (init order moment) * whooo cleanup * New job selection algorithm that tries to distribute fairly across stations. * small nitpicks * Give the heads their weights to replace the head field. * make overflow assign take a station list. * moment * Fixes and test #1 of many. * please fix nullspace * AssignJobs should no longer even consider showing up on a trace. * add comment. * Introduce station configs, praying i didn't miss something. * in one small change stations are now fully serializable. * Further doc comments. * whoops. * Solve bug where assignjobs didn't account for roundstart. * Fix spawning, improve the API. Caught an oversight in stationsystem that should've broke everything but didn't, whoops. * Goodbye JobController. * minor fix.. * fix test fail, remove debug logs. * quick serialization fixes. * fixes.. * sus * partialing * Update Content.Server/Station/Systems/StationJobsSystem.Roundstart.cs Co-authored-by: Kara <lunarautomaton6@gmail.com> * Use dirtying to avoid rebuilding the list 2,100 times. * add a bajillion more lines of docs (mostly in AssignJobs so i don't ever forget how it works) * Update Content.IntegrationTests/Tests/Station/StationJobsTest.cs Co-authored-by: Kara <lunarautomaton6@gmail.com> * Add the Mysteriously Missing Captain Check. * Put maprender back the way it belongs. * I love addressing reviews. * Update Content.Server/Station/Systems/StationJobsSystem.cs Co-authored-by: Kara <lunarautomaton6@gmail.com> * doc cleanup. * Fix bureaucratic error, add job slot tests. * zero cost abstractions when * cri * saner error. * Fix spawning failing certain tests due to gameticker not handling falliability correctly. Can't fix this until I refactor the rest of spawning code. * submodule gaming * Packedenger. * Documentation consistency. Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
@@ -1,11 +1,7 @@
|
||||
using Content.Server.Station;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Station;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Administration.Commands.Station;
|
||||
@@ -27,16 +23,17 @@ public sealed class AdjustStationJobCommand : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
var stationSystem = EntitySystem.Get<StationSystem>();
|
||||
var stationJobs = EntitySystem.Get<StationJobsSystem>();
|
||||
|
||||
if (!uint.TryParse(args[0], out var station) || !stationSystem.StationInfo.ContainsKey(new StationId(station)))
|
||||
if (!int.TryParse(args[0], out var stationInt) || !stationSystem.Stations.Contains(new EntityUid(stationInt)))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-station-id-invalid", ("index", 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
var station = new EntityUid(stationInt);
|
||||
|
||||
if (!prototypeManager.TryIndex<JobPrototype>(args[1], out var job))
|
||||
{
|
||||
@@ -52,6 +49,12 @@ public sealed class AdjustStationJobCommand : IConsoleCommand
|
||||
return;
|
||||
}
|
||||
|
||||
stationSystem.AdjustJobsAvailableOnStation(new StationId(station), job, amount);
|
||||
if (amount == -1)
|
||||
{
|
||||
stationJobs.MakeJobUnlimited(station, job);
|
||||
return;
|
||||
}
|
||||
|
||||
stationJobs.TrySetJobSlot(station, job, amount, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using Content.Server.Station;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Station;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.Administration.Commands.Station;
|
||||
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class ListStationJobsCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public string Command => "lsstationjobs";
|
||||
|
||||
public string Description => "Lists all jobs on the given station.";
|
||||
@@ -25,16 +25,18 @@ public sealed class ListStationJobsCommand : IConsoleCommand
|
||||
}
|
||||
|
||||
var stationSystem = EntitySystem.Get<StationSystem>();
|
||||
var stationJobs = EntitySystem.Get<StationJobsSystem>();
|
||||
|
||||
if (!uint.TryParse(args[0], out var station) || !stationSystem.StationInfo.ContainsKey(new StationId(station)))
|
||||
if (!int.TryParse(args[0], out var station) || !stationSystem.Stations.Contains(new EntityUid(station)))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-station-id-invalid", ("index", 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var (job, amount) in stationSystem.StationInfo[new StationId(station)].JobList)
|
||||
foreach (var (job, amount) in stationJobs.GetJobs(new EntityUid(station)))
|
||||
{
|
||||
shell.WriteLine($"{job}: {amount}");
|
||||
var amountText = amount is null ? "Infinite" : amount.ToString();
|
||||
shell.WriteLine($"{job}: {amountText}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Content.Server.Station;
|
||||
using Content.Server.Station.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -8,6 +10,8 @@ namespace Content.Server.Administration.Commands.Station;
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public sealed class ListStationsCommand : IConsoleCommand
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
|
||||
public string Command => "lsstations";
|
||||
|
||||
public string Description => "List all active stations";
|
||||
@@ -16,9 +20,10 @@ public sealed class ListStationsCommand : IConsoleCommand
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
foreach (var (id, station) in EntitySystem.Get<StationSystem>().StationInfo)
|
||||
foreach (var station in EntitySystem.Get<StationSystem>().Stations)
|
||||
{
|
||||
shell.WriteLine($"{id.Id, -2} | {station.Name} | {station.MapPrototype.ID}");
|
||||
var name = _entityManager.GetComponent<MetaDataComponent>(station).EntityName;
|
||||
shell.WriteLine($"{station, -10} | {name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using Content.Server.Station;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Station;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.Administration.Commands.Station;
|
||||
|
||||
@@ -26,12 +23,12 @@ public sealed class RenameStationCommand : IConsoleCommand
|
||||
|
||||
var stationSystem = EntitySystem.Get<StationSystem>();
|
||||
|
||||
if (!uint.TryParse(args[0], out var station) || !stationSystem.StationInfo.ContainsKey(new StationId(station)))
|
||||
if (!int.TryParse(args[0], out var station) || !stationSystem.Stations.Contains(new EntityUid(station)))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-station-id-invalid", ("index", 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
stationSystem.RenameStation(new StationId(station), args[1]);
|
||||
stationSystem.RenameStation(new EntityUid(station), args[1]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user