extends Node2D

var debug_enabled = false

func _process(_delta: float) -> void:
	if debug_enabled:
		var player = get_tree().get_first_node_in_group("player")
		if player:
			player.health = player.max_health
		handle_debug()
		
func handle_debug():
	if Input.is_key_pressed(KEY_1):
		var player = get_tree().get_first_node_in_group("player")
		print(player)
		if player:
			player.global_position = get_global_mouse_position()
	if Input.is_key_pressed(KEY_2):
		EventBus.dialogue_requested.emit("Test dialogue!!")
		EventBus.dialogue_requested.emit("More dialogue!!")
		EventBus.dialogue_requested.emit("End dialogue")

func _unhandled_input(event: InputEvent) -> void:
	if event.is_action_pressed("debug"):
		debug_enabled = !debug_enabled
		EventBus.debug_enable.emit(debug_enabled)
