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

@@ -100,11 +100,9 @@ func _ready() -> void:
GameState.currency_changed.connect(_on_currency_changed)
GameState.generator_state_changed.connect(_on_generated_state_changed)
GameState.goal_completed.connect(_on_goal_completed)
# Register with default state first, then evaluate unlock goal
_ensure_registered()
if data != null and data.unlocks_automatically_from_goal():
_evaluate_generator_unlock_goal(false)
## Updates click cooldown/click grants and runs automatic production cycles.
func _process(delta: float) -> void:
@@ -322,9 +320,6 @@ func reset_runtime_state_for_prestige() -> void:
cycle_progress_seconds = 0.0
_remaining_click_cooldown_seconds = 0.0
_ensure_registered()
if data != null and data.unlocks_automatically_from_goal():
_evaluate_generator_unlock_goal(false)
#_evaluate_buff_unlock_goals()
visible = is_available_to_player()
func get_manual_click_multiplier() -> float:
@@ -583,35 +578,19 @@ func _try_unlock_buff_from_goal(buff: GeneratorBuffData) -> void:
func _on_currency_changed(_changed_currency_id: StringName, _new_amount: BigNumber) -> void:
GameState.evaluate_all_goals()
if data != null and data.unlocks_automatically_from_goal():
_evaluate_generator_unlock_goal(false)
func try_unlock_from_goal() -> bool:
return _evaluate_generator_unlock_goal(true)
func _evaluate_generator_unlock_goal(allow_manual_unlock: bool) -> bool:
if data == null:
return false
func _on_goal_completed(goal_id: StringName) -> void:
if data == null or not data.has_unlock_goal():
return
if data.get_unlock_goal_id() != goal_id:
return
if is_available_to_player():
return false
if not data.has_unlock_goal():
return false
if not data.unlocks_automatically_from_goal() and not allow_manual_unlock:
return false
var goal_id: StringName = data.get_unlock_goal_id()
if goal_id.is_empty():
return false
var goal_completed: bool = GameState.is_goal_completed(goal_id)
if not goal_completed:
return false
return
GameState.set_generator_unlocked(_generator_id, true)
GameState.set_generator_available(_generator_id, true)
goal_achieved.emit(_generator_id, goal_id)
_on_generated_state_changed(_generator_id, GameState._get_generator_state(_generator_id))
return true
## Default unlocked state loaded from generator data.
func _default_unlocked_state() -> bool: