class_name ActionRouter extends RefCounted const InputBindingsType = preload("res://scripts/game/input_bindings.gd") const PlayerActionType = preload("res://scripts/domain/run/player_action.gd") var _game: Game func _init(game: Game) -> void: _game = game func action_from_input(event: InputEvent) -> PlayerAction: for input_action in InputBindingsType.input_actions(): if event.is_action_pressed(input_action): return PlayerActionType.new( InputBindingsType.player_action_for(input_action), InputBindingsType.direction_for(input_action) ) return null func submit(action: PlayerAction) -> Array[GameEvent]: if _game == null: return [] return _game.submit_player_action(action)