Revamp goals as resources
This commit is contained in:
@@ -56,47 +56,36 @@ not a crash.
|
||||
|
||||
## Data Model
|
||||
|
||||
## New Config File
|
||||
## New Config Resources
|
||||
|
||||
Add a root JSON file:
|
||||
- `res://generator_unlock_goals.json`
|
||||
Goals are now authored as typed resources instead of JSON:
|
||||
1. `res://core/goals/goal_requirement_data.gd` (`GoalRequirementData`)
|
||||
2. `res://core/goals/goal_data.gd` (`GoalData`)
|
||||
3. `res://core/generator-unlock-goals/generator_unlock_goal_data.gd` (`GeneratorUnlockGoalData`)
|
||||
|
||||
Schema (v1):
|
||||
|
||||
```json
|
||||
{
|
||||
"version": 1,
|
||||
"goals": [
|
||||
{
|
||||
"id": "unlock_gems_generator",
|
||||
"target_generator_id": "Gems",
|
||||
"requirements": [
|
||||
{
|
||||
"currency": "gold",
|
||||
"amount": { "m": 1.0, "e": 3 }
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
Example assets:
|
||||
1. `res://idles/goals/magic_total_30.tres` (goal definition)
|
||||
2. `res://idles/goals/generator_unlock_knowledge.tres` (goal target binding)
|
||||
|
||||
Notes:
|
||||
1. `amount` uses existing `BigNumber` serialization (`m`, `e`) to avoid float precision/overflow issues.
|
||||
2. `id` must be unique and stable.
|
||||
3. `requirements` must contain at least one entry.
|
||||
1. `GoalData.id` must be unique and stable.
|
||||
2. `GoalData.requirements` must contain at least one valid `GoalRequirementData`.
|
||||
3. `GoalRequirementData` stores amount as mantissa/exponent to preserve `BigNumber` semantics.
|
||||
|
||||
## Runtime Structures (GDScript)
|
||||
|
||||
Recommended internal structs/classes:
|
||||
Runtime data comes from resource classes:
|
||||
|
||||
1. `UnlockGoalRequirement`
|
||||
- `currency: GameState.CurrencyType`
|
||||
- `amount: BigNumber`
|
||||
2. `UnlockGoal`
|
||||
1. `GoalRequirementData`
|
||||
- `currency: Resource`
|
||||
- `amount_mantissa: float`
|
||||
- `amount_exponent: int`
|
||||
2. `GoalData`
|
||||
- `id: StringName`
|
||||
- `requirements: Array[Resource]` (validated as `GoalRequirementData`)
|
||||
3. `GeneratorUnlockGoalData`
|
||||
- `target_generator_id: StringName`
|
||||
- `requirements: Array[UnlockGoalRequirement]`
|
||||
- `goal: Resource` (validated as `GoalData`)
|
||||
|
||||
No persistent `completed_goals` storage is required for v1 because completion is derived from generator unlock state.
|
||||
|
||||
@@ -106,7 +95,7 @@ No persistent `completed_goals` storage is required for v1 because completion is
|
||||
|
||||
Add a scene-level controller script (recommended name: `generator_unlock_system.gd`) responsible for:
|
||||
|
||||
1. Loading + validating `generator_unlock_goals.json`.
|
||||
1. Loading + validating exported `GeneratorUnlockGoalData` resources.
|
||||
2. Subscribing to currency change signals.
|
||||
3. Evaluating pending goals.
|
||||
4. Triggering generator unlock transitions.
|
||||
@@ -173,7 +162,7 @@ func _evaluate_goal(goal: UnlockGoal) -> bool:
|
||||
|
||||
## Implementation Plan
|
||||
|
||||
1. Add `generator_unlock_goals.json` with initial goals.
|
||||
1. Add `GoalData` and `GeneratorUnlockGoalData` resources with initial goals.
|
||||
2. Implement `generator_unlock_system.gd` loader/validator/evaluator.
|
||||
3. Attach unlock system to gameplay scene (`generator_museum.tscn` or current active scene).
|
||||
4. Configure at least one generator as initially locked (`starts_unlocked = false`, `starts_available = false`) in its `.tres` data.
|
||||
|
||||
Reference in New Issue
Block a user