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.
		
		
		
		
		
			
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			GDScript
		
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			GDScript
		
	
| ## A Composite node controls the flow of execution of its children in a specific manner.
 | |
| @tool
 | |
| @icon("../../icons/category_composite.svg")
 | |
| class_name Composite extends BeehaveNode
 | |
| 
 | |
| 
 | |
| var running_child: BeehaveNode = null
 | |
| 
 | |
| 
 | |
| func _ready():
 | |
| 	if Engine.is_editor_hint():
 | |
| 		return
 | |
| 
 | |
| 	if self.get_child_count() < 1:
 | |
| 		push_warning("BehaviorTree Error: Composite %s should have at least one child (NodePath: %s)" % [self.name, self.get_path()])
 | |
| 
 | |
| 
 | |
| func _get_configuration_warnings() -> PackedStringArray:
 | |
| 	var warnings: PackedStringArray = super._get_configuration_warnings()
 | |
| 
 | |
| 	if get_children().filter(func(x): return x is BeehaveNode).size() < 2:
 | |
| 		warnings.append("Any composite node should have at least two children. Otherwise it is not useful.")
 | |
| 
 | |
| 	return warnings
 | |
| 
 | |
| 
 | |
| func interrupt(actor: Node, blackboard: Blackboard) -> void:
 | |
| 	if running_child != null:
 | |
| 		running_child.interrupt(actor, blackboard)
 | |
| 		running_child = null
 | |
| 
 | |
| 
 | |
| func after_run(actor: Node, blackboard: Blackboard) -> void:
 | |
| 	running_child = null
 | |
| 
 | |
| 
 | |
| func get_class_name() -> Array[StringName]:
 | |
| 	var classes := super()
 | |
| 	classes.push_back(&"Composite")
 | |
| 	return classes
 |