RynthCore as of 2026-11-08 (internal 9297e93): release 2026.11.8.1

This commit is contained in:
Tom Bohar 2026-11-08 15:48:45 -05:00
commit c68204f160
99 changed files with 5032 additions and 185 deletions

View file

@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<!--
Offline checks for the Settings > Navigation > Outdoor Hunt "Go for" row (2026-11-08): the mirror
of RynthAi's OutdoorHuntPick (0 = Nearest monster, 1 = Biggest pack, 2 = Most XP) in
UI\Data\SettingsData.cs. Nothing is claimed until RynthAi sends the value (an older RynthAi omits
it: the row stays hidden and a save sends null, which RynthAi leaves alone); the row edits only
that property and keeps it within the three choices.
The engine has no test seam for SettingsData.cs (it pulls in the whole ImGui layer), so this
references the built engine assembly and reaches the internal types by reflection. x86, like
the engine: needs the x86 .NET runtime (C:\Program Files (x86)\dotnet).
Run: dotnet run -c Release (exit 0 = pass, 1 = fail)
-->
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0-windows</TargetFramework>
<PlatformTarget>x86</PlatformTarget>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<Platforms>x86</Platforms>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
<RootNamespace>OutdoorHuntPickTests</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\RynthCore.Engine\RynthCore.Engine.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,110 @@
using System.Collections;
using System.Reflection;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
namespace OutdoorHuntPickTests
{
// Reaches RynthCore.Engine's internal settings mirror by reflection. See the csproj.
internal static class Program
{
private static int _fails, _asserts;
private static void Check(bool cond, string msg)
{
_asserts++;
if (!cond) { _fails++; Console.WriteLine($" [FAIL] {msg}"); }
}
private const string Ns = "RynthCore.Engine.UI.Data.";
private const BindingFlags All = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance;
private static int Main()
{
Assembly engine = Assembly.Load("RynthCore.Engine");
Type settingsType = engine.GetType(Ns + "RynthAiSettings", throwOnError: true)!;
Type ctxType = engine.GetType(Ns + "RynthAiSettingsJsonContext", throwOnError: true)!;
Type schemaType = engine.GetType(Ns + "SettingsSchema", throwOnError: true)!;
PropertyInfo? prop = settingsType.GetProperty("OutdoorHuntPick", All);
Check(prop != null && prop.PropertyType == typeof(int?), "the mirror has a nullable int OutdoorHuntPick (RynthAi's payload name)");
if (prop == null) return Finish();
object ctx = ctxType.GetProperty("Default", All)!.GetValue(null)!;
var info = (JsonTypeInfo)ctxType.GetProperty("RynthAiSettings", All)!.GetValue(ctx)!;
object Parse(string json) => JsonSerializer.Deserialize(json, info)!;
// What a payload carries: nothing from an older RynthAi, the value from a newer one.
object fresh = Activator.CreateInstance(settingsType, nonPublic: true)!;
Check(prop.GetValue(fresh) == null, "a fresh mirror holds no value");
Check(prop.GetValue(Parse("{\"OutdoorHuntRange\":60,\"OutdoorHuntRadius\":0}")) == null, "a RynthAi without it: absent (null)");
for (int v = 0; v <= 2; v++)
Check((int?)prop.GetValue(Parse("{\"OutdoorHuntPick\":" + v + "}")) == v, $"RynthAi sends {v}");
// A save sends exactly what the mirror holds: unset stays null (RynthAi leaves its setting alone).
Check(JsonSerializer.Serialize(fresh, info).Contains("\"OutdoorHuntPick\":null"), "an unset mirror saves null");
Check(JsonSerializer.Serialize(Parse("{\"OutdoorHuntPick\":2}"), info).Contains("\"OutdoorHuntPick\":2"), "Most XP saves 2");
// The schema row, under Navigation, beside Hunt Range / Hunt Radius.
object? nav = null;
foreach (object t in (IEnumerable)schemaType.GetField("Tabs", All)!.GetValue(null)!)
if ((string)t.GetType().GetProperty("Name")!.GetValue(t)! == "Navigation") nav = t;
Check(nav != null, "a Navigation tab");
if (nav == null) return Finish();
var labels = new List<string>();
object? row = null;
int matches = 0;
foreach (object r in (IEnumerable)nav.GetType().GetProperty("Rows")!.GetValue(nav)!)
{
string label = (string?)r.GetType().GetProperty("Label")!.GetValue(r) ?? "";
labels.Add(label);
if (label == "Go for") { row = r; matches++; }
}
Check(matches == 1, "exactly one Go for row, under Navigation");
int radius = labels.IndexOf("Hunt Radius (yd)"), goFor = labels.IndexOf("Go for");
Check(radius >= 0 && goFor == radius + 1, "right after Hunt Radius");
if (row == null) return Finish();
Type rt = row.GetType();
Check(rt.GetProperty("Kind")!.GetValue(row)!.ToString() == "Combo", "a combo");
var items = (string[])rt.GetProperty("CurrentItems")!.GetValue(row)!;
Check(items.SequenceEqual(new[] { "Nearest monster", "Biggest pack", "Most XP" }), "the three choices, in RynthAi's order");
string tip = (string?)rt.GetProperty("Tooltip")!.GetValue(row) ?? "";
Check(tip.Contains("Nearest monster: the closest one, as before."), "tooltip: nearest");
Check(tip.Contains("Biggest pack: the most monsters together"), "tooltip: biggest pack");
Check(tip.Contains("Most XP: the pack worth the most experience, learned from your kills"), "tooltip: most XP");
var get = (Delegate)rt.GetProperty("Get")!.GetValue(row)!;
var set = (Delegate)rt.GetProperty("Set")!.GetValue(row)!;
MethodInfo visible = rt.GetMethod("IsVisible")!;
Check(!(bool)visible.Invoke(row, new[] { fresh })!, "hidden while RynthAi hasn't sent the value");
Check(!(bool)visible.Invoke(row, new[] { Parse("{\"OutdoorHuntRange\":60,\"OutdoorHuntRadius\":0}") })!,
"hidden for a RynthAi with Hunt Range but no Go for");
object near = Parse("{\"OutdoorHuntRange\":60,\"OutdoorHuntPick\":0}");
Check((bool)visible.Invoke(row, new[] { near })!, "shown once RynthAi sends it");
Check((double)get.DynamicInvoke(near)! == 0, "Nearest monster reads 0");
set.DynamicInvoke(near, 2.0);
Check((int?)prop.GetValue(near) == 2, "choosing Most XP sets 2");
set.DynamicInvoke(near, 1.0);
Check((int?)prop.GetValue(near) == 1, "choosing Biggest pack sets 1");
set.DynamicInvoke(near, 7.0);
Check((int?)prop.GetValue(near) == 2, "an out-of-range pick is kept within the choices");
Check((double)get.DynamicInvoke(Parse("{\"OutdoorHuntPick\":9}"))! == 2, "an unknown value from a newer RynthAi reads as the last choice");
Check((double)get.DynamicInvoke(Parse("{\"OutdoorHuntPick\":-3}"))! == 0, "a negative value reads Nearest monster");
// Picking changes nothing else in the payload.
object before = Parse("{\"OutdoorHuntRange\":60,\"OutdoorHuntRadius\":150,\"OutdoorHuntPick\":0}");
set.DynamicInvoke(before, 1.0);
string after = JsonSerializer.Serialize(before, info);
Check(after.Contains("\"OutdoorHuntRange\":60") && after.Contains("\"OutdoorHuntRadius\":150") && after.Contains("\"OutdoorHuntPick\":1"),
"Hunt Range and Hunt Radius ride along unchanged");
return Finish();
}
private static int Finish()
{
Console.WriteLine(_fails == 0 ? $"All {_asserts} checks passed." : $"{_fails} of {_asserts} checks FAILED.");
return _fails == 0 ? 0 : 1;
}
}
}