extends MovementComponent

## Constants available to you
# UP = -1.0
# DOWN = 1.0
# LEFT = -1.0
# RIGHT = 1.0

# Avalable functions to call 
# A Series of helper functions
# go_up():
# go_down():
# go_left():
# go_right():
# stop():


export var player_number: int = 1

export (NodePath) var interactable_node

onready var interactable_receiver_node: Interactable_Receiver = get_node(interactable_node) 


func process_physics(delta):
	PlayerInfo.player_position = owner.global_position

func process_input(event: InputEvent):
	var interactables = interactable_receiver_node.interactable_function_callables
	for interactable in interactables: # Iterate through the interactable collection
		if interactable is Interactable: # Make sure we didn't push something dumb in there.
			if (Input.is_action_pressed("ui_up")): # We pressed up?
				interactable.trigger_interaction()
	get_movement_direction()
	
	
# Return the desired direction of movement for the character
# in the range [-1, 1], where positive values indicate a desire
# to move to the right and negative values to the left.
func get_movement_direction() -> float:
	#return Input.get_axis('move_left', 'move_right')
	desired_movement_vector.x = Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))
	return Input.get_axis("move_left_" + str(player_number), "move_right_" + str(player_number))

# Return a boolean indicating if the character wants to jump
func wants_jump() -> bool:
	
	if Input.is_action_just_pressed("jump_" + str(player_number)):
		desired_movement_vector.y = 1
		return true
	else:
		return false

# Return a boolean indicating if the character wants to jump
func wants_shoot() -> bool:	
	if Input.is_action_just_pressed("shoot_" + str(player_number)):
		return true
	else:
		return false

func wants_dash() -> bool:	
	if Input.is_action_just_pressed("dash_" + str(player_number)):
		return true
	else:
		return false

func wants_roll() -> bool:
	if Input.is_action_just_pressed("dash_" + str(player_number)) and Input.is_action_pressed("ui_up"):
		return true
	else:
		return false


## Other needed variables
# desired_movement_vector: Vector2 - Used to store desired movement depending on the state
# current_movement_state:String - The name of the current State

# Since animactor state machine can actually view properties from this type
# I'm thinking about moving the velocity tracker in here instead of player.
# velocity: Vector2 - Current velocity, you can change this at will but state may modify it

# Declare any other member variables here. Examples:
# var a = 2
# var b = "text"


# Called every frame. 'delta' is the elapsed time since the previous frame.
# you do not normally need to define this for Actor
#func process(delta):
#   pass

# For Enemy and NPC Actors:
# should be called on the frame process. 

# For Player Actors:
# Should be called on the input process 


