Vast improvements and a working finite state machine, working on new guild member registration.

This commit is contained in:
2025-07-24 08:41:19 -04:00
parent 90151369de
commit dc30d1b15c
100 changed files with 1987 additions and 194 deletions

View File

@@ -0,0 +1,43 @@
class_name StateMachine extends Node
@export var starting_state : String = ""
var states : Dictionary[String, StateNode] = {}
var curr_state : StateNode = null
var actor = null
func _ready() -> void:
for child in get_children():
if child is StateNode:
states[child.name] = child
child.state_machine = self
child.completed.connect(_on_state_completed)
func start() -> void:
if starting_state != "":
var state : StateNode = states.get(starting_state)
if state == null:
printerr("Starting state not found! Expected %s" % [starting_state])
else:
enter_state(state)
curr_state.execute(actor)
func exit_state(state : StateNode) -> void:
curr_state.exit()
curr_state = null
pass
func enter_state(state : StateNode) -> void:
curr_state = state
curr_state.enter()
pass
func advance_state() -> void:
pass
func _on_state_completed(state : StateNode) -> void:
if state == curr_state:
advance_state()
else:
printerr("Wrong state completed! %s when expecting %s" % [state.name, curr_state])