2023-04-13 21:06:06 -04:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using Content.Server.Administration;
|
|
|
|
|
|
using Content.Server.GameTicking.Presets;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
using Content.Shared.Administration;
|
2021-02-01 16:49:43 -08:00
|
|
|
|
using Robust.Shared.Console;
|
2023-04-13 21:06:06 -04:00
|
|
|
|
using Robust.Shared.Prototypes;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.GameTicking.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2021-11-29 14:40:10 -06:00
|
|
|
|
[AdminCommand(AdminFlags.Round)]
|
2023-04-13 21:06:06 -04:00
|
|
|
|
public sealed class SetGamePresetCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2023-04-13 21:06:06 -04:00
|
|
|
|
[Dependency] private readonly IEntityManager _entity = default!;
|
|
|
|
|
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
|
|
|
|
|
|
2020-12-03 03:40:47 +01:00
|
|
|
|
public string Command => "setgamepreset";
|
2022-05-19 08:25:45 +10:00
|
|
|
|
public string Description => Loc.GetString("set-game-preset-command-description", ("command", Command));
|
|
|
|
|
|
public string Help => Loc.GetString("set-game-preset-command-help-text", ("command", Command));
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
if (args.Length != 1)
|
|
|
|
|
|
{
|
2022-05-19 08:25:45 +10:00
|
|
|
|
shell.WriteError(Loc.GetString("shell-wrong-arguments-number-need-specific", ("properAmount", 1), ("currentAmount", args.Length)));
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-04-13 21:06:06 -04:00
|
|
|
|
var ticker = _entity.System<GameTicker>();
|
2020-12-03 03:40:47 +01:00
|
|
|
|
|
2022-05-19 08:25:45 +10:00
|
|
|
|
if (!ticker.TryFindGamePreset(args[0], out var preset))
|
|
|
|
|
|
{
|
|
|
|
|
|
shell.WriteError(Loc.GetString("set-game-preset-preset-error", ("preset", args[0])));
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ticker.SetGamePreset(preset);
|
|
|
|
|
|
shell.WriteLine(Loc.GetString("set-game-preset-preset-set", ("preset", preset.ID)));
|
2020-12-03 03:40:47 +01:00
|
|
|
|
}
|
2023-04-13 21:06:06 -04:00
|
|
|
|
|
|
|
|
|
|
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (args.Length == 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
var gamePresets = _prototype.EnumeratePrototypes<GamePresetPrototype>()
|
|
|
|
|
|
.OrderBy(p => p.ID);
|
|
|
|
|
|
var options = new List<string>();
|
|
|
|
|
|
foreach (var preset in gamePresets)
|
|
|
|
|
|
{
|
2024-07-08 17:39:04 +03:00
|
|
|
|
//CP14 console preset filter
|
|
|
|
|
|
if (!preset.CP14Allowed)
|
|
|
|
|
|
continue;
|
|
|
|
|
|
//CP14 console preset filter end
|
|
|
|
|
|
|
2023-04-13 21:06:06 -04:00
|
|
|
|
options.Add(preset.ID);
|
|
|
|
|
|
options.AddRange(preset.Alias);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return CompletionResult.FromHintOptions(options, "<id>");
|
|
|
|
|
|
}
|
|
|
|
|
|
return CompletionResult.Empty;
|
|
|
|
|
|
}
|
2020-12-03 03:40:47 +01:00
|
|
|
|
}
|
2021-06-09 22:19:39 +02:00
|
|
|
|
}
|