Core Module Documentation
Overview
The core/ directory contains the fundamental systems for the idle game. It provides:
- Numeric Foundation:
BigNumberfor handling huge idle game values - Game State Management:
LevelGameStatefor all persistent state - Currency System:
CurrencyCatalogueand tracking for multiple currency types - Generator System: Automated resource production with scaling costs
- Buff System: Upgrades that modify generator behavior
- Goal System: Achievement tracking and unlock triggers
- Prestige System: Rebirth mechanics with permanent multipliers
- Research System: XP-based progression with production multipliers
Architecture
core/
├── big_number.gd # Core numeric API
├── level_game_state.gd # Main state management (Node)
├── currency/ # Currency data structures + CurrencyCatalogue
├── currency_catalogue.gd # Currency catalogue resource
├── buff_catalogue.gd # Buff catalogue resource
├── goal_catalogue.gd # Goal catalogue resource
├── generator/ # Generator logic and data
├── goals/ # Goal/achievement system
├── prestige/ # Prestige/rebirth system
└── research/ # Research XP and progression
Data Flow
- Game Start:
LevelGameState._ready()initializes currencies, loads save - Player Action: Generator bought →
LevelGameStateupdated → signals emitted - UI Reaction: Listeners respond to signals → update display
- Goal Check: Currency changed → goals evaluated → buffs unlocked
- Save:
LevelGameState.save_game()→ JSON touser://level_save.json
Save Format
Version: 5
{
"save_format_version": 5,
"currencies": {
"<currency_id>": {
"current": {"m": float, "e": int},
"total": {"m": float, "e": int},
"all_time": {"m": float, "e": int}
}
},
"generator_states": {
"<generator_id>": {
"owned": int,
"purchased_count": int,
"unlocked": bool,
"available": bool
}
},
"buff_levels": {
"<buff_id>": int
},
"buff_unlocked": {
"<buff_id>": true
},
"buff_active": {
"<buff_id>": true
},
"goals": {
"completed": ["<goal_id>", ...]
},
"research_xp": {
"<research_id>": {"m": float, "e": int}
},
"research_levels": {
"<research_id>": int
},
"last_save_time": unix_timestamp
}
Key Signals
| Signal | Emitted When |
|---|---|
currency_changed(currency_id, new_amount) |
Any currency balance changes |
generator_state_changed(generator_id, state) |
Generator owned/unlocked changes |
generator_buff_level_changed(gen_id, buff_id, level) |
Buff level increased |
buff_unlocked_changed(buff_id, unlocked) |
Buff unlock state changed |
goal_completed(goal_id) |
Goal criteria met |
BigNumber Serialization
All large numbers use scientific notation internally:
# Value = mantissa * 10^exponent
var num = BigNumber.new(1.5, 24) # 1.5e24
var dict = num.serialize() # {"m": 1.5, "e": 24}
var restored = BigNumber.deserialize(dict)
Extending the Core
Adding a New Currency
- Create
res://sandbox/currencies/<name>.tresextendingCurrency - Set
id,display_name, andicon - Add to
CurrencyCatalogueresource assigned toLevelGameState
Adding a New Generator
- Create
res://sandbox/generators/<name>.tresextendingCurrencyGeneratorData - Configure costs, production, and unlock goals
- Instance
CurrencyGeneratorscene with this data
Adding a New Buff
- Create
res://sandbox/buffs/<name>.tresextendingGeneratorBuffData - Set
target_ids,kind,effect_increment, andcost - Add to
BuffCatalogueresource assigned toLevelGameState
Adding New Research
- Create
res://sandbox/research/<name>.tresextendingResearchData - Link to a generator via
generator_id - Add to
ResearchCatalogueresource assigned toLevelGameState
See Also
currency/- Currency data structuresgenerator/- Generator production systemgoals/- Achievement systemprestige/- Rebirth mechanics