Add currency database, cleanup legacy system

This commit is contained in:
2026-03-14 17:20:22 +01:00
parent 6da962a53d
commit 7b58c36414
20 changed files with 353 additions and 222 deletions

View File

@@ -1,5 +1,5 @@
class_name CurrencyGenerator
extends Node
extends Node2D
## Handles generator economy behavior:
## - automatic production cycles
@@ -18,7 +18,7 @@ signal production_tick(amount: BigNumber, cycle_count: int, total_owned: int)
const HUGE_COST_EXPONENT: int = 1000000
## Currency target updated by this generator.
@export var currency: Resource = GameState.GOLD_CURRENCY
@export var currency: Resource
## Data resource containing balancing values and defaults (required).
@export var data: CurrencyGeneratorData
## Enables per-cycle automatic production when true.
@@ -30,6 +30,8 @@ const HUGE_COST_EXPONENT: int = 1000000
## Extra multiplier applied to automatic production output.
@export var run_multiplier: float = 1.0
## True while the pointer is inside the generator Area2D.
var _mouse_entered: bool = false
## Time left until next click/hover grant is allowed.
@@ -82,14 +84,14 @@ var _is_registered: bool = false
## Resolves and registers this generator state before gameplay updates.
func _ready() -> void:
assert(currency != null, "Currency cannot be null")
assert(data != null, "Data cannot be null")
_generator_id = _resolve_generator_id()
_ensure_registered()
cycle_progress_seconds = 0.0
if currency == null:
push_warning("CurrencyGenerator '%s' has no currency set; defaulting to Gold." % String(name))
currency = GameState.GOLD_CURRENCY
if data == null:
push_error("CurrencyGenerator '%s' is missing CurrencyGeneratorData." % String(name))
GameState.generator_state_changed.connect(_on_generated_state_changed)
## Updates click cooldown/click grants and runs automatic production cycles.
func _process(delta: float) -> void:
@@ -342,3 +344,10 @@ func _on_area_2d_mouse_entered() -> void:
## Area2D callback: pointer exited generator interaction region.
func _on_area_2d_mouse_exited() -> void:
_mouse_entered = false
func _on_generated_state_changed(generator_id: StringName, state: Dictionary) -> void:
if generator_id == _generator_id:
print(_generator_id)
print(state)
visible = true