buggy mess of a graph based behavior tree debugger (not good, pls ignore)

This commit is contained in:
Lilith Schier 2026-06-29 00:23:09 +02:00
parent b5d5a8f9f3
commit 738e33342e
6 changed files with 143 additions and 46 deletions

View file

@ -0,0 +1,45 @@
using System.Diagnostics;
[Tool]
public sealed partial class BehaviorDebugGraphNode : GraphNode
{
public Label StateLabel { get; set; } = null!;
public override void _Ready()
{
StateLabel = GetNode<Label>("%StateLabel");
}
public string State
{
get;
set
{
field = value;
StateLabel.Text = value;
var themeStylebox = GetThemeStylebox("panel")!.Duplicate() as StyleBoxFlat;
themeStylebox?.BgColor = GetStateColor(value);
AddThemeStyleboxOverride("panel", themeStylebox);
}
} = "Idle";
private Color GetStateColor(string state) =>
state switch
{
"Idle" => Color.FromOkHsl(.653f, .3f, .2f),
"Running" => Color.FromOkHsl(.222f, .7f, .3f),
"Success" => Color.FromOkHsl(.375f, .3f, .2f),
"Failure" => Color.FromOkHsl(.055f, .3f, .2f),
_ => throw new UnreachableException(),
};
public void SetDescendantCount(int count)
{
for (var i = 0; i < count; i++)
{
var label = new Label { Text = (i + 1).ToString() };
AddChild(label);
SetSlot(i + 1, false, 0, Colors.Transparent, true, 0, Colors.FloralWhite);
}
}
}