You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			39 lines
		
	
	
		
			896 B
		
	
	
	
		
			GDScript
		
	
			
		
		
	
	
			39 lines
		
	
	
		
			896 B
		
	
	
	
		
			GDScript
		
	
| extends Node
 | |
| 
 | |
| var _registered_trees: Dictionary
 | |
| var _active_tree: BeehaveTree
 | |
| 
 | |
| 
 | |
| func _enter_tree() -> void:
 | |
| 	EngineDebugger.register_message_capture("beehave", _on_debug_message)
 | |
| 
 | |
| 
 | |
| func _on_debug_message(message: String, data: Array) -> bool:
 | |
| 	if message == "activate_tree":
 | |
| 		_set_active_tree(data[0])
 | |
| 		return true
 | |
| 	if message == "visibility_changed":
 | |
| 		if _active_tree:
 | |
| 			_active_tree._can_send_message = data[0]
 | |
| 		return true
 | |
| 	return false
 | |
| 
 | |
| 
 | |
| func _set_active_tree(tree_id: int) -> void:
 | |
| 	var tree: BeehaveTree = _registered_trees.get(tree_id, null)
 | |
| 	if not tree:
 | |
| 		return
 | |
| 
 | |
| 	if _active_tree:
 | |
| 		_active_tree._can_send_message = false
 | |
| 	_active_tree = tree
 | |
| 	_active_tree._can_send_message = true
 | |
| 
 | |
| 
 | |
| func register_tree(tree: BeehaveTree) -> void:
 | |
| 	_registered_trees[tree.get_instance_id()] = tree
 | |
| 
 | |
| 
 | |
| func unregister_tree(tree: BeehaveTree) -> void:
 | |
| 	_registered_trees.erase(tree.get_instance_id())
 |