CORE/coreloader.gd

55 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.diag("coreloader","Starting initialization")
Logger.diag("coreloader","Loading configuration file")
2023-03-18 16:34:12 +01:00
var scr_config = ResourceLoader.load("res://CORE/config.gd")
Logger.diag("coreloader","Preloading core scripts")
2023-03-18 16:34:12 +01:00
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_events = ResourceLoader.load("res://CORE/events.gd")
2023-06-29 17:22:13 +02:00
var scr_splash = ResourceLoader.load("res://CORE/splash.tscn").instantiate()
Logger.diag("coreloader","Constructing CORE")
2023-03-18 16:34:12 +01:00
var core = Control.new()
core.name = "core"
core.script = scr_core
Logger.diag("coreloader","Attaching CORE to /root/")
2023-03-18 16:34:12 +01:00
get_tree().root.add_child(core)
Logger.diag("coreloader","Attaching configuration file to CORE")
2023-03-18 16:34:12 +01:00
core.attach("config",scr_config)
Logger.diag("coreloader","Attaching wmgr to CORE")
2023-03-18 16:34:12 +01:00
core.attach("wmgr",scr_wmgr)
Logger.diag("coreloader","Attaching smgr to CORE")
2023-03-18 16:34:12 +01:00
core.attach("smgr",scr_smgr)
Logger.diag("coreloader","Attaching resmgr to CORE")
core.attach("resmgr",scr_resmgr)
Logger.diag("coreloader","Attaching events to CORE")
core.attach("events",scr_events)
Logger.diag("coreloader","Attaching splash to CORE")
2023-06-29 17:22:13 +02:00
core.attach("splash",scr_splash,false)
Logger.diag("coreloader","Locking CORE")
2023-03-18 16:34:12 +01:00
core.lock()
Logger.diag("coreloader","Waiting for CORE to fully initialize")
while !core.readylized:
await get_tree().create_timer(1).timeout
Logger.diag("coreloader","CORE has been initialized and is ready.")
Logger.diag("coreloader","Preloading project init script")
2023-03-18 16:34:12 +01:00
var initscr = ResourceLoader.load(core.config.core_startscript)
Logger.diag("coreloader","Constructing project init script")
2023-03-18 16:34:12 +01:00
var initscr_obj = Control.new()
initscr_obj.name = "ProjectInitScript"
initscr_obj.set_script(initscr)
Logger.diag("coreloader","Adding project init script to /root/")
2023-03-18 16:34:12 +01:00
get_tree().root.add_child(initscr_obj)
Logger.diag("coreloader","Removing coreloader")
queue_free()