Skip to content

Commit 71e64bc

Browse files
authored
ensure BeehaveTree is available even if Godot class cache is broken, closes #409 (#426)
1 parent 6dea60d commit 71e64bc

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

addons/beehave/plugin.gd

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ extends EditorPlugin
44
const BeehaveEditorDebugger := preload("debug/debugger.gd")
55
var editor_debugger: BeehaveEditorDebugger
66
var frames: RefCounted
7+
var _custom_types: Array[StringName] = []
78

89

910
func _init():
@@ -33,7 +34,29 @@ func _enter_tree() -> void:
3334
else:
3435
frames = preload("debug/old_frames.gd").new()
3536
add_debugger_plugin(editor_debugger)
37+
_register_custom_types()
3638

3739

3840
func _exit_tree() -> void:
41+
_unregister_custom_types()
3942
remove_debugger_plugin(editor_debugger)
43+
44+
45+
func _register_custom_types() -> void:
46+
# Some users report the script-class cache randomly missing BeehaveTree,
47+
# which makes the editor return a null instance. Register the type manually
48+
# so the node is still available even if the cache is broken.
49+
var tree_script: Script = load("res://addons/beehave/nodes/beehave_tree.gd")
50+
if tree_script == null:
51+
push_warning("Beehave: failed to load BeehaveTree script; custom type not registered.")
52+
return
53+
54+
var tree_icon: Texture2D = load("res://addons/beehave/icons/tree.svg")
55+
add_custom_type("BeehaveTree", "Node", tree_script, tree_icon)
56+
_custom_types.append(&"BeehaveTree")
57+
58+
59+
func _unregister_custom_types() -> void:
60+
for type_name in _custom_types:
61+
remove_custom_type(type_name)
62+
_custom_types.clear()

addons/gdUnit4/GdUnitRunner.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2991,4 +2991,4 @@
29912991
}
29922992
],
29932993
"version": "5.0"
2994-
}
2994+
}

0 commit comments

Comments
 (0)