CORE/coreloader.gd

57 lines
2.3 KiB
GDScript3
Raw Normal View History

2023-03-18 16:34:12 +01:00
# 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_resmgr = ResourceLoader.load("res://CORE/resmgr.gd")
var scr_autoload = ResourceLoader.load("res://CORE/autoload.gd")
var scr_events = ResourceLoader.load("res://CORE/events.gd")
2023-03-18 16:34:12 +01:00
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 resmgr to CORE")
core.attach("resmgr",scr_resmgr)
Logger.info("coreloader","Attaching autoload to CORE")
core.attach("autoload",scr_autoload)
Logger.info("coreloader","Attaching events to CORE")
core.attach("events",scr_events)
2023-03-18 16:34:12 +01:00
Logger.info("coreloader","Locking CORE")
core.lock()
Logger.info("coreloader","Waiting for CORE to fully initialize")
while !core.readylized:
await get_tree().create_timer(1).timeout
2023-03-18 16:34:12 +01:00
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")
queue_free()