From d23a7c4c36a2caa3dab215c88d845793fe73f5bb Mon Sep 17 00:00:00 2001 From: yuki Date: Sun, 23 Nov 2025 07:37:35 -0300 Subject: [PATCH] begin work on room state machine --- scenes/room/room_state.gd | 48 +++++++++++++++++++++++++++++++++++ scenes/room/room_state.gd.uid | 1 + 2 files changed, 49 insertions(+) create mode 100644 scenes/room/room_state.gd create mode 100644 scenes/room/room_state.gd.uid diff --git a/scenes/room/room_state.gd b/scenes/room/room_state.gd new file mode 100644 index 0000000..a868010 --- /dev/null +++ b/scenes/room/room_state.gd @@ -0,0 +1,48 @@ +class_name RoomState extends State + + +const STARTING = "Starting" +const PLAYING = "Playing" +const EXITING = "Exiting" + +var room: Room + + +func _ready() -> void: + await owner.ready + room = owner as Room + assert(room != null, "The RoomState state type must be used only in the room scene. It needs the owner's parent to be a Room node.") + + +func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void: + pass + + +func _exit() -> void: + pass + + +func _handle_input(_event: InputEvent) -> void: + pass + + +func _state_update(_delta: float) -> void: + pass + + +func _state_physics_update(_delta: float) -> void: + pass + + +func match_state(exclude: Array[StringName] = []) -> StringName: + + return "" + + +func watch_state(exclude: Array[StringName] = [], data: Dictionary[StringName, Variant] = {}) -> bool: + var next_state: StringName = match_state(exclude) + if next_state != "": + finished.emit(next_state, data) + return true + + return false diff --git a/scenes/room/room_state.gd.uid b/scenes/room/room_state.gd.uid new file mode 100644 index 0000000..3bca291 --- /dev/null +++ b/scenes/room/room_state.gd.uid @@ -0,0 +1 @@ +uid://hjm43hb4os07