Add reparenting

This commit is contained in:
Rafał Mikrut 2021-02-09 15:39:32 +01:00
parent 92c907211d
commit a2b88e8b86
3 changed files with 11 additions and 9 deletions

1
.gitignore vendored
View File

@ -8,3 +8,4 @@ logs/
TEMP/ TEMP/
#export_presets.cfg #export_presets.cfg
logs/ logs/
.godot/editor

View File

@ -30,7 +30,7 @@ const alone_steps : Array = [
# This should be put regression scripts which needs to run only once # This should be put regression scripts which needs to run only once
const all_in_one : Array = [ const all_in_one : Array = [
"res://AIO/Operators/Operators.tscn", "res://AIO/Operators/Operators.tscn",
"res://AIO/AllNodes/ALL.tscn", #"res://AIO/AllNodes/ALL.tscn",
] ]
func _init(): func _init():

View File

@ -223,14 +223,15 @@ func _process(delta: float) -> void:
var random_node = find_node("Special Node " + str(randi() % number_of_nodes),true,false) var random_node = find_node("Special Node " + str(randi() % number_of_nodes),true,false)
parent_of_node.remove_child(choosen_node) parent_of_node.remove_child(choosen_node)
if randi() % 6 == 0: # 16% chance to remove node with children # # Do not delete for now due https://github.com/godotengine/godot/issues/45471
var names_to_remove : Array = find_all_special_children_names(choosen_node) # if randi() % 6 == 0: # 16% chance to remove node with children
for name_to_remove in names_to_remove: # var names_to_remove : Array = find_all_special_children_names(choosen_node)
var node : Node = node_to_handle_others.get_child(randi() % node_to_handle_others.get_child_count()).duplicate(0) # for name_to_remove in names_to_remove:
node.set_name(name_to_remove) # var node : Node = node_to_handle_others.get_child(randi() % node_to_handle_others.get_child_count()).duplicate(0)
add_child(node) # node.set_name(name_to_remove)
choosen_node.queue_free() # add_child(node)
continue # choosen_node.queue_free()
# continue
if choosen_node.find_node(random_node.get_name(),true,false) != null: # Cannot set as node parent one of its child if choosen_node.find_node(random_node.get_name(),true,false) != null: # Cannot set as node parent one of its child