extends StateAnimatedActor

export (NodePath) var fall_node
export (NodePath) var move_node
export (NodePath) var jump_node
export (NodePath) var attack_node
export (NodePath) var dash_node
export (NodePath) var roll_node

onready var fall_state: State = get_node(fall_node)
onready var move_state: State = get_node(move_node)
onready var jump_state: State = get_node(jump_node)
onready var attack_state: State = get_node(attack_node)
onready var dash_state: State = get_node(dash_node)
onready var roll_state: State = get_node(roll_node)

func enter() -> void:
	.enter()
#	parent.set_hurtbox(true)
	move_component.velocity.x = 0
	if debug_state:
		print(owner.name, " Move Component: ", move_component.desired_movement_vector.x)

func process_physics(delta: float) -> State:

	if move_component.wants_jump() and parent.is_on_floor():
		return jump_state

	# We need to offer roll before dash because the inputs are the same
	if move_component.wants_roll() and parent.is_on_floor():
		return roll_state

	if move_component.wants_dash() and parent.is_on_floor():
		return dash_state


	if move_component.wants_shoot():
		return attack_state
	
	move_actor_as_desired(delta)
	
	if move_component.velocity.x != 0.0:
		return move_state
	
	if !parent.is_on_floor():
		return fall_state
	return null
