Make unitbase.gd more verbose

This commit is contained in:
JeremyStar™ 2024-04-06 13:13:27 +02:00
parent 527d4d19ab
commit 2727eca37e
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -29,6 +29,8 @@ func after_each() -> void:
# Framework management # Framework management
func load_framework(config: CoreConfiguration = CoreConfiguration.new()) -> void: func load_framework(config: CoreConfiguration = CoreConfiguration.new()) -> void:
if is_framework_loaded(): await unload_framework()
ldiag("Loading framework")
core = Core.new(config) core = Core.new(config)
get_tree().root.add_child(core) get_tree().root.add_child(core)
await get_tree().process_frame await get_tree().process_frame
@ -36,12 +38,16 @@ func load_framework(config: CoreConfiguration = CoreConfiguration.new()) -> void
func unload_framework() -> void: func unload_framework() -> void:
if is_framework_loaded(): if is_framework_loaded():
ldiag("Unloading framework")
await core.cleanup() await core.cleanup()
get_tree().root.remove_child.call_deferred(core) get_tree().root.remove_child.call_deferred(core)
core = null core = null
await get_tree().process_frame await get_tree().process_frame
else: lcrash("Can't unload framework: Framework is not loaded")
func is_framework_loaded() -> bool: return get_node_or_null("/root/CORE") != null func is_framework_loaded() -> bool: return get_node_or_null("/root/CORE") != null
# Helper functions # Helper functions
func wait_process_time() -> void: await get_tree().create_timer(0.1).timeout func wait_process_time() -> void:
ldiag("Waiting process time")
await get_tree().create_timer(0.1).timeout