SupaLidlGame/addons/dialogue_manager/dialogue_resource.gd

43 lines
1.4 KiB
GDScript
Raw Normal View History

2024-04-08 14:42:12 -07:00
@tool
2023-07-27 11:39:38 -07:00
@icon("./assets/icon.svg")
2024-04-08 14:42:12 -07:00
## A collection of dialogue lines for use with [code]DialogueManager[/code].
2023-07-27 11:39:38 -07:00
class_name DialogueResource extends Resource
2024-04-08 14:42:12 -07:00
const _DialogueManager = preload("./dialogue_manager.gd")
2023-07-27 11:39:38 -07:00
2024-04-08 14:42:12 -07:00
## A list of state shortcuts
@export var using_states: PackedStringArray = []
2023-07-27 11:39:38 -07:00
2024-04-08 14:42:12 -07:00
## A map of titles and the lines they point to.
2023-07-27 11:39:38 -07:00
@export var titles: Dictionary = {}
2024-04-08 14:42:12 -07:00
## A list of character names.
2023-07-27 11:39:38 -07:00
@export var character_names: PackedStringArray = []
2024-04-08 14:42:12 -07:00
## The first title in the file.
2023-07-27 11:39:38 -07:00
@export var first_title: String = ""
2024-04-08 14:42:12 -07:00
## A map of the encoded lines of dialogue.
2023-07-27 11:39:38 -07:00
@export var lines: Dictionary = {}
2024-04-08 14:42:12 -07:00
## raw version of the text
@export var raw_text: String
2023-07-27 11:39:38 -07:00
2024-04-08 14:42:12 -07:00
## Get the next printable line of dialogue, starting from a referenced line ([code]title[/code] can
## be a title string or a stringified line number). Runs any mutations along the way and then returns
## the first dialogue line encountered.
func get_next_dialogue_line(title: String, extra_game_states: Array = [], mutation_behaviour: _DialogueManager.MutationBehaviour = _DialogueManager.MutationBehaviour.Wait) -> DialogueLine:
2023-07-27 11:39:38 -07:00
return await Engine.get_singleton("DialogueManager").get_next_dialogue_line(self, title, extra_game_states, mutation_behaviour)
2024-04-08 14:42:12 -07:00
## Get the list of any titles found in the file.
2023-07-27 11:39:38 -07:00
func get_titles() -> PackedStringArray:
return titles.keys()
2024-04-08 14:42:12 -07:00
func _to_string() -> String:
return "<DialogueResource titles=\"%s\">" % [",".join(titles.keys())]