PC2: Build a basic playable test level scene #48

Merged
reviewer-bot merged 5 commits from agent/0c49a36fc7db into main 2026-08-21 00:00:12 +00:00
Showing only changes of commit 3f7acf857c - Show all commits
+15 -27
View File
@@ -27,25 +27,29 @@ func _run() -> void:
print("SMOKE: test_level.tscn loaded successfully") print("SMOKE: test_level.tscn loaded successfully")
# Instantiate the scene root # Change the running scene to our test level
var level_instance: Node3D = level_resource.instantiate() as Node3D var err: int = change_scene_to_packed(level_resource)
if level_instance == null: if err != OK:
printerr("SMOKE RESULT: FAIL — could not instantiate ", level_path) printerr("SMOKE RESULT: FAIL — change_scene_to_packed returned ", err)
quit(1) quit(1)
return return
# Create a temporary root node and add it to the tree so find_child works # Wait for the scene_changed signal so current_scene is set
var root_holder := Node3D.new() await scene_changed
add_child(root_holder)
root_holder.add_child(level_instance) 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 await process_frame
# (b) Find the PlayerSpawn marker # (b) Find the PlayerSpawn marker
var spawn_marker: Node3D = level_instance.find_child("PlayerSpawn", true, false) as Node3D var spawn_marker: Node3D = level_instance.find_child("PlayerSpawn", true, false) as Node3D
if spawn_marker == null: if spawn_marker == null:
printerr("SMOKE RESULT: FAIL — no Marker3D named 'PlayerSpawn' found in test level") printerr("SMOKE RESULT: FAIL — no Node3D named 'PlayerSpawn' found in test level")
level_instance.queue_free()
root_holder.queue_free()
quit(1) quit(1)
return return
@@ -58,8 +62,6 @@ func _run() -> void:
if spawn_y < 1.0: if spawn_y < 1.0:
printerr("SMOKE RESULT: FAIL — PlayerSpawn y = ", spawn_y, printerr("SMOKE RESULT: FAIL — PlayerSpawn y = ", spawn_y,
" is below the required minimum of 1.0 m above ground top (y=0)") " is below the required minimum of 1.0 m above ground top (y=0)")
level_instance.queue_free()
root_holder.queue_free()
quit(1) quit(1)
return return
@@ -69,8 +71,6 @@ func _run() -> void:
var ground: StaticBody3D = level_instance.find_child("Ground", true, false) as StaticBody3D var ground: StaticBody3D = level_instance.find_child("Ground", true, false) as StaticBody3D
if ground == null: if ground == null:
printerr("SMOKE RESULT: FAIL — no StaticBody3D named 'Ground' found") printerr("SMOKE RESULT: FAIL — no StaticBody3D named 'Ground' found")
level_instance.queue_free()
root_holder.queue_free()
quit(1) quit(1)
return return
@@ -83,8 +83,6 @@ func _run() -> void:
var ground_top: float = ground.global_position.y + box_shape.size.y / 2.0 var ground_top: float = ground.global_position.y + box_shape.size.y / 2.0
if abs(ground_top - 0.0) > 0.01: if abs(ground_top - 0.0) > 0.01:
printerr("SMOKE RESULT: FAIL — Ground top face at y = ", ground_top, " expected ~0.0") printerr("SMOKE RESULT: FAIL — Ground top face at y = ", ground_top, " expected ~0.0")
level_instance.queue_free()
root_holder.queue_free()
quit(1) quit(1)
return return
print("SMOKE: Ground top face at y = ", ground_top, " — PASS") print("SMOKE: Ground top face at y = ", ground_top, " — PASS")
@@ -98,15 +96,11 @@ func _run() -> void:
prop_count += 1 prop_count += 1
if prop_count < 3: if prop_count < 3:
printerr("SMOKE RESULT: FAIL — only ", prop_count, " props found, need >= 3") printerr("SMOKE RESULT: FAIL — only ", prop_count, " props found, need >= 3")
level_instance.queue_free()
root_holder.queue_free()
quit(1) quit(1)
return return
print("SMOKE: found ", prop_count, " props — PASS") print("SMOKE: found ", prop_count, " props — PASS")
else: else:
printerr("SMOKE RESULT: FAIL — no 'Props' Node3D found") printerr("SMOKE RESULT: FAIL — no 'Props' Node3D found")
level_instance.queue_free()
root_holder.queue_free()
quit(1) quit(1)
return return
@@ -114,8 +108,6 @@ func _run() -> void:
var sun: DirectionalLight3D = level_instance.find_child("Sun", true, false) as DirectionalLight3D var sun: DirectionalLight3D = level_instance.find_child("Sun", true, false) as DirectionalLight3D
if sun == null: if sun == null:
printerr("SMOKE RESULT: FAIL — no DirectionalLight3D named 'Sun' found") printerr("SMOKE RESULT: FAIL — no DirectionalLight3D named 'Sun' found")
level_instance.queue_free()
root_holder.queue_free()
quit(1) quit(1)
return return
print("SMOKE: found Sun DirectionalLight3D") print("SMOKE: found Sun DirectionalLight3D")
@@ -123,14 +115,10 @@ func _run() -> void:
var env: WorldEnvironment = level_instance.find_child("Environment", true, false) as WorldEnvironment var env: WorldEnvironment = level_instance.find_child("Environment", true, false) as WorldEnvironment
if env == null: if env == null:
printerr("SMOKE RESULT: FAIL — no WorldEnvironment named 'Environment' found") printerr("SMOKE RESULT: FAIL — no WorldEnvironment named 'Environment' found")
level_instance.queue_free()
root_holder.queue_free()
quit(1) quit(1)
return return
print("SMOKE: found WorldEnvironment") print("SMOKE: found WorldEnvironment")
# All checks passed # All checks passed
print("SMOKE RESULT: PASS") print("SMOKE RESULT: PASS")
level_instance.queue_free()
root_holder.queue_free()
quit(0) quit(0)