Added AbstractState and StateMachine

This commit is contained in:
2026-01-30 23:42:34 +03:00
parent ecc1fbc05a
commit 7f12066244
9 changed files with 70 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
class_name StateMachine
extends Node
var current_state : AbstractState
func _process(delta: float) -> void:
if current_state:
current_state.process(delta)
func _physics_process(delta: float) -> void:
if current_state:
current_state.physics_process(delta)
func change_state(new_state: AbstractState) -> void:
if current_state:
current_state.exit()
current_state = new_state
current_state.enter()