From 211eda983fe10de641b6dcdca451a615eb96ddad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Mikrut?= Date: Sat, 27 Mar 2021 18:49:01 +0100 Subject: [PATCH] Do not crash when deleting nodes --- Nodes/Nodes.gd | 8 ++++---- ReparentingDeleting/ReparentingDeleting.gd | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Nodes/Nodes.gd b/Nodes/Nodes.gd index a14aa59..3409560 100644 --- a/Nodes/Nodes.gd +++ b/Nodes/Nodes.gd @@ -48,7 +48,7 @@ func _process(delta: float) -> void: if time_to_delete < 0: time_to_delete += TIME_TO_DELETE - for i in get_children(): - i.queue_free() - - _populate() +# for i in get_children(): +# i.queue_free() +# +# _populate() diff --git a/ReparentingDeleting/ReparentingDeleting.gd b/ReparentingDeleting/ReparentingDeleting.gd index bc74468..ce3eafe 100644 --- a/ReparentingDeleting/ReparentingDeleting.gd +++ b/ReparentingDeleting/ReparentingDeleting.gd @@ -60,14 +60,14 @@ 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() % 10 == 0: # 10% 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 = ClassDB.instance(collected_nodes[randi() % collected_nodes.size()]) - node.set_name(name_to_remove) - add_child(node) - choosen_node.queue_free() - continue +# if randi() % 10 == 0: # 10% 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 = ClassDB.instance(collected_nodes[randi() % collected_nodes.size()]) +# 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