extends SceneTree ## Smoke test: a primed avatar loadout ends up rendered on the in-world player. ## ## Primes AvatarSystem directly (no backend needed -- main_menu.gd is what ## fetches the loadout over HTTP in the real flow) then loads scenes/game.tscn ## and checks the Player swapped its placeholder capsule for the assembled ## avatar. ## ## Run: godot --headless --path . --script res://scripts/smoke_test_avatar_in_world.gd var passed := 0 var failed := 0 func _initialize() -> void: _run() func _run() -> void: await process_frame var avatars := root.get_node_or_null("AvatarSystem") if not _check("AvatarSystem autoload exists", avatars != null): return _finish() _check("catalog loads", await avatars.ensure_catalog()) var bases: Array = avatars.get_assets_for_slot("base_body") if not _check("catalog has a base body", bases.size() > 0): return _finish() var ok: bool = avatars.set_loadout_from_dict({ "base_body": bases[0], "slots": {"hair": "hair_ponytail_01", "chest": "chest_bandit_01"}, }) _check("loadout primes from a backend-shaped dict", ok and avatars.has_loadout()) var err := change_scene_to_file("res://scenes/game.tscn") _check("game.tscn loads", err == OK) # Give _ready() (scene swap + avatar assembly) a few frames to settle. for i in 6: await process_frame var game := current_scene var player: Node = game.get_node_or_null("Player") if game else null if not _check("player exists in the world", player != null): return _finish() var avatar := player.get_node_or_null("Avatar") _check("player rendered the assembled avatar (not the capsule)", avatar != null) var capsule = player.get_node_or_null("CapsuleMesh") _check("placeholder capsule mesh is hidden", capsule != null and not capsule.visible) if avatar: var skel := avatar.get_node_or_null("Skeleton3D") as Skeleton3D _check("avatar carries the canonical rig", skel != null and skel.get_bone_count() == 24) var mounts := 0 if skel: for c in skel.get_children(): if c is BoneAttachment3D: mounts += 1 _check("equipped hair + chest are bone-mounted", mounts >= 2) _finish() func _check(description: String, condition: bool) -> bool: if condition: print(" PASS: ", description) passed += 1 else: printerr(" FAIL: ", description) failed += 1 return condition func _finish() -> void: print("\n=== SMOKE RESULT: %d/%d passed ===" % [passed, passed + failed]) quit(0 if failed == 0 else 1)