feat: author world events and social effects
This commit is contained in:
@@ -26,6 +26,8 @@ var _animals: Array[AnimalDefinition] = []
|
||||
var _situations: Array[SituationDefinition] = []
|
||||
var _dialogue_intents: Array[ConversationIntentDefinition] = []
|
||||
var _dialogue_template_catalogs: Array[ConversationTemplateCatalog] = []
|
||||
var _event_types: Array[EventTypeDefinition] = []
|
||||
var _social_consequences: Array[SocialConsequenceDefinition] = []
|
||||
var _packs_by_id: Dictionary = {}
|
||||
var _actions_by_id: Dictionary = {}
|
||||
var _professions_by_id: Dictionary = {}
|
||||
@@ -38,6 +40,8 @@ var _animals_by_id: Dictionary = {}
|
||||
var _situations_by_id: Dictionary = {}
|
||||
var _dialogue_intents_by_id: Dictionary = {}
|
||||
var _dialogue_template_catalogs_by_id: Dictionary = {}
|
||||
var _event_types_by_id: Dictionary = {}
|
||||
var _social_consequences_by_id: Dictionary = {}
|
||||
|
||||
|
||||
static func create_core(
|
||||
@@ -128,6 +132,8 @@ func rebuild(
|
||||
var situations_by_id := {}
|
||||
var dialogue_intents_by_id := {}
|
||||
var dialogue_template_catalogs_by_id := {}
|
||||
var event_types_by_id := {}
|
||||
var social_consequences_by_id := {}
|
||||
var actions: Array[ActionDefinition] = []
|
||||
var professions: Array[ProfessionDefinition] = []
|
||||
var capability_tags: Array[CapabilityTagDefinition] = []
|
||||
@@ -139,6 +145,8 @@ func rebuild(
|
||||
var situations: Array[SituationDefinition] = []
|
||||
var dialogue_intents: Array[ConversationIntentDefinition] = []
|
||||
var dialogue_template_catalogs: Array[ConversationTemplateCatalog] = []
|
||||
var event_types: Array[EventTypeDefinition] = []
|
||||
var social_consequences: Array[SocialConsequenceDefinition] = []
|
||||
|
||||
for pack in pack_list:
|
||||
if pack == null:
|
||||
@@ -163,6 +171,8 @@ func rebuild(
|
||||
_collect_dialogue_template_catalogs(
|
||||
pack, dialogue_template_catalogs, dialogue_template_catalogs_by_id, errors
|
||||
)
|
||||
_collect_event_types(pack, event_types, event_types_by_id, errors)
|
||||
_collect_social_consequences(pack, social_consequences, social_consequences_by_id, errors)
|
||||
|
||||
for pack in pack_list:
|
||||
if pack == null:
|
||||
@@ -211,6 +221,7 @@ func rebuild(
|
||||
actions_by_id,
|
||||
items_by_id,
|
||||
dialogue_intents_by_id,
|
||||
event_types_by_id,
|
||||
supported_event_predicates,
|
||||
supported_state_predicates,
|
||||
supported_expiry_predicates,
|
||||
@@ -219,6 +230,7 @@ func rebuild(
|
||||
_validate_dialogue_references(
|
||||
dialogue_intents, dialogue_intents_by_id, dialogue_template_catalogs_by_id, errors
|
||||
)
|
||||
_validate_social_consequence_references(social_consequences, event_types_by_id, errors)
|
||||
errors.sort()
|
||||
_errors = errors
|
||||
if not errors.is_empty():
|
||||
@@ -235,6 +247,8 @@ func rebuild(
|
||||
situations.sort_custom(_sort_situations)
|
||||
dialogue_intents.sort_custom(_sort_dialogue_intents)
|
||||
dialogue_template_catalogs.sort_custom(_sort_dialogue_template_catalogs)
|
||||
event_types.sort_custom(_sort_event_types)
|
||||
social_consequences.sort_custom(_sort_social_consequences)
|
||||
_packs = pack_list
|
||||
_actions = actions
|
||||
_professions = professions
|
||||
@@ -247,6 +261,8 @@ func rebuild(
|
||||
_situations = situations
|
||||
_dialogue_intents = dialogue_intents
|
||||
_dialogue_template_catalogs = dialogue_template_catalogs
|
||||
_event_types = event_types
|
||||
_social_consequences = social_consequences
|
||||
_packs_by_id = packs_by_id
|
||||
_actions_by_id = actions_by_id
|
||||
_professions_by_id = professions_by_id
|
||||
@@ -259,6 +275,8 @@ func rebuild(
|
||||
_situations_by_id = situations_by_id
|
||||
_dialogue_intents_by_id = dialogue_intents_by_id
|
||||
_dialogue_template_catalogs_by_id = dialogue_template_catalogs_by_id
|
||||
_event_types_by_id = event_types_by_id
|
||||
_social_consequences_by_id = social_consequences_by_id
|
||||
_valid = true
|
||||
return []
|
||||
|
||||
@@ -319,6 +337,14 @@ func get_dialogue_template_catalogs() -> Array[ConversationTemplateCatalog]:
|
||||
return _dialogue_template_catalogs.duplicate()
|
||||
|
||||
|
||||
func get_event_types() -> Array[EventTypeDefinition]:
|
||||
return _event_types.duplicate()
|
||||
|
||||
|
||||
func get_social_consequences() -> Array[SocialConsequenceDefinition]:
|
||||
return _social_consequences.duplicate()
|
||||
|
||||
|
||||
func get_pack(pack_id: StringName) -> SimulationContentPack:
|
||||
return _packs_by_id.get(pack_id) as SimulationContentPack
|
||||
|
||||
@@ -367,6 +393,14 @@ func get_dialogue_template_catalog(catalog_id: StringName) -> ConversationTempla
|
||||
return _dialogue_template_catalogs_by_id.get(catalog_id) as ConversationTemplateCatalog
|
||||
|
||||
|
||||
func get_event_type(event_type_id: StringName) -> EventTypeDefinition:
|
||||
return _event_types_by_id.get(event_type_id) as EventTypeDefinition
|
||||
|
||||
|
||||
func get_social_consequence(consequence_id: StringName) -> SocialConsequenceDefinition:
|
||||
return _social_consequences_by_id.get(consequence_id) as SocialConsequenceDefinition
|
||||
|
||||
|
||||
func get_authoring_report() -> Dictionary:
|
||||
return {
|
||||
"valid": _valid,
|
||||
@@ -383,6 +417,8 @@ func get_authoring_report() -> Dictionary:
|
||||
"situations": _ids_for(_situations, &"situation_definition_id"),
|
||||
"dialogue_intents": _ids_for(_dialogue_intents, &"intent_id"),
|
||||
"dialogue_template_catalogs": _ids_for(_dialogue_template_catalogs, &"catalog_id"),
|
||||
"event_types": _ids_for(_event_types, &"event_type_id"),
|
||||
"social_consequences": _ids_for(_social_consequences, &"consequence_id"),
|
||||
}
|
||||
|
||||
|
||||
@@ -401,6 +437,8 @@ func _clear_published_content() -> void:
|
||||
_situations.clear()
|
||||
_dialogue_intents.clear()
|
||||
_dialogue_template_catalogs.clear()
|
||||
_event_types.clear()
|
||||
_social_consequences.clear()
|
||||
_packs_by_id.clear()
|
||||
_actions_by_id.clear()
|
||||
_professions_by_id.clear()
|
||||
@@ -413,6 +451,8 @@ func _clear_published_content() -> void:
|
||||
_situations_by_id.clear()
|
||||
_dialogue_intents_by_id.clear()
|
||||
_dialogue_template_catalogs_by_id.clear()
|
||||
_event_types_by_id.clear()
|
||||
_social_consequences_by_id.clear()
|
||||
|
||||
|
||||
static func _collect_actions(
|
||||
@@ -593,6 +633,38 @@ static func _collect_dialogue_template_catalogs(
|
||||
definitions.append(definition)
|
||||
|
||||
|
||||
static func _collect_event_types(
|
||||
pack: SimulationContentPack,
|
||||
definitions: Array[EventTypeDefinition],
|
||||
definitions_by_id: Dictionary,
|
||||
errors: Array[String]
|
||||
) -> void:
|
||||
for definition in pack.event_types:
|
||||
if definition == null:
|
||||
continue
|
||||
if definitions_by_id.has(definition.event_type_id):
|
||||
errors.append("Duplicate event_type_id '%s'" % definition.event_type_id)
|
||||
continue
|
||||
definitions_by_id[definition.event_type_id] = definition
|
||||
definitions.append(definition)
|
||||
|
||||
|
||||
static func _collect_social_consequences(
|
||||
pack: SimulationContentPack,
|
||||
definitions: Array[SocialConsequenceDefinition],
|
||||
definitions_by_id: Dictionary,
|
||||
errors: Array[String]
|
||||
) -> void:
|
||||
for definition in pack.social_consequences:
|
||||
if definition == null:
|
||||
continue
|
||||
if definitions_by_id.has(definition.consequence_id):
|
||||
errors.append("Duplicate social consequence_id '%s'" % definition.consequence_id)
|
||||
continue
|
||||
definitions_by_id[definition.consequence_id] = definition
|
||||
definitions.append(definition)
|
||||
|
||||
|
||||
static func _validate_action_references(
|
||||
actions: Array[ActionDefinition],
|
||||
actions_by_id: Dictionary,
|
||||
@@ -897,6 +969,7 @@ static func _validate_situation_references(
|
||||
actions_by_id: Dictionary,
|
||||
items_by_id: Dictionary,
|
||||
dialogue_intents_by_id: Dictionary,
|
||||
event_types_by_id: Dictionary,
|
||||
supported_event_predicates: Dictionary,
|
||||
supported_state_predicates: Dictionary,
|
||||
supported_expiry_predicates: Dictionary,
|
||||
@@ -918,6 +991,17 @@ static func _validate_situation_references(
|
||||
% [definition.situation_definition_id, intent_id]
|
||||
)
|
||||
)
|
||||
for predicate in definition.trigger_predicates + definition.resolution_predicates:
|
||||
if predicate == null or predicate.evaluator_id != &"event_type":
|
||||
continue
|
||||
var event_type_id := StringName(predicate.parameters.get("event_type", ""))
|
||||
if not event_types_by_id.has(event_type_id):
|
||||
errors.append(
|
||||
(
|
||||
"Situation predicate '%s' references unknown event type '%s'"
|
||||
% [predicate.predicate_id, event_type_id]
|
||||
)
|
||||
)
|
||||
for alternative in definition.alternatives:
|
||||
if alternative == null:
|
||||
continue
|
||||
@@ -983,6 +1067,21 @@ static func _validate_dialogue_references(
|
||||
errors.append("Dialogue template catalog '%s': %s" % [catalog_id, error])
|
||||
|
||||
|
||||
static func _validate_social_consequence_references(
|
||||
definitions: Array[SocialConsequenceDefinition],
|
||||
event_types_by_id: Dictionary,
|
||||
errors: Array[String]
|
||||
) -> void:
|
||||
for definition in definitions:
|
||||
if not event_types_by_id.has(definition.event_type_id):
|
||||
errors.append(
|
||||
(
|
||||
"Social consequence '%s' references unknown event type '%s'"
|
||||
% [definition.consequence_id, definition.event_type_id]
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
static func _validated_id_set(
|
||||
provided_ids: Array[StringName],
|
||||
default_ids: Array[StringName],
|
||||
@@ -1069,6 +1168,16 @@ static func _sort_dialogue_template_catalogs(
|
||||
return String(first.catalog_id) < String(second.catalog_id)
|
||||
|
||||
|
||||
static func _sort_event_types(first: EventTypeDefinition, second: EventTypeDefinition) -> bool:
|
||||
return String(first.event_type_id) < String(second.event_type_id)
|
||||
|
||||
|
||||
static func _sort_social_consequences(
|
||||
first: SocialConsequenceDefinition, second: SocialConsequenceDefinition
|
||||
) -> bool:
|
||||
return String(first.consequence_id) < String(second.consequence_id)
|
||||
|
||||
|
||||
static func _ids_for(definitions: Array, id_property: StringName) -> Array[StringName]:
|
||||
var ids: Array[StringName] = []
|
||||
for definition in definitions:
|
||||
|
||||
Reference in New Issue
Block a user