CORE/core.gd

53 lines
1.4 KiB
GDScript

# 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
const version = "git-develop"
var locked = false
var readycount = 0
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
var config = null
var wmgr = null
var smgr = null
var resmgr = null
var events = null
var splash = null
func attach(type:String,component,do_setup:bool = true) -> void:
if locked:
return
Logger.diag("core","Attaching " + type + " to CORE")
var comp = component
if do_setup:
comp = Control.new()
comp.name = type
comp.set_script(component)
match(type):
"config": config = comp
"wmgr": wmgr = comp
"smgr": smgr = comp
"resmgr": resmgr = comp
"events": events = comp
"splash": splash = comp
_:
Logger.error("core","Failed attaching " + type + " to CORE: Invalid component")
comp.free()
return
add_child(comp)
Logger.diag("core","Attached " + type + " successfully")
func setready() -> void:
readycount = readycount+1
if readycount == 5:
readylized = true
func lock() -> void:
locked = true
Logger.diag("core","CORE is now locked. No new attachments can be added.")
func welcome() -> void:
Logger.info("core","CORE " + version + " welcomes you!<nl>It seems like everything is working :)")