CORE/coreloader.gd
JeremyStarTM b57d00e9cd Many improvements (see commit description)
Added more things to roadmap, removed autoload singleton check, added support for Godot 4.1, all startup messages now use Logger.diag() instead of Logger.info() (making them disappear but can be shown if needed), removed autoload.gd, fixes syntax.
2023-07-07 10:58:49 +02:00

54 lines
2.3 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.diag("coreloader","Starting initialization")
Logger.diag("coreloader","Loading configuration file")
var scr_config = ResourceLoader.load("res://CORE/config.gd")
Logger.diag("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_events = ResourceLoader.load("res://CORE/events.gd")
var scr_splash = ResourceLoader.load("res://CORE/splash.tscn").instantiate()
Logger.diag("coreloader","Constructing CORE")
var core = Control.new()
core.name = "core"
core.script = scr_core
Logger.diag("coreloader","Attaching CORE to /root/")
get_tree().root.add_child(core)
Logger.diag("coreloader","Attaching configuration file to CORE")
core.attach("config",scr_config)
Logger.diag("coreloader","Attaching wmgr to CORE")
core.attach("wmgr",scr_wmgr)
Logger.diag("coreloader","Attaching smgr to CORE")
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")
core.attach("splash",scr_splash,false)
Logger.diag("coreloader","Locking CORE")
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")
var initscr = ResourceLoader.load(core.config.core_startscript)
Logger.diag("coreloader","Constructing project init script")
var initscr_obj = Control.new()
initscr_obj.name = "ProjectInitScript"
initscr_obj.set_script(initscr)
Logger.diag("coreloader","Adding project init script to /root/")
get_tree().root.add_child(initscr_obj)
Logger.diag("coreloader","Removing coreloader")
queue_free()