nature-sim/Utilities/Debug/DebugHelper.gd
2025-06-26 14:46:23 +01:00

27 lines
729 B
GDScript

class_name DebugHelperClass
extends Node
func _count_nodes_recursive(node: Node) -> int:
var count = 1 # Count current node
for child in node.get_children():
count += _count_nodes_recursive(child)
return count
func _count_nodes_by_type(node: Node, type_name: String) -> int:
var count = 0
if node.get_script() and node.get_script().get_global_name() == type_name:
count += 1
for child in node.get_children():
count += _count_nodes_by_type(child, type_name)
return count
func _count_nodes_by_name_pattern(node: Node, pattern: String) -> int:
var count = 0
if node.name.contains(pattern):
count += 1
for child in node.get_children():
count += _count_nodes_by_name_pattern(child, pattern)
return count