feat: make pantry crises visible in the world

This commit is contained in:
Rijad Zuzo
2026-07-14 23:54:22 +02:00
parent c722e32a88
commit c23f6887c8
21 changed files with 800 additions and 73 deletions
+92 -26
View File
@@ -3,6 +3,8 @@ extends SceneTree
const SCENE_PATH := "res://main.tscn"
const DEBUG_OUTPUT_PATH := "res://docs/baselines/simulation_garden_01_debug.png"
const CINEMATIC_OUTPUT_PATH := "res://docs/baselines/simulation_garden_01_cinematic.png"
const EMPTY_PANTRY_OUTPUT_PATH := "res://docs/baselines/simulation_garden_02_empty_pantry.png"
const RESTOCKED_PANTRY_OUTPUT_PATH := "res://docs/baselines/simulation_garden_02_restocked_pantry.png"
const CAPTURE_SIZE := Vector2i(1280, 720)
const WARMUP_FRAMES := 540
@@ -45,7 +47,7 @@ func _run() -> void:
quit(1)
return
await _stage_wind_gust(main_scene)
await _settle_trust_reaction()
await _settle_trust_reaction(main_scene)
var debug_analysis := _capture(DEBUG_OUTPUT_PATH)
if debug_analysis.is_empty():
quit(1)
@@ -53,21 +55,38 @@ func _run() -> void:
if demo_controller.has_method("toggle_debug_overlay") and demo_controller.debug_overlay_visible:
demo_controller.toggle_debug_overlay()
if not _restart_trust_reaction(main_scene):
quit(1)
return
await _stage_wind_gust(main_scene)
await _settle_trust_reaction()
var cinematic_analysis := _capture(CINEMATIC_OUTPUT_PATH)
if cinematic_analysis.is_empty():
quit(1)
return
_apply_pantry_capture_camera(main_scene)
await process_frame
await process_frame
var empty_pantry_analysis := _capture(EMPTY_PANTRY_OUTPUT_PATH)
if empty_pantry_analysis.is_empty() or not _stage_pantry_restock(main_scene):
quit(1)
return
for _frame in 12:
await process_frame
var restocked_pantry_analysis := _capture(RESTOCKED_PANTRY_OUTPUT_PATH)
if restocked_pantry_analysis.is_empty():
quit(1)
return
print(
(
"[TOOL] Saved Simulation Garden captures | debug %s | cinematic %s"
% [debug_analysis, cinematic_analysis]
(
"[TOOL] Saved Simulation Garden captures | debug %s | cinematic %s | "
+ "empty pantry %s | restocked pantry %s"
)
% [
debug_analysis,
cinematic_analysis,
empty_pantry_analysis,
restocked_pantry_analysis,
]
)
)
quit(0)
@@ -145,6 +164,20 @@ func _stage_social_history(main_scene: Node) -> bool:
func _stage_pantry_need(main_scene: Node, actor: SimNPC, interested: SimNPC) -> bool:
var simulation_manager := main_scene.get_node("SimulationManager")
var world_view := main_scene.get_node("WorldViewManager")
var pantry_site := (
main_scene.get_node("JajceWorld/WorldObjects/StorageSites/VillagePantry") as StorageNode
)
var actor_visual := world_view.active_npc_visuals.get(actor.id) as Node3D
var interested_visual := world_view.active_npc_visuals.get(interested.id) as Node3D
if actor_visual == null or interested_visual == null:
push_error("Simulation Garden pantry staging needs both active NPC visuals")
return false
var pantry_arrival := pantry_site.get_interaction_position()
actor_visual.global_position = pantry_arrival + Vector3(-0.65, 0.0, 0.15)
interested_visual.global_position = pantry_arrival + Vector3(0.65, 0.0, 0.15)
simulation_manager.synchronize_npc_position(actor.id, actor_visual.global_position)
simulation_manager.synchronize_npc_position(interested.id, interested_visual.global_position)
for npc in simulation_manager.npcs:
npc.hunger = minf(npc.hunger, 70.0)
actor.hunger = 60.0
@@ -189,21 +222,6 @@ func _stage_pantry_need(main_scene: Node, actor: SimNPC, interested: SimNPC) ->
return true
func _restart_trust_reaction(main_scene: Node) -> bool:
var simulation_manager := main_scene.get_node("SimulationManager")
var world_view := main_scene.get_node("WorldViewManager")
if simulation_manager.npcs.size() < 2:
push_error("Simulation Garden trust-reaction staging needs two NPCs")
return false
var observer: SimNPC = simulation_manager.npcs[1]
var observer_visual: Node3D = world_view.active_npc_visuals.get(observer.id)
if observer_visual == null or not observer_visual.has_method("play_trust_gain_reaction"):
push_error("Simulation Garden trust-reaction staging needs an active observer visual")
return false
observer_visual.play_trust_gain_reaction()
return observer_visual.get_node("TrustReactionRoot").visible
func _stage_wind_gust(main_scene: Node) -> void:
var gust_field := (
main_scene.get_node_or_null("JajceWorld/AtmosphereRoot/WindGustField") as WindGustField
@@ -215,9 +233,45 @@ func _stage_wind_gust(main_scene: Node) -> void:
await process_frame
func _settle_trust_reaction() -> void:
for _frame in 12:
await process_frame
func _stage_pantry_restock(main_scene: Node) -> bool:
var simulation_manager := main_scene.get_node("SimulationManager")
var opportunity: OpportunityStateRecord = simulation_manager.get_active_opportunity()
if opportunity == null:
push_error("Simulation Garden restock staging needs an active pantry opportunity")
return false
var contributor: SimNPC = simulation_manager.npcs[0]
var deposited: float = simulation_manager.economy.deposit_inventory(
contributor, SimulationIds.RESOURCE_FOOD
)
var pantry_visual := (
main_scene.get_node("JajceWorld/WorldObjects/StorageSites/VillagePantry/PantryPresentation")
as PantryStockVisual
)
var world_view := main_scene.get_node("WorldViewManager")
var interested_visual: Node3D = world_view.active_npc_visuals.get(
opportunity.get_interested_npc_id()
)
if (
deposited <= 0.0
or simulation_manager.get_active_opportunity() != null
or pantry_visual.get_stock_level() != PantryStockVisual.StockLevel.LOW
or not pantry_visual.get_node("RefillResponse").visible
or interested_visual.get_node("OpportunityConcernRoot").visible
):
push_error("Simulation Garden restock staging did not produce the real visual payoff")
return false
return true
func _settle_trust_reaction(main_scene: Node) -> void:
var simulation_manager := main_scene.get_node("SimulationManager")
var world_view := main_scene.get_node("WorldViewManager")
var observer: SimNPC = simulation_manager.npcs[1]
var observer_visual: Node3D = world_view.active_npc_visuals.get(observer.id)
var reaction_tween: Tween = observer_visual.get("trust_reaction_tween")
if reaction_tween != null and reaction_tween.is_running():
await reaction_tween.finished
await process_frame
func _capture(output_path: String) -> Dictionary:
@@ -268,8 +322,20 @@ func _apply_capture_camera(main_scene: Node) -> void:
var camera_rig := main_scene.get_node("CameraRig")
if camera_rig.has_method("apply_presentation_preset"):
camera_rig.pitch_degrees = -42.0
camera_rig.apply_presentation_preset(Vector3(-2.0, 1.2, -0.5), 128.0, 0.95)
camera_rig.apply_presentation_preset(Vector3(-1.5, 1.2, -4.0), 128.0, 0.7)
camera_rig.set_physics_process(false)
var camera := main_scene.get_node("CameraRig/Camera3D") as Camera3D
camera.fov = 62.0
func _apply_pantry_capture_camera(main_scene: Node) -> void:
var pantry := (
main_scene.get_node("JajceWorld/WorldObjects/StorageSites/VillagePantry") as StorageNode
)
var camera_rig := main_scene.get_node("CameraRig")
var pantry_focus := pantry.global_position + Vector3(0.0, 0.85, 0.72)
camera_rig.apply_presentation_preset(pantry_focus, 128.0, 0.0)
camera_rig.look_at(pantry_focus, Vector3.UP)
var camera := main_scene.get_node("CameraRig/Camera3D") as Camera3D
camera.fov = 44.0