2022-09-30 14:39:48 +10:00
|
|
|
using System.Linq;
|
2022-09-06 00:28:23 +10:00
|
|
|
using Content.Client.NPC;
|
2022-09-30 14:39:48 +10:00
|
|
|
using Content.Shared.NPC;
|
2020-06-18 22:52:44 +10:00
|
|
|
using JetBrains.Annotations;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2020-06-18 22:52:44 +10:00
|
|
|
|
|
|
|
|
namespace Content.Client.Commands
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2022-09-30 14:39:48 +10:00
|
|
|
public sealed class DebugPathfindingCommand : IConsoleCommand
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
|
|
|
|
// ReSharper disable once StringLiteralTypo
|
|
|
|
|
public string Command => "pathfinder";
|
|
|
|
|
public string Description => "Toggles visibility of pathfinding debuggers.";
|
2022-09-30 14:39:48 +10:00
|
|
|
public string Help => "pathfinder [options]";
|
2020-06-18 22:52:44 +10:00
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2022-09-30 14:39:48 +10:00
|
|
|
var system = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<PathfindingSystem>();
|
|
|
|
|
|
|
|
|
|
if (args.Length == 0)
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2022-09-30 14:39:48 +10:00
|
|
|
system.Modes = PathfindingDebugMode.None;
|
2021-02-01 16:49:43 -08:00
|
|
|
return;
|
2020-06-18 22:52:44 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var arg in args)
|
|
|
|
|
{
|
2022-09-30 14:39:48 +10:00
|
|
|
if (!Enum.TryParse<PathfindingDebugMode>(arg, out var mode))
|
2020-06-18 22:52:44 +10:00
|
|
|
{
|
2022-09-30 14:39:48 +10:00
|
|
|
shell.WriteError($"Unrecognised pathfinder args {arg}");
|
|
|
|
|
continue;
|
2020-06-18 22:52:44 +10:00
|
|
|
}
|
2022-09-30 14:39:48 +10:00
|
|
|
|
|
|
|
|
system.Modes ^= mode;
|
|
|
|
|
shell.WriteLine($"Toggled {arg} to {(system.Modes & mode) != 0x0}");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
|
|
|
|
{
|
|
|
|
|
if (args.Length > 1)
|
|
|
|
|
{
|
|
|
|
|
return CompletionResult.Empty;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var values = Enum.GetValues<PathfindingDebugMode>().ToList();
|
|
|
|
|
var options = new List<CompletionOption>();
|
|
|
|
|
|
|
|
|
|
foreach (var val in values)
|
|
|
|
|
{
|
|
|
|
|
if (val == PathfindingDebugMode.None)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
options.Add(new CompletionOption(val.ToString()));
|
2020-06-18 22:52:44 +10:00
|
|
|
}
|
|
|
|
|
|
2022-09-30 14:39:48 +10:00
|
|
|
return CompletionResult.FromOptions(options);
|
2020-06-18 22:52:44 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|