refactor: separate content from presentation assets

This commit is contained in:
Rijad Zuzo
2026-08-12 21:41:33 +02:00
parent 5a70aaaded
commit bf4bf73675
22 changed files with 480 additions and 70 deletions
+18 -3
View File
@@ -10,6 +10,7 @@ signal navigation_failed(animal_id: StringName, site_id: StringName)
static var _all: Array[AnimalNode] = []
static var _core_animal_catalog: AnimalCatalog
static var _core_presentation_catalog: PresentationCatalog
@export var animal_id: StringName
@export var display_name := "Animal"
@@ -39,6 +40,7 @@ var navigation_request_id := 0
var path_pending := false
var has_reported_navigation_result := true
var _animal_definition: AnimalDefinition
var _presentation_parameters: Dictionary = {}
func _ready() -> void:
@@ -132,7 +134,9 @@ func supports_action(action_id: StringName) -> bool:
return action_id in supported_action_ids
func apply_animal_definition(definition: AnimalDefinition) -> bool:
func apply_animal_definition(
definition: AnimalDefinition, presentation_parameters: Dictionary = {}
) -> bool:
if definition == null or not definition.validate().is_empty():
return false
if state != null and state.get_animal_definition_id() != definition.animal_definition_id:
@@ -142,9 +146,10 @@ func apply_animal_definition(definition: AnimalDefinition) -> bool:
species_id = definition.species_id
supported_action_ids = definition.supported_action_ids.duplicate()
move_speed = definition.movement_speed
_presentation_parameters = presentation_parameters.duplicate(true)
var visual := get_node_or_null("Visual")
if visual != null and visual.has_method("apply_animal_definition"):
return bool(visual.apply_animal_definition(definition))
return bool(visual.apply_animal_definition(definition, _presentation_parameters))
return true
@@ -164,7 +169,17 @@ func _ensure_animal_definition() -> bool:
_core_animal_catalog = AnimalCatalog.create_core()
if _core_animal_catalog == null:
return false
return apply_animal_definition(_core_animal_catalog.get_definition(animal_definition_id))
var definition := _core_animal_catalog.get_definition(animal_definition_id)
if _core_presentation_catalog == null:
_core_presentation_catalog = PresentationCatalog.create_core()
if (
definition == null
or _core_presentation_catalog == null
or not _core_presentation_catalog.is_valid()
):
return false
var cue := _core_presentation_catalog.get_definition(definition.presentation_cue_id)
return cue != null and apply_animal_definition(definition, cue.get_parameters())
func get_hunger() -> float: