From 3f7acf857c2b52f4ae04a8c33c39cc3b26ae2008 Mon Sep 17 00:00:00 2001 From: coder-bot Date: Thu, 20 Aug 2026 22:41:53 +0000 Subject: [PATCH] WIP checkpoint: PC2: Build a basic playable test level scene --- scripts/smoke_test_test_level.gd | 42 ++++++++++++-------------------- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/scripts/smoke_test_test_level.gd b/scripts/smoke_test_test_level.gd index 2a87eb9..7e92d71 100644 --- a/scripts/smoke_test_test_level.gd +++ b/scripts/smoke_test_test_level.gd @@ -27,25 +27,29 @@ func _run() -> void: print("SMOKE: test_level.tscn loaded successfully") - # Instantiate the scene root - var level_instance: Node3D = level_resource.instantiate() as Node3D - if level_instance == null: - printerr("SMOKE RESULT: FAIL — could not instantiate ", level_path) + # Change the running scene to our test level + var err: int = change_scene_to_packed(level_resource) + if err != OK: + printerr("SMOKE RESULT: FAIL — change_scene_to_packed returned ", err) quit(1) return - # Create a temporary root node and add it to the tree so find_child works - var root_holder := Node3D.new() - add_child(root_holder) - root_holder.add_child(level_instance) + # Wait for the scene_changed signal so current_scene is set + await scene_changed + + var level_instance: Node3D = current_scene as Node3D + if level_instance == null: + printerr("SMOKE RESULT: FAIL — current_scene is not Node3D") + quit(1) + return + + # Give the tree one frame to fully initialize await process_frame # (b) Find the PlayerSpawn marker var spawn_marker: Node3D = level_instance.find_child("PlayerSpawn", true, false) as Node3D if spawn_marker == null: - printerr("SMOKE RESULT: FAIL — no Marker3D named 'PlayerSpawn' found in test level") - level_instance.queue_free() - root_holder.queue_free() + printerr("SMOKE RESULT: FAIL — no Node3D named 'PlayerSpawn' found in test level") quit(1) return @@ -58,8 +62,6 @@ func _run() -> void: if spawn_y < 1.0: printerr("SMOKE RESULT: FAIL — PlayerSpawn y = ", spawn_y, " is below the required minimum of 1.0 m above ground top (y=0)") - level_instance.queue_free() - root_holder.queue_free() quit(1) return @@ -69,8 +71,6 @@ func _run() -> void: var ground: StaticBody3D = level_instance.find_child("Ground", true, false) as StaticBody3D if ground == null: printerr("SMOKE RESULT: FAIL — no StaticBody3D named 'Ground' found") - level_instance.queue_free() - root_holder.queue_free() quit(1) return @@ -83,8 +83,6 @@ func _run() -> void: var ground_top: float = ground.global_position.y + box_shape.size.y / 2.0 if abs(ground_top - 0.0) > 0.01: printerr("SMOKE RESULT: FAIL — Ground top face at y = ", ground_top, " expected ~0.0") - level_instance.queue_free() - root_holder.queue_free() quit(1) return print("SMOKE: Ground top face at y = ", ground_top, " — PASS") @@ -98,15 +96,11 @@ func _run() -> void: prop_count += 1 if prop_count < 3: printerr("SMOKE RESULT: FAIL — only ", prop_count, " props found, need >= 3") - level_instance.queue_free() - root_holder.queue_free() quit(1) return print("SMOKE: found ", prop_count, " props — PASS") else: printerr("SMOKE RESULT: FAIL — no 'Props' Node3D found") - level_instance.queue_free() - root_holder.queue_free() quit(1) return @@ -114,8 +108,6 @@ func _run() -> void: var sun: DirectionalLight3D = level_instance.find_child("Sun", true, false) as DirectionalLight3D if sun == null: printerr("SMOKE RESULT: FAIL — no DirectionalLight3D named 'Sun' found") - level_instance.queue_free() - root_holder.queue_free() quit(1) return print("SMOKE: found Sun DirectionalLight3D") @@ -123,14 +115,10 @@ func _run() -> void: var env: WorldEnvironment = level_instance.find_child("Environment", true, false) as WorldEnvironment if env == null: printerr("SMOKE RESULT: FAIL — no WorldEnvironment named 'Environment' found") - level_instance.queue_free() - root_holder.queue_free() quit(1) return print("SMOKE: found WorldEnvironment") # All checks passed print("SMOKE RESULT: PASS") - level_instance.queue_free() - root_holder.queue_free() quit(0)