From cbc83e8d20e84f38b2f5305a43c5a2c7078e884c Mon Sep 17 00:00:00 2001 From: yuki Date: Sun, 23 Nov 2025 08:50:04 -0300 Subject: [PATCH] add room paused state --- scenes/room/states/room_paused.gd | 17 +++++++++++++++++ scenes/room/states/room_paused.gd.uid | 1 + scenes/room/states/room_playing.gd | 9 ++++++--- 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 scenes/room/states/room_paused.gd create mode 100644 scenes/room/states/room_paused.gd.uid diff --git a/scenes/room/states/room_paused.gd b/scenes/room/states/room_paused.gd new file mode 100644 index 0000000..7eb4cee --- /dev/null +++ b/scenes/room/states/room_paused.gd @@ -0,0 +1,17 @@ +extends RoomState + + +var _prev_state: String + + +func _enter(previous_state_path: String, _data: Dictionary = {}) -> void: + print("entering room pause") + _prev_state = previous_state_path + get_tree().paused = true + print("room paused") + + +func _handle_input(event: InputEvent) -> void: + if event.is_action_pressed("pause"): + finished.emit(_prev_state) + return diff --git a/scenes/room/states/room_paused.gd.uid b/scenes/room/states/room_paused.gd.uid new file mode 100644 index 0000000..d734218 --- /dev/null +++ b/scenes/room/states/room_paused.gd.uid @@ -0,0 +1 @@ +uid://ceevyto3vbq7c diff --git a/scenes/room/states/room_playing.gd b/scenes/room/states/room_playing.gd index d4fb655..2c66829 100644 --- a/scenes/room/states/room_playing.gd +++ b/scenes/room/states/room_playing.gd @@ -3,10 +3,13 @@ extends RoomState func _enter(_previous_state_path: String, _data: Dictionary = {}) -> void: print("entering room gameplay") + get_tree().paused = false + + +func _handle_input(event: InputEvent) -> void: + if event.is_action_pressed("pause"): + finished.emit(PAUSED) func _state_physics_update(delta: float) -> void: room.camera.follow_player(delta) - - if Input.is_action_just_pressed("pause"): - finished.emit(PAUSED)