CORE/core.gd

63 lines
1.5 KiB
GDScript3
Raw Normal View History

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
const version = "git-develop"
2023-03-18 16:34:12 +01:00
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 the error thrown by Godot
2023-03-18 16:34:12 +01:00
var config = null
var wmgr = null
var smgr = null
var resmgr = null
var autoload = null
var events = null
2023-03-18 16:34:12 +01:00
func attach(type:String,component:Script) -> void:
if locked:
return
Logger.diag("core","Attaching " + type + " to CORE")
var comp = Control.new()
comp.name = type
comp.set_script(component)
match(type):
"config":
add_child(comp)
config = comp
"wmgr":
add_child(comp)
wmgr = comp
"smgr":
add_child(comp)
smgr = comp
"resmgr":
add_child(comp)
resmgr = comp
"autoload":
add_child(comp)
autoload = comp
"events":
add_child(comp)
events = comp
2023-03-18 16:34:12 +01:00
_:
Logger.error("core","Failed attaching " + type + " to CORE: Invalid component")
comp.free()
return
Logger.diag("core","Attached " + type + " successfully")
func setready() -> void:
readycount = readycount+1
if readycount == 4:
readylized = true
2023-03-18 16:34:12 +01:00
func lock() -> void:
locked = true
Logger.diag("core","CORE is now locked. No new attachments can be made.")
func welcome() -> void:
Logger.info("core","CORE " + version + " welcomes you!<nl>It seems like everything is working :)")