Files
crystall-punk-14/Content.Server/GameTicking/Commands/SetGamePresetCommand.cs
Ed f42546e0c6 Some round beginning preparation (#317)
* gamepresets filter

* addgamerule cp14 filter

* shuttle dropping

* long time FTL

* FTL map tweaks

* Update ShuttleSystem.FasterThanLight.cs

* handle player ship spawning (not tested yet)

* typo

* test elemental shit (ship)

* player spawn handling (real this time)

* FTL map gravity

* clean up 1

* clean up 2

* instant FTL

* Update CP14ExpeditionSystem.cs
2024-07-08 17:39:04 +03:00

64 lines
2.3 KiB
C#

using System.Linq;
using Content.Server.Administration;
using Content.Server.GameTicking.Presets;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Prototypes;
namespace Content.Server.GameTicking.Commands
{
[AdminCommand(AdminFlags.Round)]
public sealed class SetGamePresetCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entity = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
public string Command => "setgamepreset";
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));
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1)
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number-need-specific", ("properAmount", 1), ("currentAmount", args.Length)));
return;
}
var ticker = _entity.System<GameTicker>();
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)));
}
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)
{
//CP14 console preset filter
if (!preset.CP14Allowed)
continue;
//CP14 console preset filter end
options.Add(preset.ID);
options.AddRange(preset.Alias);
}
return CompletionResult.FromHintOptions(options, "<id>");
}
return CompletionResult.Empty;
}
}
}