buggy mess of a graph based behavior tree debugger (not good, pls ignore)
This commit is contained in:
parent
b5d5a8f9f3
commit
738e33342e
6 changed files with 143 additions and 46 deletions
45
addons/BehaviorDebug/BehaviorDebugGraphNode.cs
Normal file
45
addons/BehaviorDebug/BehaviorDebugGraphNode.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue