mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
* Scope creep my ass * why was this shit not pushed???? * gone... * fix that * review plus buildd * asfsafsafsafsafas * grug * burber * I'll fix this later * shrimply die * also this * it's snerf or snuthin * assaads * round snend * aaaa * fix this shit for real * actually, don't start GameRules until MapInit now that I think aboot it. * forgot u * don't actually need this part nullable * Deffer comp removal * one liner * do that too * chungus * Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?) * deferred removal :V * aaaaaaaaaaaaaaa * whhop * Whoop * better * landmine that I placed for myself then forgot about lmao * cleanup * FUCKING `!` * gotovo * amogus * please don't check by metadata I beg * waawsasfdfsasfa * sfafsasfafsas * fdsaasffsasfa * code * fix * fasasffasfasfsad * chungaas * I may be stupid * gra * graaaaaaaaaaaaaaaaa * comment * gra * clearing is not predicted and would require major refactors, so don't cache on client. * lame shit :P * last holes * nukeopsfsafsasafsfafsa * why was that shit public bruh * bubrbgwahrghfaka * dynamic * revert change that did nothing lmao
108 lines
3.6 KiB
C#
108 lines
3.6 KiB
C#
using System.Linq;
|
|
using Content.Server.Administration;
|
|
using Content.Server.Station.Systems;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.Roles;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Toolshed;
|
|
using Robust.Shared.Toolshed.Syntax;
|
|
using Robust.Shared.Toolshed.TypeParsers;
|
|
|
|
namespace Content.Server.Station.Commands;
|
|
|
|
[ToolshedCommand, AdminCommand(AdminFlags.VarEdit)]
|
|
public sealed class JobsCommand : ToolshedCommand
|
|
{
|
|
private ServerStationJobsSystem? _jobs;
|
|
|
|
[CommandImplementation("jobs")]
|
|
public IEnumerable<JobSlotRef> Jobs([PipedArgument] EntityUid station)
|
|
{
|
|
_jobs ??= GetSys<ServerStationJobsSystem>();
|
|
|
|
foreach (var (job, _) in _jobs.GetJobs(station))
|
|
{
|
|
yield return new JobSlotRef(job, station, _jobs, EntityManager);
|
|
}
|
|
}
|
|
|
|
[CommandImplementation("jobs")]
|
|
public IEnumerable<JobSlotRef> Jobs([PipedArgument] IEnumerable<EntityUid> stations)
|
|
=> stations.SelectMany(Jobs);
|
|
|
|
[CommandImplementation("job")]
|
|
public JobSlotRef Job([PipedArgument] EntityUid station, ProtoId<JobPrototype> job)
|
|
{
|
|
_jobs ??= GetSys<ServerStationJobsSystem>();
|
|
|
|
return new JobSlotRef(job.Id, station, _jobs, EntityManager);
|
|
}
|
|
|
|
[CommandImplementation("job")]
|
|
public IEnumerable<JobSlotRef> Job([PipedArgument] IEnumerable<EntityUid> stations, ProtoId<JobPrototype> job)
|
|
=> stations.Select(x => Job(x, job));
|
|
|
|
[CommandImplementation("isinfinite")]
|
|
public bool IsInfinite([PipedArgument] JobSlotRef job, [CommandInverted] bool inverted)
|
|
=> job.Infinite() ^ inverted;
|
|
|
|
[CommandImplementation("isinfinite")]
|
|
public IEnumerable<bool> IsInfinite([PipedArgument] IEnumerable<JobSlotRef> jobs, [CommandInverted] bool inverted)
|
|
=> jobs.Select(x => IsInfinite(x, inverted));
|
|
|
|
[CommandImplementation("adjust")]
|
|
public JobSlotRef Adjust([PipedArgument] JobSlotRef @ref, int by)
|
|
{
|
|
_jobs ??= GetSys<ServerStationJobsSystem>();
|
|
_jobs.TryAdjustJobSlot(@ref.Station, @ref.Job, by, true, true);
|
|
return @ref;
|
|
}
|
|
|
|
[CommandImplementation("adjust")]
|
|
public IEnumerable<JobSlotRef> Adjust([PipedArgument] IEnumerable<JobSlotRef> @ref, int by)
|
|
=> @ref.Select(x => Adjust(x, by));
|
|
|
|
|
|
[CommandImplementation("set")]
|
|
public JobSlotRef Set([PipedArgument] JobSlotRef @ref, int by)
|
|
{
|
|
_jobs ??= GetSys<ServerStationJobsSystem>();
|
|
_jobs.TrySetJobSlot(@ref.Station, @ref.Job, by, true);
|
|
return @ref;
|
|
}
|
|
|
|
[CommandImplementation("set")]
|
|
public IEnumerable<JobSlotRef> Set([PipedArgument] IEnumerable<JobSlotRef> @ref, int by)
|
|
=> @ref.Select(x => Set(x, by));
|
|
|
|
[CommandImplementation("amount")]
|
|
public int Amount([PipedArgument] JobSlotRef @ref)
|
|
{
|
|
_jobs ??= GetSys<ServerStationJobsSystem>();
|
|
_jobs.TryGetJobSlot(@ref.Station, @ref.Job, out var slots);
|
|
return slots ?? 0;
|
|
}
|
|
|
|
[CommandImplementation("amount")]
|
|
public IEnumerable<int> Amount([PipedArgument] IEnumerable<JobSlotRef> @ref)
|
|
=> @ref.Select(Amount);
|
|
}
|
|
|
|
// Used for Toolshed queries.
|
|
public readonly record struct JobSlotRef(string Job, EntityUid Station, ServerStationJobsSystem Jobs, IEntityManager EntityManager)
|
|
{
|
|
public override string ToString()
|
|
{
|
|
if (!Jobs.TryGetJobSlot(Station, Job, out var slot))
|
|
{
|
|
return $"{EntityManager.ToPrettyString(Station)} job {Job} : (not a slot)";
|
|
}
|
|
|
|
return $"{EntityManager.ToPrettyString(Station)} job {Job} : {slot?.ToString() ?? "infinite"}";
|
|
}
|
|
|
|
public bool Infinite()
|
|
{
|
|
return Jobs.TryGetJobSlot(Station, Job, out var slot) && slot is null;
|
|
}
|
|
}
|