fix clearing to many nodes
This commit is contained in:
parent
a215ababff
commit
e47de557dd
|
@ -3,7 +3,7 @@ extends Node
|
||||||
const VariantSerializer = preload("res://lib/utils/variant_serializer.gd")
|
const VariantSerializer = preload("res://lib/utils/variant_serializer.gd")
|
||||||
|
|
||||||
func clear():
|
func clear():
|
||||||
_clear_save_tree(get_tree().root.get_node("Main"))
|
await _clear_save_tree(get_tree().root.get_node("Main"))
|
||||||
|
|
||||||
func save():
|
func save():
|
||||||
if HomeApi.has_connected() == false:
|
if HomeApi.has_connected() == false:
|
||||||
|
@ -22,7 +22,7 @@ func save():
|
||||||
save_file.store_line(json_text)
|
save_file.store_line(json_text)
|
||||||
|
|
||||||
func load():
|
func load():
|
||||||
clear()
|
await clear()
|
||||||
|
|
||||||
if HomeApi.has_connected() == false:
|
if HomeApi.has_connected() == false:
|
||||||
return
|
return
|
||||||
|
@ -45,10 +45,11 @@ func load():
|
||||||
|
|
||||||
func _clear_save_tree(node: Node):
|
func _clear_save_tree(node: Node):
|
||||||
for child in node.get_children():
|
for child in node.get_children():
|
||||||
_clear_save_tree(child)
|
await _clear_save_tree(child)
|
||||||
|
|
||||||
if node.has_method("_save"):
|
if node.has_method("_save"):
|
||||||
node.queue_free()
|
node.queue_free()
|
||||||
|
await node.tree_exited
|
||||||
|
|
||||||
func _generate_save_tree(node: Node):
|
func _generate_save_tree(node: Node):
|
||||||
var children = []
|
var children = []
|
||||||
|
|
Loading…
Reference in New Issue
Block a user