using System.Numerics; using System.Text.Json; using GamePort.Game; using var document=JsonDocument.Parse(File.ReadAllText(Path.Combine(AppContext.BaseDirectory,"original-scalar-reference.json"))); var cases=document.RootElement.GetProperty("cases").EnumerateArray().ToArray(); Check(cases.Length==30,"thirty copied-original observations"); foreach(var c in cases) { var p=c.GetProperty("input").EnumerateArray().Select(x=>x.GetSingle()).ToArray(); var observed=c.GetProperty("observed").EnumerateArray().Select(x=>x.GetSingle()).ToArray(); var name=c.GetProperty("kind").GetString()+"/"+c.GetProperty("name").GetString(); switch(c.GetProperty("kind").GetString()) { case "attach": var a=GrapplerMotion.Attach(new(p[0],p[1],p[2]),new(p[3],p[4],p[5]),new(11,-222,33),p[6]); Near(a.Length,observed[0],name+" length");Near(a.InitialLength,observed[1],name+" first length"); Check(a.RopeScaleZ.HasValue==(observed[3]==1),name+" scale write ownership"); if(a.RopeScaleZ is{} scale)Near(scale,observed[2],name+" scale"); break; case "held":Near(GrapplerMotion.HeldReel(p[0],p[2]),observed[0],name);break; case "fast":Near(GrapplerMotion.FastReel(p[0],p[1],p[2]),observed[0],name);break; case "swing": var s=GrapplerMotion.Swing(new(p[0],p[1],p[2]),p[3],p[4],p[5],p[6]); Near(s.X,observed[0],name+" X");Near(s.Z,observed[1],name+" Z");Near(s.Elapsed,observed[2],name+" elapsed");break; default:throw new Exception("Unknown native reference kind"); } } Console.WriteLine("PASS all30 copied-original attachment/reel/damping scalar observations"); var first=GrapplerMotion.Attach(Vector3.Zero,new(0,300,400),new(10,-200,20)); Check(first.Velocity==new Vector3(10,100,20)&&first.FastReelTarget==100,"source attachment velocity/reel target"); var second=GrapplerMotion.Attach(Vector3.Zero,new(0,600,800),Vector3.Zero,first.InitialLength); Check(second.InitialLength==400&&second.Length==900&&second.RopeScaleZ==null,"reattach retains first rope length/scale"); Console.WriteLine("PASS first-length retention and independent velocity/scalar publication"); Check(GrapplerMotion.HeldReel(251,.1f)==226&&GrapplerMotion.HeldReel(250,.1f)==250,"strict held-reel gate without final250 clamp"); Check(GrapplerMotion.FastReel(251,250,.1f)==156&&GrapplerMotion.FastReel(250,250,.1f)==250,"strict fast-reel target without final clamp"); var shortRope=GrapplerMotion.Swing(new(100,-100,.2f),0,0,0,349); var longRope=GrapplerMotion.Swing(new(100,-100,.2f),0,0,0,350); Check(shortRope.X==47.5f&&longRope.X==49,"350 damping boundary after50 clamp"); var tick=GrapplerMotion.Swing(new(50,50,0),.6f,0,0,400); Near(tick.X,49,"one damping per callback");Near(tick.Elapsed,.4f,"remainder retained"); Console.WriteLine("PASS strict overshoot, clamp/damping threshold and one-step timing"); Check(GrapplerMotion.JumpDetaches(true,false,true),"jump detaches"); Check(!GrapplerMotion.JumpDetaches(true,true,true)&&!GrapplerMotion.JumpDetaches(false,false,true) &&!GrapplerMotion.JumpDetaches(true,false,false),"independent fire/jump/attached predicates"); Console.WriteLine("PASS simultaneous fire prevents jump detach"); Reject(()=>GrapplerMotion.HeldReel(300,-.1f));Reject(()=>GrapplerMotion.FastReel(300,0,float.NaN)); Reject(()=>GrapplerMotion.Attach(new(float.PositiveInfinity,0,0),Vector3.Zero,Vector3.Zero)); Reject(()=>GrapplerMotion.Swing(new(0,0,float.NaN),.1f,0,0,400)); Console.WriteLine("PASS nonfinite and unsupported timestep boundaries"); QueryReferences.Run(); Console.WriteLine("Grappler:10 groups,72 original component observations; body composition/camera/lifetime and live VR08 integration remain separate gates."); static void Check(bool ok,string message){if(!ok)throw new Exception(message);} static void Near(float actual,float expected,string message)=>Check(float.IsFinite(actual)&&MathF.Abs(actual-expected)<.0002f,$"{message}: {actual} != {expected}"); static void Reject(Action action){try{action();throw new Exception("Invalid scalar state accepted");}catch(ArgumentOutOfRangeException){}}