add state machine draft

This commit is contained in:
Fabien Freling 2023-12-05 14:03:14 +01:00
parent a7c7fb0b6f
commit 810a3aa9b5

View file

@ -1,11 +1,16 @@
extends Node
# https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html
signal state_changed(previous, new)
enum State {UNLOADED, LOADED}
const config_path = "user://logue.cfg"
var config = ConfigFile.new()
var db : SQLite = SQLite.new()
var db = SQLite.new()
var current_scene = null
var current_state = State.UNLOADED
func _ready():
var root = get_tree().root
@ -18,6 +23,15 @@ func _ready():
var db_path = config.get_value("general", "db_path")
load_db(db_path)
func switch_state(new: State):
var old = current_state
if old == new:
return
current_state = new
#signal state_changed(old, new)
func load_db(path: String):
db.path = path
var success = db.open_db()