Add core simulation modules for owniverse mechanics
- Introduced `life_evolution.gd` to manage life evolution processes. - Implemented `manual_production.gd` for handling production mechanics, including resource management and production steps. - Created `object_batches.gd` to manage batches of objects, including scaling and appending batches. - Developed `object_ledger.gd` for tracking physical amounts, available resources, and binding ownerships. - Added `simulation_module.gd` as a base class for simulation modules, providing a weak reference to the world. - Established `stellar_rules.gd` for managing stellar evolution and destruction mechanics. - Introduced `universe_environment.gd` to calculate environmental parameters based on the current state of the universe.
This commit is contained in:
+20
-15
@@ -24,31 +24,36 @@ func run() -> void:
|
||||
await process_frame
|
||||
stage.owniverse.state.amount.H = 1000.0
|
||||
stage.owniverse.state.amount.RD = 2.0
|
||||
stage.owniverse.refresh_item_amounts()
|
||||
stage._update_ui(0.0)
|
||||
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
||||
stage.set_owniverse_item_value()
|
||||
var hydrogen = stage.owniverse_items.H
|
||||
var dwarf = stage.owniverse_items.RD
|
||||
check(hydrogen.description.text == "1 000", "Visible page updates immediately on navigation")
|
||||
check(dwarf.description.text == "", "Offscreen counters are not rendered")
|
||||
check(hydrogen.description.text == "1 000", "Pending quantities reach controls")
|
||||
check(dwarf.description.text == "2", "Other page receives its current quantity")
|
||||
check(stage.owniverse.presentation.pending_amounts.is_empty(), "Published queue is consumed by Stage")
|
||||
stage.owniverse.presentation.deferred_updates = true
|
||||
stage.owniverse.state.amount.H = 2000.0
|
||||
stage.owniverse.refresh_item_amounts()
|
||||
check(stage.owniverse.item_amounts_dirty and stage.owniverse.items_to_update.H == 1000.0, "Simulation invalidates without recalculating display sums")
|
||||
stage._update_ui(0.05)
|
||||
check(hydrogen.description.text == "1 000", "No refresh before interval")
|
||||
stage._update_ui(0.051)
|
||||
check(hydrogen.description.text == "2 000" and not stage.owniverse.item_amounts_dirty, "Latest state appears at interval")
|
||||
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog)
|
||||
check(stage.owniverse.presentation.dirty and stage.owniverse.presentation.pending_amounts.is_empty(), "Deferred refresh marks dirty without republishing")
|
||||
stage.set_owniverse_item_value()
|
||||
check(hydrogen.description.text == "1 000", "Labels retain last published quantity")
|
||||
stage.owniverse.presentation.refresh(stage.owniverse.state, stage.owniverse.catalog, true)
|
||||
stage.set_owniverse_item_value()
|
||||
check(hydrogen.description.text == "2 000" and not stage.owniverse.presentation.dirty, "Forced refresh publishes latest state")
|
||||
stage.owniverse.presentation.deferred_updates = false
|
||||
stage.item_activated(hydrogen)
|
||||
check(hydrogen.description.text == root.get_node("Global").format_number(stage.owniverse.state.amount.H), "Player production updates counter immediately")
|
||||
stage.set_owniverse_item_value()
|
||||
check(hydrogen.description.text == root.get_node("Global").format_number(stage.owniverse.state.amount.H), "Player production publishes the new quantity")
|
||||
check(stage.owniverse.state.amount.H > 2000.0, "Production action actually executed")
|
||||
dwarf.visible = true
|
||||
stage.stage_page_scroller.scroll_horizontal = 2 * stage.PAGE_WIDTH
|
||||
await process_frame
|
||||
stage._update_ui(0.0)
|
||||
stage._refresh_universe_ui()
|
||||
check(dwarf.description.text == "2", "Newly visible page receives cached latest values")
|
||||
stage.owniverse.state.time.year = 1234.5
|
||||
stage._update_ui(0.1)
|
||||
check(stage.date_time.text == "1 234.5", "Time uses throttled display with tenths")
|
||||
for entity in stage.owniverse.entities.values(): entity.free()
|
||||
stage._refresh_universe_ui()
|
||||
check(stage.date_time.text == "1 234.5", "Time displays tenths with thousands separator")
|
||||
for entity in stage.owniverse.catalog.entities.values(): entity.free()
|
||||
stage.owniverse.free()
|
||||
scene.free()
|
||||
print("UI updates: %d checks, %d failures" % [checks, failures])
|
||||
|
||||
Reference in New Issue
Block a user