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/
#export_presets.cfg
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
const all_in_one : Array = [
"res://AIO/Operators/Operators.tscn",
"res://AIO/AllNodes/ALL.tscn",
#"res://AIO/AllNodes/ALL.tscn",
]
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)
parent_of_node.remove_child(choosen_node)
if randi() % 6 == 0: # 16% chance to remove node with children
var names_to_remove : Array = find_all_special_children_names(choosen_node)
for name_to_remove in names_to_remove:
var node : Node = node_to_handle_others.get_child(randi() % node_to_handle_others.get_child_count()).duplicate(0)
node.set_name(name_to_remove)
add_child(node)
choosen_node.queue_free()
continue
# # Do not delete for now due https://github.com/godotengine/godot/issues/45471
# if randi() % 6 == 0: # 16% chance to remove node with children
# var names_to_remove : Array = find_all_special_children_names(choosen_node)
# for name_to_remove in names_to_remove:
# var node : Node = node_to_handle_others.get_child(randi() % node_to_handle_others.get_child_count()).duplicate(0)
# node.set_name(name_to_remove)
# add_child(node)
# 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