feat: plan deterministic generated conversations
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
class_name ConversationOption
|
||||
extends RefCounted
|
||||
|
||||
var _option_id: StringName
|
||||
var _intent_id: StringName
|
||||
var _speaker: WorldEntityRef
|
||||
var _listener: WorldEntityRef
|
||||
var _causal_topic_ids: Array[StringName] = []
|
||||
var _enabled := true
|
||||
var _reason_code: StringName
|
||||
var _reason_trace: Array[StringName] = []
|
||||
|
||||
|
||||
func _init(
|
||||
option_id: StringName = &"",
|
||||
intent_id: StringName = &"",
|
||||
speaker: WorldEntityRef = null,
|
||||
listener: WorldEntityRef = null,
|
||||
causal_topic_ids: Array[StringName] = [],
|
||||
enabled: bool = true,
|
||||
reason_code: StringName = &"",
|
||||
reason_trace: Array[StringName] = []
|
||||
) -> void:
|
||||
_option_id = option_id
|
||||
_intent_id = intent_id
|
||||
_speaker = ConversationSemantic.duplicate_entity(speaker)
|
||||
_listener = ConversationSemantic.duplicate_entity(listener)
|
||||
_causal_topic_ids = causal_topic_ids.duplicate()
|
||||
_enabled = enabled
|
||||
_reason_code = reason_code
|
||||
_reason_trace = reason_trace.duplicate()
|
||||
|
||||
|
||||
func is_valid() -> bool:
|
||||
return (
|
||||
ConversationSemantic.is_valid_id(_option_id)
|
||||
and ConversationSemantic.is_valid_id(_intent_id)
|
||||
and _speaker != null
|
||||
and _speaker.is_valid()
|
||||
and _listener != null
|
||||
and _listener.is_valid()
|
||||
and not _speaker.equals(_listener)
|
||||
and ConversationSemantic.normalize_id_array(_causal_topic_ids) != null
|
||||
and (_enabled or ConversationSemantic.is_valid_id(_reason_code))
|
||||
and ConversationSemantic.normalize_trace(_reason_trace) != null
|
||||
)
|
||||
|
||||
|
||||
func get_option_id() -> StringName:
|
||||
return _option_id
|
||||
|
||||
|
||||
func get_intent_id() -> StringName:
|
||||
return _intent_id
|
||||
|
||||
|
||||
func get_speaker() -> WorldEntityRef:
|
||||
return ConversationSemantic.duplicate_entity(_speaker)
|
||||
|
||||
|
||||
func get_listener() -> WorldEntityRef:
|
||||
return ConversationSemantic.duplicate_entity(_listener)
|
||||
|
||||
|
||||
func get_causal_topic_ids() -> Array[StringName]:
|
||||
return _causal_topic_ids.duplicate()
|
||||
|
||||
|
||||
func is_enabled() -> bool:
|
||||
return _enabled
|
||||
|
||||
|
||||
func get_reason_code() -> StringName:
|
||||
return _reason_code
|
||||
|
||||
|
||||
func get_reason_trace() -> Array[StringName]:
|
||||
return _reason_trace.duplicate()
|
||||
|
||||
|
||||
func copy() -> ConversationOption:
|
||||
return ConversationOption.new(
|
||||
_option_id,
|
||||
_intent_id,
|
||||
_speaker,
|
||||
_listener,
|
||||
_causal_topic_ids,
|
||||
_enabled,
|
||||
_reason_code,
|
||||
_reason_trace
|
||||
)
|
||||
Reference in New Issue
Block a user