- Fix input_mapper double-check bug (redundant InputEventKey + pressed filter) - Add bounds checking for position arrays in entity_renderer and game_state - Make test snapshot deterministic (incrementing counter, not wall clock) - Fix tween overlap in monologue_display (cancel active tween before new one) - Extract TILE_SIZE constant from magic number 32 - Add 5 D-030 Layer 1 fixture tests for snapshot parsing (7/7 total passing) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45 lines
1.3 KiB
GDScript
45 lines
1.3 KiB
GDScript
extends Node
|
|
|
|
# Semantic actions — NO raw key codes cross the bridge
|
|
enum Action {
|
|
MOVE_NORTH, MOVE_SOUTH, MOVE_EAST, MOVE_WEST,
|
|
INTERACT, USE_PERCEPTION_MODE, OPEN_MENU, PAUSE
|
|
}
|
|
|
|
var input_queue: Array[Dictionary] = []
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
var action: Action = -1
|
|
|
|
# Map input actions to semantic Action enum
|
|
# is_action_pressed handles press detection for all input types (key, gamepad, etc.)
|
|
if event.is_action_pressed("move_north"):
|
|
action = Action.MOVE_NORTH
|
|
elif event.is_action_pressed("move_south"):
|
|
action = Action.MOVE_SOUTH
|
|
elif event.is_action_pressed("move_east"):
|
|
action = Action.MOVE_EAST
|
|
elif event.is_action_pressed("move_west"):
|
|
action = Action.MOVE_WEST
|
|
elif event.is_action_pressed("interact"):
|
|
action = Action.INTERACT
|
|
elif event.is_action_pressed("perception_mode"):
|
|
action = Action.USE_PERCEPTION_MODE
|
|
elif event.is_action_pressed("open_menu"):
|
|
action = Action.OPEN_MENU
|
|
elif event.is_action_pressed("pause"):
|
|
action = Action.PAUSE
|
|
|
|
# Queue the action if valid
|
|
if action != -1:
|
|
input_queue.append({
|
|
"action": action,
|
|
"timestamp_msec": Time.get_ticks_msec()
|
|
})
|
|
get_viewport().set_input_as_handled()
|
|
|
|
func flush_queue() -> Array[Dictionary]:
|
|
var queue = input_queue.duplicate()
|
|
input_queue.clear()
|
|
return queue
|