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

@@ -36,7 +36,7 @@ Resource class for generator balancing data.
@export var name: String = "" # Display name
@export var starts_unlocked: bool = true # Visible at game start
@export var purchase_currency: Currency # What to spend
@export var unlock_goal: GoalData # Goal to unlock this
@export var unlock_goal: GoalData # Goal to unlock this (behavior defined in GoalData)
# Cost formula: cost = base * coefficient^owned
@export var initial_cost: float = 10.0 # Base cost
@@ -90,7 +90,7 @@ Runtime node instance attached to generator scenes.
signal purchase_completed(amount, total_owned, total_purchased, total_cost)
signal production_tick(amount, cycle_count, total_owned)
signal buff_purchased(buff_id, new_level, cost, cost_currency_id)
signal goal_achieved(generator_id, goal_id)
signal goal_achieved(generator_id, goal_id) # Emitted when generator unlocks from goal
```
### Key Methods
@@ -102,6 +102,10 @@ func buy_max() -> int
func get_cost_for_amount(amount: int) -> BigNumber
func can_buy(amount: int) -> bool
# Goal-based unlock (automatic when goal completes)
# Generator listens to GameState.goal_completed signal
```
# Production
func grant_currency(amount: BigNumber)
func get_effective_auto_run_multiplier() -> float
@@ -184,6 +188,22 @@ UI component showing generator information.
- `production_tick` - Update production display
- `generator_buff_level_changed` - Refresh buff rows
## Goal-Based Unlock
Generators with `unlock_goal` automatically listen to `GameState.goal_completed` signal:
- When goal completes, generator unlocks automatically
- Goal's `unlock_behavior` (AUTOMATIC/MANUAL) controls when goal completes
- Manual goals require player to click "Unlock" button first
```gdscript
# In CurrencyGenerator._ready():
GameState.goal_completed.connect(_on_goal_completed)
func _on_goal_completed(goal_id: StringName) -> void:
if data.has_unlock_goal() and data.get_unlock_goal_id() == goal_id:
unlock_generator()
```
## Prestige Integration
Generators automatically apply prestige multipliers: