Fix research xp generation
This commit is contained in:
@@ -1,14 +1,18 @@
|
||||
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")
|
||||
@@ -18,6 +22,7 @@ func _ready() -> void:
|
||||
|
||||
_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
|
||||
@@ -72,3 +77,22 @@ func _update_from_state() -> void:
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user