diff options
| author | Radio <radiohotline@disroot.org> | 2026-06-04 15:15:11 +0300 |
|---|---|---|
| committer | Radio <radiohotline@disroot.org> | 2026-06-04 15:15:11 +0300 |
| commit | 9d74b49ab62908d4acf53dde444413886b8b28e5 (patch) | |
| tree | 0cb785267ea7e239b19d88684c0d64b9bd5d52f0 /addons/escoria-dialog-simple/esc_dialog_simple_state_machine.gd | |
| parent | 2c85d452ad02a5f89cd43bad7f9de31d0e4fa0c1 (diff) | |
escoria setup and old branch archives
Diffstat (limited to 'addons/escoria-dialog-simple/esc_dialog_simple_state_machine.gd')
| -rw-r--r-- | addons/escoria-dialog-simple/esc_dialog_simple_state_machine.gd | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/addons/escoria-dialog-simple/esc_dialog_simple_state_machine.gd b/addons/escoria-dialog-simple/esc_dialog_simple_state_machine.gd new file mode 100644 index 0000000..4c48f60 --- /dev/null +++ b/addons/escoria-dialog-simple/esc_dialog_simple_state_machine.gd @@ -0,0 +1,34 @@ +extends StateMachine +## Instanciation of this dialogs state machine implementation. + +# Constructor +func _init(): + _create_states() + _add_states_to_machine() + current_state_name = "idle" + # This line is very important here: it defines the initial state of the + # dialogs state machine. Since Escoria can't guess which state is the default one + # it has to be assigned here. If it happens to be null on initialize() call, + # an error is triggered. + START_STATE = states_map[current_state_name] + initialize(START_STATE) + + +# Creates the states for this state machine. +func _create_states() -> void: + states_map = { + "idle": preload("res://addons/escoria-dialog-simple/states/dialog_idle.gd").new(), + "say": preload("res://addons/escoria-dialog-simple/states/dialog_say.gd").new(), + "say_fast": preload("res://addons/escoria-dialog-simple/states/dialog_say_fast.gd").new(), + "say_finish": preload("res://addons/escoria-dialog-simple/states/dialog_say_finish.gd").new(), + "visible": preload("res://addons/escoria-dialog-simple/states/dialog_visible.gd").new(), + "finish": preload("res://addons/escoria-dialog-simple/states/dialog_finish.gd").new(), + "interrupt": preload("res://addons/escoria-dialog-simple/states/dialog_interrupt.gd").new(), + "choices": preload("res://addons/escoria-dialog-simple/states/dialog_choices.gd").new() + } + + +# Adds any created states into the state machine as children. +func _add_states_to_machine() -> void: + for key in states_map: + add_child(states_map[key]) |
