Cleanup goal unlocks behaviour

This commit is contained in:
2026-04-04 16:56:39 +02:00
parent cd23125739
commit 0ab63ebe8c
8 changed files with 70 additions and 97 deletions

View File

@@ -154,18 +154,14 @@ func _refresh_goal_row(row: GoalRow) -> void:
var already_unlocked: bool = _is_goal_completed(goal)
var can_resolve_target: bool = _can_resolve_target(goal.target_generator_id)
var met: bool = _is_goal_met(goal)
var generator: CurrencyGenerator = _get_generator_for_goal(goal)
var is_manual_goal: bool = _is_manual_goal_generator(generator)
var can_unlock: bool = can_resolve_target and met and not already_unlocked and is_manual_goal
var can_click: bool = can_resolve_target and met and not already_unlocked
row.requirements_label.text = _get_requirements_text(goal)
row.button.disabled = not can_unlock
row.button.disabled = not can_click
if already_unlocked:
row.button.text = "Done"
elif is_manual_goal:
row.button.text = "Unlock"
else:
row.button.text = "Auto"
row.button.text = "Unlock"
if already_unlocked:
row.status_label.text = "Unlocked"
@@ -210,9 +206,11 @@ func _on_unlock_pressed(goal_id: StringName) -> void:
var generator: CurrencyGenerator = _get_generator_for_goal(goal)
if generator == null:
return
if not generator.try_unlock_from_goal():
return
GameState.set_generator_unlocked(goal.target_generator_id, true)
GameState.set_generator_available(goal.target_generator_id, true)
if goal.goal.unlock_behavior == GoalData.UnlockBehavior.MANUAL:
GameState._complete_goal_manually(goal.goal.id)
print("[GoalsDebugUI] Unlocked goal '%s' -> %s" % [String(goal.goal.id), String(goal.target_generator_id)])
_refresh_ui()
@@ -287,16 +285,6 @@ func _find_generator_for_goal(goal: GoalData) -> StringName:
return StringName(generator_id)
return &""
func _is_manual_goal_generator(generator: CurrencyGenerator) -> bool:
if generator == null:
return false
if generator.data == null:
return false
if not generator.data.has_unlock_goal():
return false
return not generator.data.unlocks_automatically_from_goal()
func _get_requirements_text(goal: GoalDefinition) -> String:
if goal == null:
return ""