CORE/coreloader.gd

56 lines
2.4 KiB
GDScript

# coreloader.gd
# CORE Loader
#
# This file is part of StarOpenSource CORE (SOSCORE)
# Made by the StarOpenSource Project and Contributers
# Licensed under GNU GPLv3
extends Node
func _ready() -> void:
await get_tree().create_timer(1.5).timeout
Logger.info("coreloader","Starting initialization")
Logger.info("coreloader","Loading configuration file")
var scr_config = ResourceLoader.load("res://CORE/config.gd")
Logger.info("coreloader","Preloading core scripts")
var scr_core = ResourceLoader.load("res://CORE/core.gd")
var scr_wmgr = ResourceLoader.load("res://CORE/wmgr.gd")
var scr_smgr = ResourceLoader.load("res://CORE/smgr.gd")
var scr_autoload = ResourceLoader.load("res://CORE/autoload.gd")
Logger.info("coreloader","Constructing CORE")
var core = Control.new()
core.name = "core"
core.script = scr_core
Logger.info("coreloader","Attaching CORE to /root/")
get_tree().root.add_child(core)
Logger.info("coreloader","Attaching configuration file to CORE")
core.attach("config",scr_config)
Logger.info("coreloader","Waiting for CORE to initialize")
await get_tree().create_timer(0.5).timeout
Logger.info("coreloader","Attaching wmgr to CORE")
core.attach("wmgr",scr_wmgr)
Logger.info("coreloader","Attaching smgr to CORE")
core.attach("smgr",scr_smgr)
Logger.info("coreloader","Attaching autoload to CORE")
core.attach("autoload",scr_autoload)
Logger.info("coreloader","Locking CORE")
core.lock()
Logger.info("coreloader","Waiting for CORE to fully initialize")
await get_tree().create_timer(1).timeout
Logger.info("coreloader","Checking CORE availability")
if !core.wmgr.available:
Logger.error("coreloader","CORE wmgr is not available.<nl>Please check the log for any errors during initialization.")
return
if !core.smgr.available:
Logger.error("coreloader","CORE smgr is not available.<nl>Please check the log for any errors during initialization.")
Logger.info("coreloader","CORE is available.")
Logger.info("coreloader","CORE has been initialized and is ready.")
Logger.info("coreloader","Preloading project init script")
var initscr = ResourceLoader.load(core.config.core_startscript)
Logger.info("coreloader","Constructing project init script")
var initscr_obj = Control.new()
initscr_obj.name = "ProjectInitScript"
initscr_obj.set_script(initscr)
Logger.info("coreloader","Adding project init script to /root/")
get_tree().root.add_child(initscr_obj)
Logger.info("coreloader","Removing coreloader")
coreloader.queue_free()