Added gameplay_input manager.
Refactored menus, player, and escape_capsule to utilize new system. Actions defined in Godot project file with default bindings. Player/Vehicles now react to actions and GameplayInput states instead of polling Input directly. They respond to commands via `_handle_gameplay_command` and should not implement _unhandled_input directly. Kept some debugging input handling code in `player.gd` for things like F3/F5/F4/PageUp/PageDown. We may want to move much of this out of `player.gd` into something that handles the gamestate more generally.
This commit is contained in:
@@ -17,8 +17,11 @@ func _ready() -> void:
|
||||
quit_button.pressed.connect(_on_quit_to_menu)
|
||||
|
||||
|
||||
## Pause has its own binding; menu cancel must not pause during gameplay.
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not event.is_action_pressed("ui_cancel"):
|
||||
var pause_pressed := event.is_action_pressed("ui_pause")
|
||||
var cancel_pressed := event.is_action_pressed("ui_cancel")
|
||||
if not pause_pressed and not (visible and cancel_pressed):
|
||||
return
|
||||
var banner := get_node_or_null("/root/Node3D/HUD/ScrambleBanner")
|
||||
if banner and banner.visible:
|
||||
@@ -27,6 +30,8 @@ func _input(event: InputEvent) -> void:
|
||||
_on_resume()
|
||||
get_viewport().set_input_as_handled()
|
||||
return
|
||||
if not GameplayInput.gameplay_enabled():
|
||||
return
|
||||
var p := get_tree().get_first_node_in_group("player")
|
||||
if p == null:
|
||||
p = get_node_or_null("/root/Node3D/Player")
|
||||
@@ -35,16 +40,21 @@ func _input(event: InputEvent) -> void:
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
## Blocks gameplay and selects a controller-accessible control before pausing.
|
||||
func open_pause(player_ref: Node) -> void:
|
||||
player = player_ref
|
||||
visible = true
|
||||
GameplayInput.set_menu_open(self, true)
|
||||
resume_button.grab_focus()
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
get_tree().paused = true
|
||||
|
||||
|
||||
## Restores control only after currently held gameplay inputs return to neutral.
|
||||
func _on_resume() -> void:
|
||||
visible = false
|
||||
get_tree().paused = false
|
||||
GameplayInput.set_menu_open(self, false)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
|
||||
@@ -59,5 +69,6 @@ func _on_save() -> void:
|
||||
|
||||
func _on_quit_to_menu() -> void:
|
||||
get_tree().paused = false
|
||||
GameplayInput.set_menu_open(self, false)
|
||||
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
|
||||
get_tree().change_scene_to_file("res://Scenes/main_menu.tscn")
|
||||
|
||||
Reference in New Issue
Block a user