Enhance simulation performance and accuracy by optimizing physical amount calculations and refining arithmetic operations

This commit is contained in:
Kirill
2026-10-01 20:30:53 +03:00
parent befb377774
commit f51eea6c0f
14 changed files with 155 additions and 55 deletions
+13 -2
View File
@@ -91,6 +91,8 @@ var g_counters: Dictionary[String, Counter] = {
var g_active_items: Dictionary = {}
var pending_page: int = -1
var active_actions_dirty: bool = true
var active_actions_elapsed: float = 0.0
var owniverse:Owniverse = Owniverse.new()
var owniverse_items: Dictionary[String, OwniverseItem] = {}
@@ -174,6 +176,7 @@ func _control_page(item: OwniverseItem) -> void:
return
g_active_items[item.item_page] = item
active_actions_dirty = true
if current_item != null and current_item.item_page == item.item_page:
current_item.set_selection(false)
@@ -338,6 +341,8 @@ func create_new_universe() -> void:
description_samples.clear()
description_rates.clear()
description_elapsed = 0.0
active_actions_dirty = true
active_actions_elapsed = 0.0
for label in g_item_descriptions:
label.text = ""
for item in owniverse_items.values():
@@ -379,8 +384,14 @@ func _process(delta: float) -> void:
var actions = _check_counters(delta)
_do_actions(actions)
_set_active_page_actions()
# Production limits are expensive (they walk the resource ledger). Refresh
# them when selection changes and at a modest cadence instead of every
# rendered frame. The simulation itself continues to run every frame.
active_actions_elapsed += delta
if active_actions_dirty or active_actions_elapsed >= 0.1:
active_actions_elapsed = 0.0
active_actions_dirty = false
_set_active_page_actions()
func _change_speed(delta: int) -> void: