feat(01-04): preserve observer identity through control and scene changes
This commit is contained in:
1 parent
6bccd47b9b
commit
ea4dc9b5df
4 files changed
+177
-25
No files matched your search
+44
-13
@@ -341,6 +341,24 @@ internal static class Program
|
||||
var debugCheckpointFile = toolsSmoke ? Path.GetFullPath("artifacts/debug-expansion/checkpoint.tsk")
|
||||
: Path.Combine(AppContext.BaseDirectory, "debug-checkpoint.tsk");
|
||||
Vector3 returnRoot = loadedSave?.StoredVector ?? Vector3.Zero;
|
||||
void ObserveControl(string boundary)
|
||||
{
|
||||
if (observation != null && director != null)
|
||||
observation.RecordControl(level!.Code, simulation?.Steps ?? 0, director.Controlled,
|
||||
director.ControlledTag, director.Playing, director.CurrentTag, boundary);
|
||||
}
|
||||
void SkipObservedDialogue(string source)
|
||||
{
|
||||
ObserveControl("before_skip");
|
||||
director!.Skip();
|
||||
ObserveControl("skip:" + source);
|
||||
}
|
||||
void StepObservedDirector(float delta)
|
||||
{
|
||||
ObserveControl("before_director_step");
|
||||
director?.Step(delta);
|
||||
ObserveControl("director_step");
|
||||
}
|
||||
void RequestTransition(LevelTransition request)
|
||||
{
|
||||
if (transitionRequest != null) return;
|
||||
@@ -593,6 +611,8 @@ internal static class Program
|
||||
var renderer = presentation.LoadScene(mesh, texture, headless,
|
||||
walking ? WalkTitle : animations?.WindowTitle ?? "Jimmy Neutron — scene preview | C camera",
|
||||
width, height, !args.Contains("--no-validation"));
|
||||
observation?.RecordSceneEntry(level?.Code ?? "preview", simulation?.Steps ?? 0, returning,
|
||||
carriedPlayer != null, carriedSave != null ? "retained" : loadedSave != null ? "tsk-story" : "fresh-direct-scene");
|
||||
var window = presentation.Window;
|
||||
ShrinkSoldier? shrinkVictim = null;
|
||||
var shrinkPhaseMask = 0;
|
||||
@@ -668,6 +688,7 @@ internal static class Program
|
||||
sceneAudio.Music(originalStart!.Text("MusicDatabase") ?? "none", originalStart.Integer("MusicIndex", -1));
|
||||
}
|
||||
director.Begin(originalStart!, activateStartTrigger: !returning);
|
||||
ObserveControl("scene_begin");
|
||||
gadgets?.Reset();
|
||||
baseballs?.Reset();
|
||||
interactions!.Reset();
|
||||
@@ -685,7 +706,7 @@ internal static class Program
|
||||
Console.WriteLine($"Practice RETURN: exact saved root={restored}, root={simulation.ActorRoot}, STRT yaw={simulation.Yaw}, intro suppressed={!director.Playing}, companion restored={companionRestored}, retained player input order={simulation.InputAfterPlayerUpdate}, gadget availability={interactions.Inventory.State(0, 3)}.");
|
||||
if (!restored) throw new InvalidOperationException("RETURN did not restore the live departure root without replaying STRT actions");
|
||||
}
|
||||
if (args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || scooterSmoke || gadgetWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke || controlPhaseSmoke) { sceneAudio?.StopSpeech(); director.Skip(); }
|
||||
if (args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || scooterSmoke || gadgetWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke || controlPhaseSmoke) { sceneAudio?.StopSpeech(); SkipObservedDialogue("startup-option-or-fixture"); }
|
||||
if (gadgetWindowSmoke) { interactions!.Inventory.SetState(0,3,1); interactions.Inventory.SelectGadget(3); }
|
||||
if (controlPhaseSmoke)
|
||||
{
|
||||
@@ -710,13 +731,13 @@ internal static class Program
|
||||
{
|
||||
if (interactions!.Inventory.State(0, 3) != 1)
|
||||
throw new InvalidOperationException("VR04 PostLoad tail did not re-enable its owned practice jetpack");
|
||||
director.Skip();
|
||||
SkipObservedDialogue("fixture-setup");
|
||||
interactions!.Update(level.Entities.First(e => e.Kind == "LOAD").Position);
|
||||
if (transitionRequest is not { Returning: true }) throw new InvalidOperationException("VR04 exit did not preserve RETURN identity");
|
||||
}
|
||||
if (args.Contains("--smoke-transition"))
|
||||
{
|
||||
director.Skip();
|
||||
SkipObservedDialogue("fixture-setup");
|
||||
interactions!.Update(level!.Entities.First(e => e.Kind == "LOAD").Position);
|
||||
if (transitionRequest == null) throw new InvalidOperationException("Original VR01 RETURN contact did not request a transition");
|
||||
}
|
||||
@@ -729,9 +750,9 @@ internal static class Program
|
||||
if (carlSmoke) LabRouteSmoke.StartCarl(level!, director, interactions!, () => practice.Key(17, Vector2.Zero));
|
||||
if (objectiveSmoke)
|
||||
{
|
||||
director.Skip();
|
||||
SkipObservedDialogue("fixture-setup");
|
||||
director.Touch(level!.Player!.Tag!, level.Entities.Single(e => e.Tag == "teleportexplanation").Position);
|
||||
director.Skip();
|
||||
SkipObservedDialogue("fixture-setup");
|
||||
if (interactions!.CurrentObjective != 1) throw new InvalidOperationException("Original explanation did not assign objective1");
|
||||
if (objectiveWindowSmoke) objectivePanel!.Step(9);
|
||||
}
|
||||
@@ -739,7 +760,7 @@ internal static class Program
|
||||
|| practiceReturnSmoke && level.Code == "LV1B" && !returning)
|
||||
{
|
||||
if ((!headless && !practiceWindowSmoke) || level?.Code != "LV1B") throw new ArgumentException("Practice smoke requires the original lab");
|
||||
director.Skip();
|
||||
SkipObservedDialogue("fixture-setup");
|
||||
if (practiceReturnSmoke)
|
||||
{
|
||||
// Move the real player away from STRT so an accidental
|
||||
@@ -748,7 +769,7 @@ internal static class Program
|
||||
director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, simulation.Rotation);
|
||||
}
|
||||
director.Touch(level!.Player!.Tag!, level.Entities.Single(e => e.Tag == "teleportexplanation").Position);
|
||||
director.Skip();
|
||||
SkipObservedDialogue("fixture-setup");
|
||||
interactions!.Update(director.FindActor("shrinkray")!.Position);
|
||||
if (!practice.Active) throw new InvalidOperationException("Original lab pickup did not open practice modal");
|
||||
if (args.Contains("--smoke-practice-transition") || practiceReturnSmoke) practice.Key(28, Vector2.Zero);
|
||||
@@ -761,7 +782,7 @@ internal static class Program
|
||||
interactions!.UpdateEnergy(simulation!.Energy);
|
||||
foreach (var patrol in patrols.Values) patrol.Step(FixedStepClock.Step);
|
||||
mechanisms!.Step(FixedStepClock.Step);
|
||||
director.Step(FixedStepClock.Step);
|
||||
StepObservedDirector(FixedStepClock.Step);
|
||||
objectivePanel!.Step(FixedStepClock.Step, director.ControlledTag != null, practice.Active);
|
||||
if (animations!.SelectAction(director.FindActor(level!.Player!.Tag!)!.Animation)) initialPoseTime = 0;
|
||||
initialPoseTime += FixedStepClock.Step;
|
||||
@@ -879,6 +900,7 @@ internal static class Program
|
||||
if (simulation == null) { debugMenu.Message = "RESET REQUIRES PLAY MODE"; return; }
|
||||
if (practice.Active) practice.Key(17, Vector2.Zero);
|
||||
playerBinding?.ResetVehicle();simulation.Reset(); poseTime = 0; sceneAudio?.StopSpeech(); director?.Begin(originalStart!);
|
||||
ObserveControl("reset_begin");
|
||||
rocketship?.Reset();
|
||||
if(scooter!=null)
|
||||
{
|
||||
@@ -914,7 +936,7 @@ internal static class Program
|
||||
case DebugAction.Camera: ToggleCamera(); debugMenu.Close(); break;
|
||||
case DebugAction.SkipCutscene:
|
||||
if (director is { Playing: true } or { Blocked: true }||director is{Controlled:false}&&rocketship?.Mounted!=true)
|
||||
{ sceneAudio?.StopSpeech(); director.Skip(); debugMenu.Message = "CUTSCENE SKIPPED"; }
|
||||
{ sceneAudio?.StopSpeech(); SkipObservedDialogue("debug-menu"); debugMenu.Message = "CUTSCENE SKIPPED"; }
|
||||
else debugMenu.Message = "NO ACTIVE CUTSCENE";
|
||||
break;
|
||||
case DebugAction.RefillEnergy when simulation != null:
|
||||
@@ -1137,6 +1159,10 @@ internal static class Program
|
||||
}
|
||||
while (!headless && Sdl.SDL_PollEvent(out var e))
|
||||
{
|
||||
observation?.RecordRawEvent(level?.Code ?? "preview", simulation?.Steps ?? 0,
|
||||
e.Type, e.Type is Sdl.KeyDown or Sdl.KeyUp ? e.Scancode : null,
|
||||
e.Type is Sdl.MouseButtonDown or Sdl.MouseButtonUp ? e.MouseButton : null,
|
||||
e.Type is Sdl.KeyDown or Sdl.KeyUp ? e.Repeat : null);
|
||||
if(scooterSmoke&&e.Type==Sdl.KeyDown)
|
||||
sawScooterKeys|=e.Scancode switch{81=>1,82=>2,80=>4,225=>8,43=>16,60=>32,21=>64,_=>0};
|
||||
if(grapplerSmoke&&e.Type==Sdl.KeyDown)
|
||||
@@ -1230,7 +1256,7 @@ internal static class Program
|
||||
if (smoke && e.Scancode == 79) sawKey = true;
|
||||
if (e.Scancode is 41 or 44 && e.Repeat == 0 && director is { Controlled: false }&&rocketship?.Mounted!=true
|
||||
&& (e.Scancode != 44 || simulation?.Noclip != true))
|
||||
{ sceneAudio?.StopSpeech(); director.Skip(); keys.Clear(); mouseJump = false; }
|
||||
{ sceneAudio?.StopSpeech(); SkipObservedDialogue("sdl-key-" + e.Scancode); keys.Clear(); mouseJump = false; }
|
||||
else if (e.Scancode == 41) running = false;
|
||||
if (inspecting && e.Repeat == 0 && animations?.Select(e.Scancode) == true)
|
||||
{
|
||||
@@ -1301,6 +1327,10 @@ internal static class Program
|
||||
else { simulation.Step(input); acceptsInput = true; }
|
||||
observation?.RecordInput(level?.Code ?? "preview", simulation.Steps, input, acceptsInput,
|
||||
director?.ControlledTag ?? (playerBinding == null ? "direct-simulation" : "script"));
|
||||
observation?.RecordState(level?.Code ?? "preview", simulation.Steps, simulation.ActorRoot,
|
||||
simulation.Rotation, simulation.Velocity, simulation.Grounded, simulation.MovementMode,
|
||||
simulation.InputAfterPlayerUpdate, simulation.ControllerSteps, simulation.PhysicsSteps, simulation.EffectSteps);
|
||||
ObserveControl("player_step");
|
||||
scooterFixture?.Received(input);
|
||||
grapplerFixture?.Received(input);
|
||||
rocketFixture?.Received(input);
|
||||
@@ -1324,7 +1354,7 @@ internal static class Program
|
||||
}
|
||||
mechanisms?.Step(FixedStepClock.Step);
|
||||
foreach (var patrol in patrols.Values) patrol.Step(FixedStepClock.Step);
|
||||
director?.Step(FixedStepClock.Step);
|
||||
StepObservedDirector(FixedStepClock.Step);
|
||||
objectivePanel?.Key(keys.Contains(18) && director is { Controlled: true, InventoryEnabled: true });
|
||||
objectivePanel?.Step(FixedStepClock.Step, director?.ControlledTag != null, practice.Active);
|
||||
var switched = director is { Controlled: false } && !simulation.Noclip
|
||||
@@ -1525,8 +1555,8 @@ internal static class Program
|
||||
&& simulation.Energy < 20 && Vector2.Distance(new(simulation.ActorRoot.X, simulation.ActorRoot.Z), new(controlEntry.X, controlEntry.Z)) < .001f;
|
||||
CutsceneIdleSmoke.LandWhileLocked(playerBinding!, director!, simulation!);
|
||||
sceneAudio?.StopSpeech();
|
||||
director!.Skip();
|
||||
CutsceneIdleSmoke.VerifyReturn(playerBinding!, director, simulation!);
|
||||
SkipObservedDialogue("control-phase-fixture");
|
||||
CutsceneIdleSmoke.VerifyReturn(playerBinding!, director!, simulation!);
|
||||
controlControllers = simulation!.ControllerSteps;
|
||||
}
|
||||
if (controlPhaseSmoke && count == 30)
|
||||
@@ -1873,6 +1903,7 @@ internal static class Program
|
||||
continuation = new(nextArgs.ToArray(), (debugCheckpointToLoad ?? interactions!.Snapshot()) with {
|
||||
StartPoint = transitionRequest.StartPoint, StoredVector = debugCheckpointToLoad?.StoredVector ?? returnRoot }, transitionRequest.Returning,
|
||||
debugCheckpointToLoad == null ? simulation?.CaptureLevelState(interactions!.Inventory.SelectedGadget) : null);
|
||||
observation?.RecordTransition(level!.Code, transitionRequest.LevelFile, simulation?.Steps ?? 0, transitionRequest.Returning);
|
||||
Console.WriteLine($"Loading original destination: {transitionRequest.LevelFile}, start={transitionRequest.StartPoint}; fade behavior remains unreconstructed.");
|
||||
}
|
||||
if (walkSmoke && !simulation!.SmokePassed) return 2;
|
||||
|
||||
Reference in new issue
Block a user