class_name Operation extends Node var steps: Array[Node2D] = [] var active_step: Node2D = null func _ready(): var children = get_children() for child in children: if child is Node2D: steps.push_back(child) if child is CutSequence: child.sequence_succeeded.connect(_on_cut_sequence_succeeded.bind(child)) child.sequence_failed.connect(_on_cut_sequence_failed.bind(child)) _disable_node2d(child) active_step = steps[0] _enable_node2d(active_step) func _on_cut_sequence_succeeded(cut_sequence: CutSequence): _disable_node2d(active_step) var next_index = steps.find(cut_sequence) + 1 if next_index == 4: _enable_node2d(%TestBody2) _disable_node2d(%BatExtraction) active_step = steps[next_index] _enable_node2d(active_step) func _on_cut_sequence_failed(cut_sequence: CutSequence): pass func _enable_node2d(node: Node2D): node.set_deferred("visible", true) node.set_deferred("process_mode", Node.PROCESS_MODE_INHERIT) func _disable_node2d(node: Node2D): node.set_deferred("visible", false) node.set_deferred("process_mode", Node.PROCESS_MODE_DISABLED)