extends Area2D

# warning-ignore:unused_signal
signal used
# warning-ignore:unused_signal
signal item_used(item_id)

export(String, "action", "door", "move") \
	var type: String = "action"
export(String, FILE) var next_scene
export(Vector2) var destination
export(String) var player_animation = ""
enum PlayerFacing {
	NULL = -1,
	RIGHT = 0
	LEFT = 1
}
export(PlayerFacing) var player_facing = PlayerFacing.NULL
export var sound: String

onready var global: Node = get_node("/root/Global")

func _on_Object_input_event(_viewport, event, _shape_idx) -> void:
	if !event is InputEventMouseButton:
		return
	if !event.pressed:
		return
	if event.button_index == BUTTON_LEFT:
		match type:
			"action", "door":
				action()
			"move":
				move()

func action() -> void:
	global.move_player(global_position, self)

func move() -> void:
	global.move_player(get_global_mouse_position().floor(), null)
