2024-08-28 08:20:16 +03:00
|
|
|
|
using System.Linq;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
using Content.Server.Administration;
|
|
|
|
|
|
using Content.Server.GameTicking;
|
2024-01-28 18:18:54 +07:00
|
|
|
|
using Content.Server._White.AspectsSystem.Managers;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
using Content.Shared.Administration;
|
|
|
|
|
|
using Robust.Shared.Console;
|
|
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
namespace Content.Server._White.AspectsSystem.Commands;
|
|
|
|
|
|
|
|
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
|
|
|
|
public sealed class ForceAspectCommand : IConsoleCommand
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public string Command => "forceaspect";
|
|
|
|
|
|
public string Description => "Принудительно форсит аспект по его ID.";
|
|
|
|
|
|
public string Help => "forceaspect <aspectId>";
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
var ticker = _entityManager.System<GameTicker>();
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
if (args.Length != 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
shell.WriteError("Использование: forceaspect <aspectId>");
|
|
|
|
|
|
return;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
2024-08-28 08:20:16 +03:00
|
|
|
|
|
|
|
|
|
|
var aspectManager = _entityManager.System<AspectManager>();
|
|
|
|
|
|
|
|
|
|
|
|
var aspectId = args[0];
|
|
|
|
|
|
var result = aspectManager.ForceAspect(aspectId);
|
|
|
|
|
|
shell.WriteLine(result);
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
if (args.Length != 1)
|
|
|
|
|
|
return CompletionResult.Empty;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
var aspectManager = _entityManager.System<AspectManager>();
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
var options = aspectManager
|
|
|
|
|
|
.GetAspectsPrototypesId()
|
|
|
|
|
|
.Select(p => new CompletionOption(p.Key.ID, p.Value.Name))
|
|
|
|
|
|
.OrderBy(p => p.Value);
|
|
|
|
|
|
|
|
|
|
|
|
return CompletionResult.FromHintOptions(options, Loc.GetString("forcemap-command-arg-map"));
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
2024-08-28 08:20:16 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
|
|
|
|
public sealed class DeForceAspectCommand : IConsoleCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
public string Command => "deforceaspect";
|
|
|
|
|
|
public string Description => "Дефорсит принудительно установленный аспект.";
|
|
|
|
|
|
public string Help => "deforceaspect";
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
var ticker = _entityManager.System<GameTicker>();
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
|
|
|
|
|
|
return;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
2024-08-28 08:20:16 +03:00
|
|
|
|
|
|
|
|
|
|
var aspectManager = _entityManager.System<AspectManager>();
|
|
|
|
|
|
|
|
|
|
|
|
var result = aspectManager.DeForceAspect();
|
|
|
|
|
|
shell.WriteLine(result);
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
2024-08-28 08:20:16 +03:00
|
|
|
|
}
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
|
|
|
|
public sealed class GetForcedAspectCommand : IConsoleCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public string Command => "getforcedaspect";
|
|
|
|
|
|
public string Description => "Получает информацию о принудительно установленном аспекте.";
|
|
|
|
|
|
public string Help => "getforcedaspect";
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
var ticker = _entityManager.System<GameTicker>();
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
|
|
|
|
|
|
return;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
2024-08-28 08:20:16 +03:00
|
|
|
|
|
|
|
|
|
|
var aspectManager = _entityManager.System<AspectManager>();
|
|
|
|
|
|
|
|
|
|
|
|
var result = aspectManager.GetForcedAspect();
|
|
|
|
|
|
shell.WriteLine(result);
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
2024-08-28 08:20:16 +03:00
|
|
|
|
}
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
|
|
|
|
public sealed class ListAspectsCommand : IConsoleCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public string Command => "listaspects";
|
|
|
|
|
|
public string Description => "Список всех доступных аспектов.";
|
|
|
|
|
|
public string Help => "listaspects";
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
var aspectManager = _entityManager.System<AspectManager>();
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
var aspectIds = aspectManager.GetAllAspectIds();
|
|
|
|
|
|
|
|
|
|
|
|
if (aspectIds.Count == 0)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
shell.WriteLine("Нет доступных аспектов.");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
shell.WriteLine("Список доступных аспектов:");
|
|
|
|
|
|
foreach (var aspectId in aspectIds)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
shell.WriteLine(aspectId);
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-28 08:20:16 +03:00
|
|
|
|
}
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
|
|
|
|
public sealed class RunAspectCommand : IConsoleCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
|
2024-08-28 08:20:16 +03:00
|
|
|
|
public string Command => "runaspect";
|
|
|
|
|
|
public string Description => "Запускает аспект по его ID.";
|
|
|
|
|
|
public string Help => "runaspect <aspectId>";
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (args.Length != 1)
|
2023-09-17 18:51:42 +06:00
|
|
|
|
{
|
2024-08-28 08:20:16 +03:00
|
|
|
|
shell.WriteError("Использование: runaspect <aspectId>");
|
|
|
|
|
|
return;
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
2024-08-28 08:20:16 +03:00
|
|
|
|
|
|
|
|
|
|
var aspectId = args[0];
|
|
|
|
|
|
|
|
|
|
|
|
var aspectManager = _entityManager.System<AspectManager>();
|
|
|
|
|
|
|
|
|
|
|
|
var result = aspectManager.RunAspect(aspectId);
|
|
|
|
|
|
shell.WriteLine(result);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
|
|
|
|
|
public sealed class RunRandomAspectCommand : IConsoleCommand
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
|
|
|
|
|
|
|
|
|
|
public string Command => "runrandomaspect";
|
|
|
|
|
|
public string Description => "Запускает случайный аспект.";
|
|
|
|
|
|
public string Help => "runrandomaspect";
|
|
|
|
|
|
|
|
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
var aspectManager = _entityManager.System<AspectManager>();
|
|
|
|
|
|
|
|
|
|
|
|
var result = aspectManager.RunRandomAspect();
|
|
|
|
|
|
shell.WriteLine(result);
|
2023-09-17 18:51:42 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|