extends PlayerState


func _input(event: InputEvent) -> void:
	if Input.is_action_pressed("move_up") and player.current_path_node.up_connection:
		player.current_path_node = player.current_path_node.up_connection
		player.state_machine.switch_state($"../PlayerStateMove")
		player.player_moved.emit()
	
	elif Input.is_action_pressed("move_right") and player.current_path_node.right_connection:
		player.current_path_node = player.current_path_node.right_connection
		player.state_machine.switch_state($"../PlayerStateMove")
		player.player_moved.emit()
	
	elif Input.is_action_pressed("move_down") and player.current_path_node.down_connection:
		player.current_path_node = player.current_path_node.down_connection
		player.state_machine.switch_state($"../PlayerStateMove")
		player.player_moved.emit()
	
	elif Input.is_action_pressed("move_left") and player.current_path_node.left_connection:
		player.current_path_node = player.current_path_node.left_connection
		player.state_machine.switch_state($"../PlayerStateMove")
		player.player_moved.emit()


func _enter_state():
	player.set_deferred("monitoring", true)
	player.set_deferred("monitorable", true)
	player.animation_player.play(GameConstants.ANIM_IDLE)

func _exit_state():
	player.set_deferred("monitoring", false)
	player.set_deferred("monitorable", false)
