feat: generate world-backed situations and commitments
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
class_name SituationAlternativeDefinition
|
||||
extends Resource
|
||||
|
||||
@export var alternative_id: StringName
|
||||
@export var display_name: String
|
||||
@export_multiline var description: String
|
||||
@export var resolution_predicate_ids: Array[StringName] = []
|
||||
@export var dialogue_topic_ids: Array[StringName] = []
|
||||
@export var commitment_terms: Dictionary = {}
|
||||
|
||||
|
||||
func validate() -> Array[String]:
|
||||
var errors: Array[String] = []
|
||||
if alternative_id.is_empty():
|
||||
errors.append("alternative_id is empty")
|
||||
if display_name.is_empty():
|
||||
errors.append("display_name is empty for alternative '%s'" % alternative_id)
|
||||
if resolution_predicate_ids.is_empty():
|
||||
errors.append("alternative '%s' has no resolution predicates" % alternative_id)
|
||||
for predicate_id in resolution_predicate_ids:
|
||||
if predicate_id.is_empty():
|
||||
errors.append("alternative '%s' has an empty resolution predicate ID" % alternative_id)
|
||||
for topic_id in dialogue_topic_ids:
|
||||
if topic_id.is_empty():
|
||||
errors.append("alternative '%s' has an empty dialogue topic ID" % alternative_id)
|
||||
for term_key in commitment_terms:
|
||||
if not term_key is String and not term_key is StringName:
|
||||
errors.append("alternative '%s' has a non-string commitment term key" % alternative_id)
|
||||
return errors
|
||||
|
||||
|
||||
func duplicate_alternative() -> SituationAlternativeDefinition:
|
||||
var copy := SituationAlternativeDefinition.new()
|
||||
copy.alternative_id = alternative_id
|
||||
copy.display_name = display_name
|
||||
copy.description = description
|
||||
copy.resolution_predicate_ids = resolution_predicate_ids.duplicate()
|
||||
copy.dialogue_topic_ids = dialogue_topic_ids.duplicate()
|
||||
copy.commitment_terms = commitment_terms.duplicate(true)
|
||||
return copy
|
||||
Reference in New Issue
Block a user