Run body and fire phases during scripted control locks

This commit is contained in:
UnixNight committed 2026-10-26 12:21:25 -04:00
1 parent 5876da112c
commit c285b57091
35 files changed
+1503 -45

No files matched your search

+99
View File
@@ -139,6 +139,96 @@ Check(carlBytes.AsSpan(0x3159e, 15).SequenceEqual(Convert.FromHexString("8B0D489
"Source MCA clears game controlled pointer before playback");
Console.WriteLine("PASS end-of-lab Carl cutscene input lock and natural/skip control restoration");
foreach (var kind in new[] { "3CAM", "3MCA", "3AIT" })
{
var jim = Entity("3JIM", "JIM1", ("RotationX", 12f), ("RotationZ", 22f));
var command = Entity(kind, "command", ("PlayerControlled", "NULL"),
("CameraTarget", "JIM1"), ("CameraTarget0", "JIM1"), ("CameraTarget1", "JIM1"),
("SoundIndex", 1), ("SoundIndex0", 1), ("SoundIndex1", 1), ("SoundDatabase", "voice"),
("NextTrigger", "default"));
var scene = new SceneDirector(new("LV1B", [jim, command]), new TaskStates([]), (_, _) => .1);
var body = ControlBody();
var bag = new SceneInventory(new int[19]); bag.SetState(0, 3, 1); bag.SelectGadget(3);
using var binding = new PlayerSceneBinding(scene, body, bag, "JIM1");
for (var tick = 0; tick < 5; tick++) binding.Step(new(true, false, false, false, false));
var callbacks = new List<ScriptPreparation>();
scene.ActorPreparing += (actor, action) =>
{
Check(actor.Tag == "JIM1" && scene.AuthoredControlledTag == "JIM1", "Preparation observes the prior raw owner");
callbacks.Add(action);
};
var stopObserved = false;
scene.ActorChanged += actor =>
{
if (actor.Tag == "JIM1" && actor.Animation == "STOP")
{
Check(body.Velocity == Vector3.Zero && body.Speed == 0, "Body preparation precedes derived STOP notification");
stopObserved = true;
}
};
scene.Trigger("command");
var expected = kind switch
{
"3CAM" => new[] { ScriptPreparation.ReleaseGadget, ScriptPreparation.StopMotion, ScriptPreparation.FlattenOrientation },
"3MCA" => new[] { ScriptPreparation.StopMotion, ScriptPreparation.FlattenOrientation, ScriptPreparation.ReleaseGadget },
_ => new[] { ScriptPreparation.StopMotion }
};
Check(stopObserved && callbacks.SequenceEqual(expected) && body.Speed == 0 && body.Velocity == Vector3.Zero,
"CAM/MCA/AI retain their own ordered preparation boundaries");
Check(bag.SelectedGadget == (kind == "3AIT" ? 3 : -1), "AI control loss does not imply camera gadget cleanup");
Check(scene.FindActor("JIM1")!.Rotation.X == (kind == "3AIT" ? 12 : 0), "Only camera preparation flattens pitch/roll");
if (kind == "3AIT") continue; // Its DEFAULT next trigger has already restored control.
var controllers = body.ControllerSteps;
binding.Step(new(true, false, true, false, true));
Check(body.ControllerSteps == controllers && body.Jumps == 0 && body.PhysicsSteps > controllers,
"Input lock leaves body/effect callbacks running");
scene.DebugForceControl = true;
binding.Step(new(true, false, false, false, false));
var speed = body.Speed;
scene.Step(.11f);
Check(callbacks.SequenceEqual(expected), "Later MCA shots/CAM completion do not replay initial preparations");
Check(body.Speed == speed && scene.Controlled, "Force control does not become the raw preparation owner");
scene.DebugForceControl = false;
scene.Trigger("default");
var jumps = body.Jumps;
binding.Step(new(false, false, false, false, true));
Check(body.Jumps == jumps + 1, "DEFAULT restores held jump without an invented fresh-key boundary");
}
Console.WriteLine("PASS ordered CAM/MCA/AI preparations, body continuation, raw-owner force override and held-input restoration");
{
var jim = Entity("3JIM", "JIM1");
var command = Entity("3AIT", "move", ("PlayerControlled", "NULL"), ("AITarget", "JIM1"),
("AINewPos", "marker"), ("AINewRotY", 75f));
var marker = Entity("DUMY", "marker", ("PositionX", 200f), ("PositionY", 500f), ("PositionZ", 300f));
var scene = new SceneDirector(new("LV1B", [jim, command, marker]), new TaskStates([]), (_, _) => 1);
var body = ControlBody();
using var binding = new PlayerSceneBinding(scene, body, new SceneInventory(new int[19]), "JIM1");
scene.Trigger("move");
Near(body.ActorRoot, marker.Position, "Authored AI position is applied to the actual player body");
Check(body.Yaw == 75 && !scene.Controlled, "Authored AI yaw follows the logical setter during control loss");
binding.Step(new(true, false, true, false, true));
Check(body.ActorRoot.Y < marker.Position.Y && body.ActorRoot.X == marker.Position.X && body.ControllerSteps == 0,
"Body settles at the scripted location without accepting movement input");
Near(scene.FindActor("JIM1")!.Position, body.ActorRoot, "Physics publishes the new logical player root");
}
Console.WriteLine("PASS authored player teleport/yaw survives uncontrolled body synchronization");
{
var jim = Entity("3JIM", "JIM1");
var empty = Entity("3MCA", "empty", ("CameraTarget0", "none"), ("PlayerControlled", "NULL"), ("NextTrigger", "default"));
var missing = Entity("3CAM", "missing", ("CameraTarget", "absent"), ("SoundIndex", 1), ("PlayerControlled", "NULL"));
var scene = new SceneDirector(new("LV1B", [jim, empty, missing]), new TaskStates([]), (_, _) => 1);
var callbacks = new List<ScriptPreparation>(); scene.ActorPreparing += (_, action) => callbacks.Add(action);
scene.Trigger("empty");
Check(callbacks.Count == 0 && scene.AuthoredControlledTag == "JIM1" && !scene.Playing,
"Initial MCA none target returns without preparation or invoking completion ownership");
scene.Trigger("missing");
Check(callbacks.Count == 3 && scene.AuthoredControlledTag == null && scene.Blocked,
"CAM preparation precedes target-lookup failure");
}
Console.WriteLine("PASS first-MCA none return and CAM failure preparation boundaries");
foreach(var type in new[]{0,1,2,3,4})
{
var camera=Entity("3MCA","camera",("CameraTarget0","actor"),("SoundDatabase","voice"),("SoundIndex0",1),("CameraType0",type),("LookatVOffset0",100f),("NextTrigger","default"));
@@ -268,6 +358,15 @@ var returnGate=vr.Entities.First(e=>e.Kind=="LOAD");interactions.Update(returnGa
Check(transitions==1 && returned!.Returning && returned.LevelFile==save.ReturnLevel && returned.StartPoint==save.ReturnStart,"RETURN uses stored destination, restore flag and contact-enter gating");
Console.WriteLine("PASS original VR01 star/trophy score, strict contact entry, acquired-state save/reload and RETURN request");
static LabSimulation ControlBody()
{
var points = new[] { new Vector3(-10000, 0, -10000), new Vector3(-10000, 0, 10000),
new Vector3(10000, 0, 10000), new Vector3(10000, 0, -10000) };
var floor = new Mesh(points.Select(p => new MeshVertex(p, Vector2.Zero, Vector3.One)).ToArray(), [0, 1, 2, 0, 2, 3]);
var standing = new Mesh([new(new(-20, -20, -20), Vector2.Zero, Vector3.One), new(new(20, 80, 20), Vector2.Zero, Vector3.One)], []);
return new(new SceneCollision(floor), standing, new(0, 25, 0), 0);
}
static GamEntity Entity(string kind,string tag,params (string Name,object Value)[] values)
{
var properties=new Dictionary<string,GamProperty>();