extends Node3D

@export_group("Mapping contexts")
@export var base_mode:GUIDEMappingContext

@export_group("Move actions")
@export var move:GUIDEAction
@export var rotate_y:GUIDEAction
@export var rotate_floorplane:GUIDEAction

@export_group("Trigger actions")
@export var aim_pressed:GUIDEAction
@export var aim_released:GUIDEAction
@export var aim_canceled:GUIDEAction
@export var jump:GUIDEAction

signal input_move(value: Vector3)
signal input_rotate_y(value: float)
signal input_rotate_floorplane(value: float)

signal input_aim_pressed
signal input_aim_released
signal input_aim_canceled
signal input_jump

func _ready() -> void:
	GUIDE.enable_mapping_context(base_mode)
	
	aim_pressed.triggered.connect(on_input_aim_pressed)
	aim_released.triggered.connect(on_input_aim_released)
	aim_canceled.triggered.connect(on_input_aim_canceled)
	jump.triggered.connect(on_input_jump)
	

func on_input_jump():
	input_jump.emit()

func on_input_aim_pressed():
	input_aim_pressed.emit()

func on_input_aim_released():
	input_aim_released.emit()

func on_input_aim_canceled():
	input_aim_canceled.emit()

func _process(_delta: float) -> void:
	input_move.emit(move.value_axis_3d)
	input_rotate_y.emit(rotate_y.value_axis_1d)
	input_rotate_floorplane.emit(rotate_floorplane.value_axis_1d)
