2023-03-18 16:34:12 +01:00
# core.gd
# CORE Holder
#
# This file is part of StarOpenSource CORE (SOSCORE)
# Made by the StarOpenSource Project and Contributers
# Licensed under GNU GPLv3
extends Node
2023-03-18 18:02:07 +01:00
const version = " git-develop "
2023-03-18 16:34:12 +01:00
var locked = false
2023-05-29 20:46:47 +02:00
var readycount = 0
2023-06-29 17:22:13 +02:00
var readylized = false # Fun Fact: "ready" is a signal from "Node" and I (JeremyStarTM) just added "lized" from "initialized" to it to avoid a error thrown by Godot
2023-03-18 16:34:12 +01:00
var config = null
var wmgr = null
var smgr = null
2023-05-29 20:46:47 +02:00
var resmgr = null
var events = null
2023-06-29 17:22:13 +02:00
var splash = null
2023-03-18 16:34:12 +01:00
2023-06-29 17:22:13 +02:00
func attach ( type : String , component , do_setup : bool = true ) - > void :
2023-03-18 16:34:12 +01:00
if locked :
return
Logger . diag ( " core " , " Attaching " + type + " to CORE " )
2023-06-29 17:22:13 +02:00
var comp = component
if do_setup :
comp = Control . new ( )
comp . name = type
comp . set_script ( component )
2023-03-18 16:34:12 +01:00
match ( type ) :
2023-07-07 10:58:49 +02:00
" config " : config = comp
" wmgr " : wmgr = comp
" smgr " : smgr = comp
" resmgr " : resmgr = comp
" events " : events = comp
" splash " : splash = comp
2023-03-18 16:34:12 +01:00
_ :
Logger . error ( " core " , " Failed attaching " + type + " to CORE: Invalid component " )
comp . free ( )
return
2023-06-29 17:22:13 +02:00
add_child ( comp )
2023-03-18 16:34:12 +01:00
Logger . diag ( " core " , " Attached " + type + " successfully " )
2023-05-29 20:46:47 +02:00
func setready ( ) - > void :
readycount = readycount + 1
2023-07-07 11:03:06 +02:00
if readycount == 5 :
2023-05-29 20:46:47 +02:00
readylized = true
2023-03-18 16:34:12 +01:00
func lock ( ) - > void :
locked = true
2023-06-29 17:22:13 +02:00
Logger . diag ( " core " , " CORE is now locked. No new attachments can be added. " )
2023-03-18 18:02:07 +01:00
func welcome ( ) - > void :
Logger . info ( " core " , " CORE " + version + " welcomes you!<nl>It seems like everything is working :) " )