This commit is contained in:
2026-04-04 16:04:51 +02:00
parent eaa8f18a4a
commit cd23125739
9 changed files with 870 additions and 7 deletions

View File

@@ -721,7 +721,10 @@ func _get_generator_state(generator_id: StringName) -> Dictionary:
var existing_raw: Variant = generator_states.get(key, _default_generator_state(false, false, 0))
if existing_raw is Dictionary:
var state: Dictionary = existing_raw
var sanitized: Dictionary = _sanitize_generator_state(state, false, false, 0)
var current_unlocked: bool = state.get(GENERATOR_UNLOCKED_KEY, false)
var current_available: bool = state.get(GENERATOR_AVAILABLE_KEY, false)
var current_owned: int = state.get(GENERATOR_OWNED_KEY, 0)
var sanitized: Dictionary = _sanitize_generator_state(state, current_unlocked, current_available, current_owned)
generator_states[key] = sanitized
return sanitized
@@ -734,7 +737,10 @@ func _set_generator_state(generator_id: StringName, state: Dictionary) -> void:
if key.is_empty():
return
var sanitized: Dictionary = _sanitize_generator_state(state, false, false, 0)
var current_unlocked: bool = state.get(GENERATOR_UNLOCKED_KEY, false)
var current_available: bool = state.get(GENERATOR_AVAILABLE_KEY, false)
var current_owned: int = state.get(GENERATOR_OWNED_KEY, 0)
var sanitized: Dictionary = _sanitize_generator_state(state, current_unlocked, current_available, current_owned)
generator_states[key] = sanitized
generator_state_changed.emit(StringName(key), sanitized.duplicate(true))
@@ -1098,9 +1104,30 @@ func _try_complete_goal(goal_id: StringName) -> void:
if _goal_completed[goal_id]:
return
if goal.is_met():
if _is_goal_manual_unlock(goal_id):
return
_goal_completed[goal_id] = true
goal_completed.emit(goal_id)
func _is_goal_manual_unlock(goal_id: StringName) -> bool:
var goal: GoalData = _goal_definitions.get(goal_id, null)
if goal == null or not goal.has_id():
return false
var scene_root: Node = get_tree().current_scene
if scene_root == null:
return false
var gen_nodes: Array[Node] = scene_root.find_children("*", "CurrencyGenerator", true, false)
for node in gen_nodes:
if node.has_method("get_generator_id") and node.has_method("data"):
var data: Variant = node.get("data")
if data != null and data.has_method("has_unlock_goal") and data.has_method("unlocks_automatically_from_goal"):
if data.has_unlock_goal() and data.get_unlock_goal_id() == goal_id:
return not data.unlocks_automatically_from_goal()
return false
func _serialize_goals() -> Dictionary:
var result: Dictionary = {}
var completed_goals: Array[StringName] = []