mirror of
https://github.com/Relintai/regression-test-project.git
synced 2024-12-25 14:07:21 +01:00
Do not crash when deleting nodes
This commit is contained in:
parent
674c2fa339
commit
211eda983f
@ -48,7 +48,7 @@ func _process(delta: float) -> void:
|
|||||||
if time_to_delete < 0:
|
if time_to_delete < 0:
|
||||||
time_to_delete += TIME_TO_DELETE
|
time_to_delete += TIME_TO_DELETE
|
||||||
|
|
||||||
for i in get_children():
|
# for i in get_children():
|
||||||
i.queue_free()
|
# i.queue_free()
|
||||||
|
#
|
||||||
_populate()
|
# _populate()
|
||||||
|
@ -60,14 +60,14 @@ 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() % 10 == 0: # 10% chance to remove node with children
|
# if randi() % 10 == 0: # 10% chance to remove node with children
|
||||||
var names_to_remove : Array = find_all_special_children_names(choosen_node)
|
# var names_to_remove : Array = find_all_special_children_names(choosen_node)
|
||||||
for name_to_remove in names_to_remove:
|
# for name_to_remove in names_to_remove:
|
||||||
var node : Node = ClassDB.instance(collected_nodes[randi() % collected_nodes.size()])
|
# var node : Node = ClassDB.instance(collected_nodes[randi() % collected_nodes.size()])
|
||||||
node.set_name(name_to_remove)
|
# node.set_name(name_to_remove)
|
||||||
add_child(node)
|
# add_child(node)
|
||||||
choosen_node.queue_free()
|
# choosen_node.queue_free()
|
||||||
continue
|
# 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
|
||||||
|
Loading…
Reference in New Issue
Block a user