Decouple everything from globals
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
extends HBoxContainer
|
||||
|
||||
@export var currency: Resource
|
||||
@export var game_state: LevelGameState
|
||||
|
||||
@onready var _label_start = $LabelStart
|
||||
@onready var _label_end = $LabelEnd
|
||||
@@ -22,15 +23,16 @@ func set_limits(start: BigNumber, end: BigNumber) -> void:
|
||||
_progress_bar.max_value = _end.get_ratio(_start)
|
||||
|
||||
func _ready() -> void:
|
||||
if currency == null:
|
||||
currency = CurrencyDatabase.get_currency_resource(GameState.GOLD_CURRENCY_ID)
|
||||
if currency == null:
|
||||
push_warning("BigNumberProgressBar '%s' has no currency configured." % String(name))
|
||||
return
|
||||
_currency_id = GameState.get_currency_id(currency)
|
||||
if game_state == null:
|
||||
push_warning("BigNumberProgressBar '%s' has no game_state configured." % String(name))
|
||||
return
|
||||
_currency_id = game_state.get_currency_id(currency)
|
||||
|
||||
GameState.currency_changed.connect(_on_currency_changed)
|
||||
_current = GameState.get_currency_amount_by_id(_currency_id)
|
||||
game_state.currency_changed.connect(_on_currency_changed)
|
||||
_current = game_state.get_currency_amount_by_id(_currency_id)
|
||||
|
||||
set_limits(_current, _current.add(BigNumber.new(1, 1)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user