Files
TheriapolisV3/Theriapolis.Godot/SmokeTest.cs
T

60 lines
2.2 KiB
C#
Raw Normal View History

using Godot;
using System.IO;
using System.Linq;
using Theriapolis.Core.World.Generation;
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 = ResolveDataDir();
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;
}
private static string ResolveDataDir()
{
string fromRes = ProjectSettings.GlobalizePath("res://../Content/Data");
if (Directory.Exists(fromRes)) return fromRes;
string? dir = ProjectSettings.GlobalizePath("res://").TrimEnd('/', '\\');
for (int i = 0; i < 6; i++)
{
if (string.IsNullOrEmpty(dir)) break;
string candidate = Path.Combine(dir, "Content", "Data");
if (Directory.Exists(candidate)) return candidate;
dir = Path.GetDirectoryName(dir);
}
return fromRes;
}
}