extends BasisInteraction

class_name TalkInteraction

var is_talking = false

export var yarnScript : Resource

var yarnRunner := YarnRunner.new()

func on_interact():
	if not is_talking:
		yarnRunner.say_func = funcref(Controller.speech_panel.text, "on_new_line")
		yarnRunner.choices_func = funcref(Controller.speech_panel.choices, "on_choices")
		yarnRunner.yarnScript = self.yarnScript
		
		is_talking = true
		Controller.speech_panel.show()
		Controller.player_input_enabled = false
		
		yield(yarnRunner.run_all(), "completed")
		
		Controller.player_input_enabled = true
		Controller.speech_panel.hide()
		is_talking = false
