Pathfinder rework (#11452)
This commit is contained in:
@@ -1,74 +1,61 @@
|
||||
using System.Linq;
|
||||
using Content.Client.NPC;
|
||||
using Content.Shared.NPC;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Commands
|
||||
{
|
||||
[UsedImplicitly]
|
||||
internal sealed class DebugPathfindingCommand : IConsoleCommand
|
||||
public sealed class DebugPathfindingCommand : IConsoleCommand
|
||||
{
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
public string Command => "pathfinder";
|
||||
public string Description => "Toggles visibility of pathfinding debuggers.";
|
||||
public string Help => "pathfinder [hide/nodes/routes/graph/regioncache/regions]";
|
||||
public string Help => "pathfinder [options]";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
#if DEBUG
|
||||
if (args.Length < 1)
|
||||
var system = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<PathfindingSystem>();
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
shell.RemoteExecuteCommand(argStr);
|
||||
system.Modes = PathfindingDebugMode.None;
|
||||
return;
|
||||
}
|
||||
|
||||
var anyAction = false;
|
||||
var debugSystem = EntitySystem.Get<ClientPathfindingDebugSystem>();
|
||||
|
||||
foreach (var arg in args)
|
||||
{
|
||||
switch (arg)
|
||||
if (!Enum.TryParse<PathfindingDebugMode>(arg, out var mode))
|
||||
{
|
||||
case "hide":
|
||||
debugSystem.Disable();
|
||||
anyAction = true;
|
||||
break;
|
||||
// Shows all nodes on the closed list
|
||||
case "nodes":
|
||||
debugSystem.ToggleTooltip(PathfindingDebugMode.Nodes);
|
||||
anyAction = true;
|
||||
break;
|
||||
// Will show just the constructed route
|
||||
case "routes":
|
||||
debugSystem.ToggleTooltip(PathfindingDebugMode.Route);
|
||||
anyAction = true;
|
||||
break;
|
||||
// Shows all of the pathfinding chunks
|
||||
case "graph":
|
||||
debugSystem.ToggleTooltip(PathfindingDebugMode.Graph);
|
||||
anyAction = true;
|
||||
break;
|
||||
// Shows every time the cached reachable regions are hit (whether cached already or not)
|
||||
case "regioncache":
|
||||
debugSystem.ToggleTooltip(PathfindingDebugMode.CachedRegions);
|
||||
anyAction = true;
|
||||
break;
|
||||
// Shows all of the regions in each chunk
|
||||
case "regions":
|
||||
debugSystem.ToggleTooltip(PathfindingDebugMode.Regions);
|
||||
anyAction = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
continue;
|
||||
shell.WriteError($"Unrecognised pathfinder args {arg}");
|
||||
continue;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if(!anyAction)
|
||||
shell.RemoteExecuteCommand(argStr);
|
||||
#else
|
||||
shell.RemoteExecuteCommand(argStr);
|
||||
#endif
|
||||
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()));
|
||||
}
|
||||
|
||||
return CompletionResult.FromOptions(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user