2.6 KiB
2.6 KiB
Generator-Embedded Unlock Goals - Technical Specification
Document Status
- Version: 2.0
- Date: 2026-03-21
- Scope: Unlock generators from
CurrencyGeneratorData.unlock_goalwhen goal thresholds are reached.
Problem Statement
Generator unlock progression should be authored where generator behavior lives: CurrencyGeneratorData.
The previous scene-level target mapping layer increased setup complexity and created mismatch risk between goal targets and scene content.
Current Baseline
- Generator state persists in
GameState.generator_states(owned,purchased_count,unlocked,available). CurrencyGeneratoralready gates interactions usingis_available_to_player().- Goal primitives remain reusable and data-driven:
GoalRequirementDataGoalData
- Generator data now owns unlock definition via
unlock_goal: GoalData.
Functional Requirements
- A generator may define one optional unlock goal (
CurrencyGeneratorData.unlock_goal). - Goal completion uses logical AND across requirements.
- Requirement checks use total acquired currency (
GameState.get_total_currency_acquired_by_id). - Unlock evaluation runs:
- once on generator
_ready() - on every
GameState.currency_changed
- once on generator
- When a goal is met, runtime sets:
GameState.set_generator_unlocked(generator_id, true)GameState.set_generator_available(generator_id, true)
- Unlock transitions are idempotent.
- Unlock completion emits
CurrencyGenerator.goal_achieved(generator_id, goal_id)for hooks/UI.
Runtime Design
CurrencyGeneratorDataexposes:has_unlock_goal()is_unlock_goal_met()get_unlock_goal_id()
CurrencyGeneratorexecutes_evaluate_generator_unlock_goal().- No scene-level unlock controller is required.
- Goals debug UI discovers goals from scene generators instead of external target-mapping resources.
Data Authoring Rules
- Configure locked generators with
starts_unlocked = falseandstarts_available = false. - Set
unlock_goaldirectly on that generator.tresresource. - Keep
GoalData.idunique and stable. - Goal data can still be shared across systems (generator unlocks, buff unlocks).
Save/Load Behavior
- Unlock persistence remains unchanged because
GameStatestoresunlocked/available. - Re-evaluation after load is safe due to idempotent state writes.
Validation
- Run headless parse:
"$GODOT_BIN" --headless --path . --quit - Manual smoke test in
generator_museum:- verify locked generator starts unavailable
- grant required currency
- verify generator unlocks automatically
- verify state persists after restart