Remove deprecated NPC debug buttons (#15824)
This commit is contained in:
@@ -3,12 +3,11 @@
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
Title="NPC debug"
|
||||
MinSize="200 200">
|
||||
<BoxContainer Name="Options" Orientation="Vertical">
|
||||
<BoxContainer Name="Options" Orientation="Vertical" Margin="8 8">
|
||||
<controls:StripeBack>
|
||||
<Label Text="NPC" HorizontalAlignment="Center"/>
|
||||
</controls:StripeBack>
|
||||
<BoxContainer Name="NPCBox" Orientation="Vertical">
|
||||
<CheckBox Name="NPCPath" Text="Path"/>
|
||||
<CheckBox Name="NPCThonk" Text="Thonk"/>
|
||||
</BoxContainer>
|
||||
<controls:StripeBack>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Content.Client.NPC.HTN;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.NPC;
|
||||
using Robust.Client.AutoGenerated;
|
||||
@@ -13,14 +14,17 @@ public sealed partial class NPCWindow : FancyWindow
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
var sysManager = IoCManager.Resolve<IEntitySystemManager>();
|
||||
var htn = sysManager.GetEntitySystem<HTNSystem>();
|
||||
var path = sysManager.GetEntitySystem<PathfindingSystem>();
|
||||
|
||||
NPCThonk.Pressed = htn.EnableOverlay;
|
||||
PathCrumbs.Pressed = (path.Modes & PathfindingDebugMode.Breadcrumbs) != 0x0;
|
||||
PathPolys.Pressed = (path.Modes & PathfindingDebugMode.Polys) != 0x0;
|
||||
PathNeighbors.Pressed = (path.Modes & PathfindingDebugMode.PolyNeighbors) != 0x0;
|
||||
PathRouteCosts.Pressed = (path.Modes & PathfindingDebugMode.RouteCosts) != 0x0;
|
||||
PathRoutes.Pressed = (path.Modes & PathfindingDebugMode.Routes) != 0x0;
|
||||
|
||||
NPCThonk.OnToggled += args => htn.EnableOverlay = args.Pressed;
|
||||
PathCrumbs.OnToggled += args => path.Modes ^= PathfindingDebugMode.Breadcrumbs;
|
||||
PathPolys.OnToggled += args => path.Modes ^= PathfindingDebugMode.Polys;
|
||||
PathNeighbors.OnToggled += args => path.Modes ^= PathfindingDebugMode.PolyNeighbors;
|
||||
|
||||
@@ -223,11 +223,10 @@ public sealed class HTNSystem : EntitySystem
|
||||
{
|
||||
text.AppendLine($"BTR: {string.Join(", ", comp.Plan.BranchTraversalRecord)}");
|
||||
text.AppendLine($"tasks:");
|
||||
|
||||
foreach (var task in comp.Plan.Tasks)
|
||||
{
|
||||
text.AppendLine($"- {task.ID}");
|
||||
}
|
||||
var root = _prototypeManager.Index<HTNCompoundTask>(comp.RootTask);
|
||||
var btr = new List<int>();
|
||||
var level = -1;
|
||||
AppendDebugText(root, text, comp.Plan.BranchTraversalRecord, btr, ref level);
|
||||
}
|
||||
|
||||
RaiseNetworkEvent(new HTNMessage()
|
||||
@@ -247,6 +246,49 @@ public sealed class HTNSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void AppendDebugText(HTNTask task, StringBuilder text, List<int> planBtr, List<int> btr, ref int level)
|
||||
{
|
||||
// If it's the selected BTR then highlight.
|
||||
for (var i = 0; i < btr.Count; i++)
|
||||
{
|
||||
text.Append('-');
|
||||
}
|
||||
|
||||
text.Append(' ');
|
||||
|
||||
if (task is HTNPrimitiveTask primitive)
|
||||
{
|
||||
text.AppendLine(primitive.ID);
|
||||
return;
|
||||
}
|
||||
|
||||
if (task is HTNCompoundTask compound)
|
||||
{
|
||||
level++;
|
||||
text.AppendLine(compound.ID);
|
||||
var branches = _compoundBranches[compound];
|
||||
|
||||
for (var i = 0; i < branches.Length; i++)
|
||||
{
|
||||
var branch = branches[i];
|
||||
btr.Add(i);
|
||||
text.AppendLine($" branch {string.Join(" ", btr)}:");
|
||||
|
||||
foreach (var sub in branch)
|
||||
{
|
||||
AppendDebugText(sub, text, planBtr, btr, ref level);
|
||||
}
|
||||
|
||||
btr.RemoveAt(btr.Count - 1);
|
||||
}
|
||||
|
||||
level--;
|
||||
return;
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void Update(HTNComponent component, float frameTime)
|
||||
{
|
||||
// If we're not planning then countdown to next one.
|
||||
|
||||
Reference in New Issue
Block a user