Fix devil idol ui

This commit is contained in:
2026-05-17 16:51:07 +02:00
parent 41466af1ca
commit 4fd23d9416
14 changed files with 89 additions and 31 deletions

View File

@@ -45,6 +45,8 @@ func _ready() -> void:
# Connect to goal completion for unlocking
game_state.goal_completed.connect(_on_goal_completed)
# Refresh button state when unit balance changes
game_state.currency_changed.connect(_on_currency_changed)
# If goal was already completed in a previous session, unlock immediately
if game_state.is_goal_completed(UNLOCK_GOAL_ID):
@@ -67,6 +69,10 @@ func _on_goal_completed(goal_id: StringName) -> void:
_unlock_idol()
func _on_currency_changed(currency_id: StringName, _new_amount: BigNumber) -> void:
if currency_id == &"unit":
_update_ui()
func _unlock_idol() -> void:
_is_targetable = true
@@ -103,9 +109,10 @@ func _update_ui() -> void:
return
var progress_pct: float = 0.0
if _max_hp.mantissa > 0.0:
progress_pct = (1.0 - (_current_hp.mantissa / _max_hp.mantissa)) * pow(10.0, float(_current_hp.exponent - _max_hp.exponent))
progress_pct = clampf(progress_pct * 100.0, 0.0, 100.0)
var max_float: float = _max_hp.to_float()
if max_float > 0.0:
var current_float: float = _current_hp.to_float()
progress_pct = clampf((1.0 - current_float / max_float) * 100.0, 0.0, 100.0)
_hp_value.text = "%s / %s (%.1f%%)" % [_current_hp.to_string_suffix(2), _max_hp.to_string_suffix(2), progress_pct]