feat: simulation speed control with bracket keys
Press [ to slow down, ] to speed up through 6 levels: 0.25x, 0.5x, 1x, 2x, 4x, 10x. Clock delta is multiplied by the current speed, so time_of_day advances proportionally and the visual day-night cycle stays synced. Current speed shown in the village panel header. 10x makes a full day cycle watchable in ~24 seconds. Speed changes are non-destructive to simulation determinism.
This commit is contained in:
+12
-1
@@ -27,6 +27,8 @@ func _ready() -> void:
|
||||
push_error("VillageUI: SimulationManager has no npc_decision_recorded signal")
|
||||
if simulation_manager.has_signal("state_restored"):
|
||||
simulation_manager.state_restored.connect(_on_state_restored)
|
||||
if simulation_manager.has_signal("speed_changed"):
|
||||
simulation_manager.speed_changed.connect(_on_speed_changed)
|
||||
|
||||
if "village" in simulation_manager:
|
||||
_on_village_changed(simulation_manager.village)
|
||||
@@ -63,9 +65,12 @@ func _on_village_changed(village: SimVillage) -> void:
|
||||
event_text = ""
|
||||
else:
|
||||
event_text = "\n" + event_text
|
||||
var speed_text := ""
|
||||
if simulation_manager.has_method("get_current_speed"):
|
||||
speed_text = simulation_manager.get_current_speed()
|
||||
village_stats_label.text = (
|
||||
"""
|
||||
Village
|
||||
Village [%s]
|
||||
|
||||
Food: %s
|
||||
Wood: %s
|
||||
@@ -79,6 +84,7 @@ func _on_village_changed(village: SimVillage) -> void:
|
||||
%s
|
||||
"""
|
||||
% [
|
||||
speed_text,
|
||||
round(village.food),
|
||||
round(village.wood),
|
||||
round(village.safety),
|
||||
@@ -101,6 +107,11 @@ func _on_state_restored() -> void:
|
||||
_refresh_npc_inspector()
|
||||
|
||||
|
||||
func _on_speed_changed(_multiplier: float) -> void:
|
||||
if simulation_manager != null and "village" in simulation_manager:
|
||||
_on_village_changed(simulation_manager.village)
|
||||
|
||||
|
||||
func _refresh_npc_inspector() -> void:
|
||||
if not debug_overlay_visible:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user