feat: add ui labels to display village state
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
extends CanvasLayer
|
||||
|
||||
const DEBUG_LOGS := false
|
||||
|
||||
@export var simulation_manager: Node
|
||||
|
||||
@onready var village_stats_label: Label = $VillagePanel/MarginContainer/VillageStatsLabel
|
||||
|
||||
func _ready() -> void:
|
||||
if simulation_manager == null:
|
||||
push_error("VillageUI: simulation_manager missing")
|
||||
return
|
||||
|
||||
if simulation_manager.has_signal("village_changed"):
|
||||
simulation_manager.village_changed.connect(_on_village_changed)
|
||||
else:
|
||||
push_error("VillageUI: SimulationManager has no village_changed signal")
|
||||
|
||||
if "village" in simulation_manager:
|
||||
_on_village_changed(simulation_manager.village)
|
||||
|
||||
func _on_village_changed(village: SimVillage) -> void:
|
||||
village_stats_label.text = """
|
||||
Village
|
||||
|
||||
Food: %s
|
||||
Wood: %s
|
||||
Safety: %s
|
||||
Knowledge: %s
|
||||
""" % [
|
||||
round(village.food),
|
||||
round(village.wood),
|
||||
round(village.safety),
|
||||
round(village.knowledge)
|
||||
]
|
||||
Reference in New Issue
Block a user