Reconstruct lab story, interactions, patrol and jet pack practice flow
This commit is contained in:
1 parent
58424120bb
commit
c929f942e1
84 files changed
+7957
-305
No files matched your search
@@ -0,0 +1,63 @@
|
||||
using System.Numerics;
|
||||
using System.Text.Json;
|
||||
using GamePort.Assets;
|
||||
using GamePort.Application;
|
||||
|
||||
var temp = Path.Combine(Path.GetTempPath(), "neutron-hud-" + Guid.NewGuid());
|
||||
Directory.CreateDirectory(temp);
|
||||
try
|
||||
{
|
||||
var entries = new[] { (120,256,29),(121,256,29),(122,256,29),(156,320,173),(169,207,100),(83,8,8),(84,8,8),(85,8,8) }
|
||||
.Select(t => new { id=t.Item1, width=t.Item2, height=t.Item3, path=$"{t.Item1}.rgba" }).ToArray();
|
||||
foreach (var entry in entries) File.WriteAllBytes(Path.Combine(temp, entry.path), new byte[entry.width * entry.height * 4]);
|
||||
string Manifest(object textures) => JsonSerializer.Serialize(new { version=1, referenceWidth=640, referenceHeight=480, textures });
|
||||
var path = Path.Combine(temp, "ui.json");
|
||||
File.WriteAllText(path, Manifest(entries));
|
||||
var source = new Mesh([new(new(5,6,7), Vector2.Zero, Vector3.One)], [0,0,0]);
|
||||
var hud = new SceneHud(source, path);
|
||||
Check(hud.Mesh.Vertices.Length == 33 && hud.Mesh.Indices.Length == 51, "Exact bounded HUD ranges");
|
||||
Check(hud.Mesh.Draws.Length == 9 && !hud.Mesh.Draws[0].ScreenSpace && hud.Mesh.Draws.Skip(1).All(d => d.ScreenSpace),
|
||||
"Preserve implicit world draw; explicit HUD overlays");
|
||||
Check(hud.Mesh.Textures.Count == 8, "Original canvas count");
|
||||
var final = hud.Mesh with { Vertices = hud.Mesh.Vertices.ToArray(), Draws = hud.Mesh.Draws.Select(d => d with {}).ToArray() };
|
||||
hud.Update(final, 2, true, true);
|
||||
Check(final.Vertices[0].Position == new Vector3(5,6,7), "HUD leaves world data unchanged");
|
||||
Check(hud.Mesh.Vertices[1].Position == Vector3.Zero && final.Vertices[1].Position != Vector3.Zero,
|
||||
"Update writes final merged buffer after copies");
|
||||
Near(final.Vertices[1].Position, new(.2f, 2*311f/480-1, 0), "Pad default source offset");
|
||||
Near(final.Vertices[9].Position, new(.2f, 2*379f/480-1, 0), "Selected objective row position");
|
||||
Near(final.Vertices[21].Position, new(2*393f/640-1, 2*381f/480-1, 0), "Selected original digit position");
|
||||
Near(final.Vertices[29].Position, new(2*210f/640-1, 2*210f/480-1, 0), "Practice source position");
|
||||
Check(final.Draws.Select(d => d.Visible).SequenceEqual(new[] { true,true,false,true,false,false,true,false,true }),
|
||||
"Only pad, active objective2 and practice visible");
|
||||
hud.Update(final, 3, true, false, 0);
|
||||
Check(final.Draws.Select(d => d.Visible).SequenceEqual(new[] { true,true,false,false,true,false,false,true,false }), "Objective3 and dismissed modal");
|
||||
Near(final.Vertices[1].Position, new(.2f, 2*380f/480-1, 0), "Expanded source HUD offset");
|
||||
hud.Update(final, 0, true, false);
|
||||
Check(final.Draws.Skip(1).All(d => !d.Visible), "No invented objective0 image");
|
||||
Reject(() => hud.Update(source, 1, true, false), "Missing final ranges");
|
||||
Reject(() => hud.Update(final, 1, true, false, float.NaN), "Nonfinite HUD offset");
|
||||
File.WriteAllText(path, Manifest(entries.Select(e => new { e.id, width=e.id==120 ? 0 : e.width, e.height, e.path })));
|
||||
Reject(() => new SceneHud(source,path), "Bad canvas dimensions");
|
||||
File.WriteAllText(path, Manifest(entries.Select(e => new { e.id, e.width, e.height, path=e.id==120 ? "../outside.rgba" : e.path })));
|
||||
Reject(() => new SceneHud(source,path), "Escaping texture path");
|
||||
File.WriteAllText(path, Manifest(entries.Concat(entries.Take(1))));
|
||||
Reject(() => new SceneHud(source,path), "Unbounded texture count");
|
||||
if (args.Length == 1)
|
||||
{
|
||||
var originalHud = new SceneHud(source, args[0]);
|
||||
originalHud.Update(originalHud.Mesh,1,true,true);
|
||||
Check(originalHud.Mesh.Textures.Values.Any(p=>p.Rgba.Any(v=>v!=0)), "Actual original RGBA loaded");
|
||||
}
|
||||
Console.WriteLine("PASS original UI geometry/visibility/final buffer and bounded prepared manifest checks");
|
||||
}
|
||||
finally { Directory.Delete(temp,true); }
|
||||
|
||||
static void Check(bool value,string message) { if(!value)throw new Exception(message); }
|
||||
static void Near(Vector3 a,Vector3 b,string message) => Check(Vector3.Distance(a,b)<.00001f,message);
|
||||
static void Reject(Action action,string message)
|
||||
{
|
||||
try { action(); }
|
||||
catch (Exception e) when (e is InvalidDataException or ArgumentException) { return; }
|
||||
throw new Exception("Accepted invalid input: " + message);
|
||||
}
|
||||
Reference in new issue
Block a user