Use worker for research
This commit is contained in:
27
core/research/worker_summary_label.gd
Normal file
27
core/research/worker_summary_label.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
class_name WorkerSummaryLabel
|
||||
extends Label
|
||||
|
||||
@onready var _game_state: LevelGameState = find_parent("LevelGameState")
|
||||
|
||||
signal research_workers_changed(new_count: int)
|
||||
|
||||
func _ready() -> void:
|
||||
if _game_state == null:
|
||||
push_error("WorkerSummaryLabel: Could not find LevelGameState parent")
|
||||
return
|
||||
|
||||
_game_state.currency_changed.connect(_on_currency_changed)
|
||||
_game_state.research_workers_changed.connect(_on_research_workers_changed)
|
||||
_update_worker_display()
|
||||
|
||||
func _on_currency_changed(currency_id: StringName, _new_amount: BigNumber) -> void:
|
||||
if currency_id == "worker":
|
||||
_update_worker_display()
|
||||
|
||||
func _on_research_workers_changed(new_count: int) -> void:
|
||||
_update_worker_display()
|
||||
|
||||
func _update_worker_display() -> void:
|
||||
var worker_currency: int = int(_game_state.get_currency_amount_by_id("worker").mantissa)
|
||||
var research_workers: int = _game_state.get_research_workers()
|
||||
text = "Workers: %d available, %d assigned" % [worker_currency, research_workers]
|
||||
Reference in New Issue
Block a user