Files
TheriapolisV3/Theriapolis.Godot/SmokeTest.cs
T
Christopher Wiebe a23cf8bd97 M3: Asset pipeline — ContentPaths + ContentLoader + asset-test
Formalises Content/ access from the Godot host. Content lives at the
repo root (sibling of Theriapolis.Godot/), not duplicated under res://,
so the MonoGame branch and headless Tools keep reading from the same
single source of truth.

ContentPaths.cs:
  Static ContentRoot/DataDir/GfxDir resolved once via res:// walk-up
  and cached. Replaces two inline ResolveDataDir copies in SmokeTest
  and WorldMapView.

ContentLoader.cs:
  LoadGfx(relativePath) -> ImageTexture, cached by relative path.
  Bypasses the res:// import pipeline because Content/ lives outside
  the project — fine for static pixel-art assets at native size, and
  the project default texture filter is already Nearest. Cache is
  per-process, never evicted (full atlas <1 MB).

AssetTest.cs + Main.cs --asset-test flag:
  Smoke-tests the pipeline. Walks Content/Data and Content/Gfx,
  reports counts, attempts to load every PNG, prints per-subdir
  breakdown. Quits with non-zero on any failure.

Verified post-refactor (--asset-test):
  53 JSON files in Data, 50 PNG files in Gfx (8 tactical/deco +
  42 tactical/surface), 50/50 loaded, 0 failures.

Verified no regressions:
  --smoke-test (M1) still produces canonical FNV hashes.
  --world-map 12345 (M2) still produces 3 rivers / 91 roads /
  226 settlements / 0 rails / 0 bridges.

Scope note: plan mentioned "tile/NPC/CodexUI atlases — three
separate themes". Only tactical/ exists in Content/Gfx today; NPC
and CodexUI atlases never landed during MonoGame development. M3
ships what's actually present. ContentLoader.LoadGfx works for any
future sub-directories without changes.

Closes M3 of theriapolis-rpg-implementation-plan-godot-port.md.
Next: M4 (tactical render).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-01 19:13:51 -07:00

44 lines
1.7 KiB
C#

using Godot;
using System.IO;
using System.Linq;
using Theriapolis.Core.World.Generation;
using Theriapolis.GodotHost.Platform;
namespace Theriapolis.GodotHost;
/// <summary>
/// M1 determinism oracle. Runs the full Core worldgen pipeline from inside
/// the Godot process and prints FNV hashes. Output must match
/// <c>dotnet run --project Theriapolis.Tools -- worldgen-hash --seed N</c>
/// byte-for-byte. This proves Core works untouched under Godot's csproj.
/// </summary>
public static class SmokeTest
{
public static int Run(ulong seed)
{
string dataDir = ContentPaths.DataDir;
if (!Directory.Exists(dataDir))
{
GD.PrintErr($"[smoke-test] Data directory not found: {dataDir}");
return 1;
}
GD.Print($"[smoke-test] seed=0x{seed:X} data-dir={dataDir}");
var ctx = new WorldGenContext(seed, dataDir);
WorldGenerator.RunAll(ctx);
var w = ctx.World;
GD.Print($"[smoke-test] === FNV hashes ===");
GD.Print($"[smoke-test] elevation = 0x{w.HashElevation():X16}");
GD.Print($"[smoke-test] moisture = 0x{w.HashMoisture():X16}");
GD.Print($"[smoke-test] temperature = 0x{w.HashTemperature():X16}");
GD.Print($"[smoke-test] biomes = 0x{w.HashBiomes():X16}");
GD.Print($"[smoke-test] settlements = 0x{w.HashSettlements():X16}");
GD.Print($"[smoke-test] polylines = 0x{w.HashPolylines():X16}");
GD.Print($"[smoke-test] === Per-stage hashes ({w.StageHashes.Count}) ===");
foreach (var kv in w.StageHashes.OrderBy(k => k.Key, System.StringComparer.Ordinal))
GD.Print($"[smoke-test] {kv.Key,-32} = 0x{kv.Value:X16}");
return 0;
}
}