extends SceneTree ## Component and read-only rendering checks; never OS or same-demand proof. const Presentation := preload("res://scripts/ui/room_presentation.gd") const Stream := preload("res://tests/fixtures/p23-03/diagnostic_stream.gd") var checks := 0 var failures := 0 func _initialize() -> void: call_deferred("run") func expect(value: bool, message: String) -> void: checks += 1 if not value: failures += 1 push_error("P23 life observation: " + message) func run() -> void: var layout := OS.get_environment("P23_LAYOUT") var output_directory := OS.get_environment("P23_OUTPUT") if layout in ["A", "B"] and not output_directory.is_empty(): var comparison := preload("res://tests/fixtures/p23-03/layout_comparison.gd").new() expect(await comparison.run(self, output_directory, layout), "native layout " + layout) print("P23 life observation: %d checks, %d failures" % [checks, failures]) quit(0 if failures == 0 else 1) return var clock: Variant = root.get_node("GameClock") clock.set_paused(true) # Isolated real typed components test state labels, without claiming gameplay. var labels: Dictionary = {} for state: int in FacilityInstance.State.values(): var room := FacilityInstance.new().configure(&"component", &"reception") room.state = state as FacilityInstance.State var description := Presentation.describe(room) expect(description[&"state_name"] == FacilityInstance.State.keys()[state], "enum name preserved") var text := Presentation.business_label(description) expect(not text.is_empty() and not labels.has(text), "distinct visible business reason") labels[text] = true for reason: StringName in [&"RAIDED", &"DESTROYED"]: var room := FacilityInstance.new().configure(&"component", &"reception", {&"suspension_reason": reason}) var description := Presentation.describe(room) expect(description[&"operation"] == FacilityInstance.OperationState.SUSPENDED, "actual suspension operation") var text := Presentation.business_label(description) expect(not labels.has(text), "raid and damage have separate visible labels") labels[text] = true var room := FacilityInstance.new().configure(&"component", &"reception", {&"customer_capacity": 3}) var service := ServiceInstance.new() service.guest_ids.assign([&"b", &"a"]) room.active_services[&"service"] = service room.queue_entries.assign([&"queue-only"]) var description := Presentation.describe(room) expect(description[&"people"] == [&"a", &"b"] and description[&"count"] == 2, "queue entries are not room occupants") description[&"people"].clear() expect(service.guest_ids.size() == 2, "presentation owns its arrays") var runtime: Variant = root.get_node("SimulationRuntime") var view := WorldPreview.new() view.size = Vector2(1440, 810) view.set_runtime(runtime) root.add_child(view) var before: PackedByteArray = var_to_bytes(runtime.create_snapshot()) var tracks: PackedByteArray = var_to_bytes([view._actor_tracks, view._elevator_tracks]) var model := view._build_life_observation() expect(var_to_bytes(runtime.create_snapshot()) == before, "builder does not mutate Runtime") expect(var_to_bytes([view._actor_tracks, view._elevator_tracks]) == tracks, "builder does not advance visual tracks") expect(model.has(&"rooms") and model.has(&"landing_badges") and model.has(&"elevators") and model.has(&"staff") and model.has(&"goods") and model.has(&"badges"), "all six category fields exist") expect(model[&"traffic"].size() > 0 and not view.show_grid, "normal view observes real walkable traffic") await process_frame await process_frame var report := view.get_life_observation_report() expect(not report.is_empty(), "actual drawing published an observation") # The getter exposes the last actual draw and must not create another model. var original: PackedByteArray = var_to_bytes(report) if report.has(&"traffic"): report[&"traffic"].clear() expect(var_to_bytes(view.get_life_observation_report()) == original, "nested report arrays are isolated") report.clear() expect(var_to_bytes(view.get_life_observation_report()) == original, "public report is a deep copy") var output := OS.get_environment("P23_LIFE_DIAGNOSTIC_ROOT") if not output.is_empty(): var stream := Stream.new() expect(stream.open(output), "fresh sparse diagnostic stream") expect(stream.capture("initial", runtime, view), "whole typed state and draw report capture") stream.close() view.free() print("P23 life observation: %d checks, %d failures" % [checks, failures]) quit(0 if failures == 0 else 1)