forked from harper/spooktober-vnj
30 lines
948 B
GDScript
30 lines
948 B
GDScript
extends Resource
|
|
class_name Choice
|
|
|
|
@export var response: String
|
|
@export var targets: Array[ChoiceTarget]
|
|
|
|
func get_target()->DialogueScene:
|
|
for target : ChoiceTarget in targets:
|
|
if target.condition_events.is_empty():
|
|
if !target.target_event.is_empty():
|
|
Game.log_event_data(target.target_event)
|
|
return target.target_scene
|
|
if Game.has_all_events_data(target.condition_events):
|
|
if !target.target_event.is_empty():
|
|
Game.log_event_data(target.target_event)
|
|
return target.target_scene
|
|
print(error_string(ERR_INVALID_PARAMETER) +
|
|
" in Choice.get_target(), check that there is a target with an empty condition_events in targets")
|
|
return null
|
|
|
|
func _init(str1 : String, targs : Array[ChoiceTarget]):
|
|
response = str1
|
|
targets = targs
|
|
|
|
static func load_dict(dict : Dictionary) -> Choice:
|
|
var ts : Array[ChoiceTarget] = []
|
|
for tar : Dictionary in dict["t"]:
|
|
ts.append(ChoiceTarget.load_dict(tar))
|
|
return new(dict["r"], ts)
|