Files
idle/core/research/research_row.gd
Michele Rossi 81a4058b04 systems rework: buffs, prestige graph, research, modular architecture
Decouples core systems from centralized globals in favor of catalogue-based architecture and data-driven content.

   Key changes:
   - Prestige: node-based buff tech tree, graph panel, progress bar
   - Research: multi-worker system, per-generator research, xp generation
   - Ascension: meta-currency layer via multi-currency prestige resets
   - Buffs: refactored as generator-independent via catalogues
   - UI: currency panel, edge-scrolling camera + zoom, current-goal panel
   - Alchemy Tower: crafting building with recipe/cost system
   - Testing: 7 test suites (ascension, prestige, research, goals)
   - Content: migrated from hardcoded idles/ to gym format (tiny_sword)
2026-05-07 20:36:21 +00:00

99 lines
3.3 KiB
GDScript

class_name ResearchRow
extends HBoxContainer
signal active_changed(is_active: bool)
@onready var _name_label: Label = $VBoxContainer/NameLabel
@onready var _level_label: Label = $VBoxContainer/HBoxContainer/LevelLabel
@onready var _progress_bar: ProgressBar = $VBoxContainer/HBoxContainer/ProgressBar
@onready var _multiplier_label: Label = $VBoxContainer/HBoxContainer/MultiplierLabel
@onready var _buff_label: Label = $VBoxContainer/HBoxContainer/BuffLabel
@onready var _check_button: CheckButton = $CheckButton
var _research: ResearchData
var _game_state: LevelGameState
var _is_active: bool = false
func _ready() -> void:
_game_state = find_parent("LevelGameState")
if _game_state == null:
push_error("ResearchRow: Could not find LevelGameState parent")
return
_game_state.research_xp_changed.connect(_on_research_xp_changed)
_game_state.research_level_up.connect(_on_research_level_up)
_check_button.toggled.connect(_on_check_button_toggled)
func setup(research: ResearchData) -> void:
_research = research
if _name_label:
_name_label.text = research.name
func get_research_id() -> StringName:
if _research == null:
return &""
return _research.id
func update_display(level: int, progress: float, multiplier: float, xp_current: BigNumber, xp_needed: BigNumber) -> void:
if _level_label:
_level_label.text = "Level %d" % level
if _progress_bar:
_progress_bar.value = progress * 100
if _multiplier_label:
_multiplier_label.text = "+%d%%" % int((multiplier - 1.0) * 100)
if _buff_label and _research != null:
if not _research.associated_buff_id.is_empty():
var buff: GeneratorBuffData = _game_state.get_buff(_research.associated_buff_id)
if buff != null and _game_state.is_buff_active(buff.id):
var buff_level: int = _game_state.get_buff_level(buff.id)
var effect: float = buff.get_effect_multiplier(buff_level) - 1.0
_buff_label.text = "%s: +%d%% XP" % [buff.text, int(effect * 100)]
else:
_buff_label.text = ""
else:
_buff_label.text = ""
func _on_research_xp_changed(research_id: StringName, _new_xp: BigNumber) -> void:
if _research != null and research_id == _research.id:
_update_from_state()
func _on_research_level_up(research_id: StringName, _old_level: int, _new_level: int) -> void:
if _research != null and research_id == _research.id:
_update_from_state()
func _update_from_state() -> void:
if _research == null or _game_state == null:
return
var xp: BigNumber = _game_state.get_research_xp(_research.id)
var level: int = _game_state.get_research_level(_research.id)
var progress: float = _research.get_xp_progress(xp)
var multiplier: float = _research.get_multiplier_for_level(level)
var xp_current: BigNumber = xp.subtract(_research.get_total_xp_for_level(level))
var xp_needed: BigNumber = _research.get_xp_required_for_level_big(level + 1)
update_display(level, progress, multiplier, xp_current, xp_needed)
func _on_check_button_toggled(toggled_on: bool) -> void:
if toggled_on != _is_active:
_is_active = toggled_on
active_changed.emit(_is_active)
func set_active(is_active: bool, emit_signal: bool = true) -> void:
_is_active = is_active
_check_button.button_pressed = is_active
if emit_signal:
active_changed.emit(is_active)
func is_research_active() -> bool:
return _is_active
func get_research_id_public() -> StringName:
if _research == null:
return &""
return _research.id