Fix original cutscene music lifecycle and verify walking lab route
This commit is contained in:
1 parent
c929f942e1
commit
b58138d7ba
16 files changed
+282
-18
No files matched your search
@@ -0,0 +1,104 @@
|
||||
using System.Numerics;
|
||||
using GamePort.Assets;
|
||||
using GamePort.Game;
|
||||
using GamePort.Application;
|
||||
|
||||
// An explicit modern input replay, not recovered original navigation/AI. The
|
||||
// player is never repositioned and all contacts use the live collision result.
|
||||
var original = Path.GetFullPath(args.Length == 1 ? args[0] : "../Original");
|
||||
var prepared = Path.GetFullPath("artifacts/extracted");
|
||||
var level = GamLevel.Load(AssetPath.Resolve(original, "gam/level1b.gam"));
|
||||
var start = level.FindStart()!;
|
||||
var world = Mesh.LoadSceneJson(Path.Combine(prepared, "level1b/scene.json"));
|
||||
var save = OriginalSave.Load(Path.Combine(original, "NewGame.tsk"));
|
||||
var tasks = new TaskStates(save.Tasks);
|
||||
var resources = new PreparedEntityResources(Path.Combine(prepared, "level1b/entities/entities.json"));
|
||||
var director = new SceneDirector(level, tasks, resources.Duration);
|
||||
var interactions = new SceneInteractions(director, tasks, save, level.Code);
|
||||
var mechanisms = new SceneMechanisms(director);
|
||||
var visuals = new StaticSceneVisuals(world, director, original, Path.Combine(prepared, "level1b/models"));
|
||||
var simulation = new LabSimulation(new SceneCollision(world), AseMesh.Load(AssetPath.Resolve(original, "ASE/jimstop.ase")),
|
||||
start.Position, start.Rotation.Y) { JetpackInventoryState = () => interactions.Inventory.State(0, 3) };
|
||||
simulation.DynamicRootResolver = (before, after, radius) => DynamicBodyResponse.Resolve(visuals.DoorColliders(), before, after, radius);
|
||||
var patrols = new List<ActorPatrol>();
|
||||
foreach (var actor in director.Actors.Where(a => a.Kind is "3DOG" or "3CAR"))
|
||||
{
|
||||
var physics = new OriginalScenePhysics(world);
|
||||
var grounded = false;
|
||||
var patrol = new ActorPatrol(actor, director.FindActor, (body, dt) =>
|
||||
{
|
||||
var step = physics.Step(body.Position, body.Velocity, actor.Kind == "3DOG" ? 130 : 100,
|
||||
actor.Kind == "3DOG" ? .3f : .75f, grounded, dt);
|
||||
grounded = step.Supported;
|
||||
return new(step.Body.Position, step.Body.Velocity);
|
||||
});
|
||||
patrols.Add(patrol);
|
||||
director.RegisterPatrolConsumer(actor.Tag);
|
||||
director.ActorChanged += changed => { if (ReferenceEquals(changed, actor)) patrol.SynchronizeAuthoredState(); };
|
||||
}
|
||||
var practice = new PracticePrompt();
|
||||
interactions.PracticeRequested += practice.Show;
|
||||
var prompts = 0;
|
||||
LevelTransition? destination = null;
|
||||
interactions.Transition += request => destination ??= request;
|
||||
director.Begin(start);
|
||||
interactions.Reset(); mechanisms.Reset(); director.Skip();
|
||||
|
||||
Vector2 Point(string tag)
|
||||
{
|
||||
var p = director.FindActor(tag)!.Position;
|
||||
return new(p.X, p.Z);
|
||||
}
|
||||
// Source trigger/item/marker/exit locations plus an explicit doorway approach.
|
||||
// The approach avoids the wall outside the authored exit opening.
|
||||
var exit = Point("LABTONEIGH");
|
||||
var route = new[] { Point("teleportexplanation"), Point("shrinkray"), Point("CARLESC3"),
|
||||
new Vector2(exit.X, 500), exit };
|
||||
var sceneStates = new[] { 35, 50, 60, 60, 60 };
|
||||
for (var leg = 0; leg < route.Length && destination == null; leg++)
|
||||
{
|
||||
var arrived = false;
|
||||
for (var tick = 0; tick < 2400; tick++)
|
||||
{
|
||||
if (practice.Active)
|
||||
{
|
||||
Require(practice.Mode == 0, "Wrong lab practice mode");
|
||||
practice.Key(17, Vector2.Zero); // N resumes; no direct task/pickup mutation.
|
||||
prompts++;
|
||||
}
|
||||
var difference = route[leg] - new Vector2(simulation.Position.X, simulation.Position.Z);
|
||||
if (difference.Length() < 90) { arrived = true; break; }
|
||||
var desiredYaw = MathF.Atan2(-difference.X, difference.Y) * 180 / MathF.PI;
|
||||
var error = MathF.IEEERemainder(desiredYaw - simulation.Yaw, 360);
|
||||
if (director.Controlled)
|
||||
{
|
||||
var previous = simulation.ActorRoot;
|
||||
simulation.Step(new(MathF.Abs(error) < 30, false, error > 1, error < -1, false));
|
||||
Require(Vector3.Distance(previous, simulation.ActorRoot) < 100, "Player warped during input replay");
|
||||
director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, new(0, simulation.Yaw, 0));
|
||||
director.Touch(level.Player!.Tag!, simulation.ActorRoot);
|
||||
interactions.Update(simulation.ActorRoot, simulation.InteractionRadius);
|
||||
if (practice.Active) continue; // Same modal activation boundary as Program.
|
||||
mechanisms.Update(simulation.ActorRoot, simulation.InteractionRadius);
|
||||
}
|
||||
mechanisms.Step(FixedStepClock.Step);
|
||||
foreach (var patrol in patrols) patrol.Step(FixedStepClock.Step);
|
||||
director.Step(FixedStepClock.Step);
|
||||
if (destination != null) break;
|
||||
}
|
||||
Require(arrived || destination != null, $"Input route blocked at leg{leg}: {simulation.ActorRoot}");
|
||||
Require(tasks.Get("SCENE") == sceneStates[leg], $"Wrong task state after walking leg{leg}");
|
||||
Console.WriteLine($"PASS walked leg{leg}: SCENE={tasks.Get("SCENE")}, root={simulation.ActorRoot}");
|
||||
}
|
||||
Require(destination is { LevelFile: "level1.gam", StartPoint: "level1" }, "Walking did not enter the source outside LOAD");
|
||||
Require(interactions.Score == 150 && interactions.Inventory.State(0, 3) == 1 && prompts == 1,
|
||||
"Walking route did not preserve jetpack/Carl score, inventory and practice dispatch");
|
||||
Require(simulation.Steps > 500 && simulation.Travel > 5000 && simulation.Jumps == 0, "Walking route did not exercise actual movement");
|
||||
Require(!director.Blocked, "Source director blocked during the walking route");
|
||||
Console.WriteLine($"PASS input-only lab route ->level1.gam, score150, jetpack owned, practice declined once. {simulation.Report}");
|
||||
Console.WriteLine("This verifies port navigation through the lab; original collision/cadence/behavior fidelity remains unverified.");
|
||||
|
||||
static void Require(bool condition, string message)
|
||||
{
|
||||
if (!condition) throw new InvalidOperationException(message);
|
||||
}
|
||||
Reference in new issue
Block a user