40 lines
912 B
GDScript
40 lines
912 B
GDScript
@tool
|
|
class_name NPCInteract extends Node
|
|
|
|
enum InteractType {
|
|
NONE,
|
|
TEXT,
|
|
CUTSCENE
|
|
}
|
|
|
|
@export var interactType:InteractType = InteractType.NONE
|
|
@export var interactText:Array[String] = []
|
|
|
|
var interactTextIndex:int = 0
|
|
|
|
func onInteract(_player:Player) -> void:
|
|
if interactType == InteractType.TEXT:
|
|
interactTextIndex = 0
|
|
UI.TEXTBOX.setText(interactText[interactTextIndex])
|
|
UI.TEXTBOX.textboxClosing.connect(onTextboxClosing)
|
|
return
|
|
|
|
pass
|
|
|
|
func onInteractable(player:Player) -> void:
|
|
pass
|
|
|
|
func onNotInteractable(player:Player) -> void:
|
|
pass
|
|
|
|
func _exit_tree() -> void:
|
|
UI.TEXTBOX.textboxClosing.disconnect(onTextboxClosing)
|
|
|
|
func onTextboxClosing() -> void:
|
|
interactTextIndex += 1
|
|
if interactTextIndex < interactText.size():
|
|
UI.TEXTBOX.setText(interactText[interactTextIndex])
|
|
else:
|
|
UI.TEXTBOX.textboxClosing.disconnect(onTextboxClosing)
|
|
UI.TEXTBOX.setText("")
|