Expand debug system pages and add noclip exploration

This commit is contained in:
UnixNight committed 2026-10-25 20:34:27 -04:00
1 parent b915a2c2e4
commit d7838980fd
20 files changed
+628 -47

No files matched your search

+1 -1
View File
@@ -63,7 +63,7 @@ public sealed class DebugDiagnostics
I($"VEL X {F(motion.Velocity.X)} Y {F(motion.Velocity.Y)} Z {F(motion.Velocity.Z)}"),
I($"YAW {F(status.Yaw)} SPEED {F(status.Speed)} TURN {F(motion.TurnRate)}"),
I($"GROUND {B(status.Grounded)} POSE {motion.Pose} ENERGY {F(status.Energy)}"),
I($"CTRL {B(status.Controlled)} FORCE {B(status.ForcedControl)} PAUSED {B(motion.Paused)}"),
I($"CTRL {B(status.Controlled)} FORCE {B(status.ForcedControl)} PAUSED {B(motion.Paused)} NOCLIP {B(status.Systems?.Noclip ?? false)}"),
I($"SCENE {status.SceneTask} SCORE {status.Score} JETPACK {motion.JetpackState} {F(motion.JetpackRemaining)}S"),
I($"CAM {camera} FAR {F(status.FarPlane)}"),
I($"CUT {status.Cutscene} SHOT {motion.Shot} BLOCK {B(motion.Blocked)}"),
+93 -9
View File
@@ -5,17 +5,55 @@ using GamePort.Assets;
namespace GamePort.Application;
public sealed record DebugScene(string LevelFile, string Code, string[] Starts);
public enum DebugAction { None, Resume, Camera, SkipCutscene, RefillEnergy, GiveJetpack, ApplySceneTask, LoadScene, Reset, ForceControl, ToggleOverlay }
public enum DebugAction { None, Resume, Camera, SkipCutscene, RefillEnergy, GiveJetpack, ApplySceneTask, LoadScene, Reset, ForceControl, ToggleOverlay,
Noclip, NoclipSpeed, StopMotion, ShowObjective, ReturnNoclipEntry, LevelAvailability, InputOrder, ApplyJetpackState,
CameraObstruction, MuteMusic, MuteSpeech, MuteEffects, RestartMusic, StopEffects, SaveCheckpoint, LoadCheckpoint, Practice }
public sealed record DebugMenuView(string[] Lines, int SelectedLine);
public sealed record DebugStatus(string Level, string Start, Vector3 Root, float Yaw, float Speed,
bool Grounded, float Energy, int Score, int SceneTask, string Cutscene, bool Controlled,
int Issues, float FarPlane, bool Inspecting, bool ForcedControl = false, bool DiagnosticsVisible = false, string? CameraMode = null);
int Issues, float FarPlane, bool Inspecting, bool ForcedControl = false, bool DiagnosticsVisible = false, string? CameraMode = null,
DebugSystems? Systems = null);
public sealed record DebugSystems
{
public bool Noclip { get; init; }
public float NoclipSpeed { get; init; } = 600;
public Vector3 Velocity { get; init; }
public Vector3 PendingImpulse { get; init; }
public int MovementMode { get; init; }
public bool InputAfterPlayer { get; init; }
public int JumpState { get; init; }
public float JumpHold { get; init; }
public float BurnRemaining { get; init; }
public int JetpackAvailability { get; init; }
public int Objective { get; init; }
public float ObjectiveTime { get; init; }
public bool? CameraObstruction { get; init; }
public int CameraPolygons { get; init; }
public int CameraWallPolygons { get; init; }
public int CameraTests { get; init; }
public bool AudioAvailable { get; init; }
public bool MusicMuted { get; init; }
public bool SpeechMuted { get; init; }
public bool EffectsMuted { get; init; }
public int MusicBytes { get; init; }
public int SpeechBytes { get; init; }
public int EffectBytes { get; init; }
}
/// <summary>Modern investigation tools, deliberately separate from recovered game UI.</summary>
public sealed class DebugMenu
{
public const uint ToggleKey = 58; // SDL scancode F1; F11 remains fullscreen.
public const uint NoclipKey = 60; // F3; F2 remains live diagnostics.
public const int ItemCount = 12;
public const int PageCount = 3;
public int Page { get; private set; }
public int PageItems => Page switch { 1 => 10, 2 => 9, _ => ItemCount };
private static readonly float[] FlySpeeds = [300, 600, 1200, 2400];
private int flySpeedIndex = 1, jetpackStateIndex = 1;
private static readonly int[] JetpackStates = [0, 1, 4];
public float FlySpeed => FlySpeeds[flySpeedIndex];
public int JetpackState => JetpackStates[jetpackStateIndex];
public bool Open { get; private set; }
public int Selected { get; private set; }
public int SceneTask { get; private set; }
@@ -24,6 +62,7 @@ public sealed class DebugMenu
private int sceneIndex, startIndex;
public DebugScene? Scene => scenes.Length == 0 ? null : scenes[sceneIndex];
public string? Start => Scene is { } scene ? scene.Starts[startIndex] : null;
public DebugScene? FindScene(string code) => scenes.FirstOrDefault(s => s.Code == code);
public DebugMenu(IEnumerable<DebugScene> scenes, string? currentLevel, string? currentStart)
{
@@ -47,19 +86,39 @@ public sealed class DebugMenu
{
if (!Open) return DebugAction.None;
if (scancode == 41) { Close(); return DebugAction.None; }
if (scancode == 43 && !repeat) { Page = (Page + 1) % PageCount; Selected = 0; return DebugAction.None; }
if (scancode is 82 or 81)
Selected = (Selected + (scancode == 82 ? ItemCount - 1 : 1)) % ItemCount;
Selected = (Selected + (scancode == 82 ? PageItems - 1 : 1)) % PageItems;
else if (scancode is 80 or 79 or 75 or 78)
{
var direction = scancode is 80 or 78 ? -1 : 1;
if (Selected == 5)
if (Page == 1 && Selected == 1)
flySpeedIndex = (flySpeedIndex + FlySpeeds.Length + direction) % FlySpeeds.Length;
else if (Page == 1 && Selected == 7)
jetpackStateIndex = (jetpackStateIndex + JetpackStates.Length + direction) % JetpackStates.Length;
else if (Page == 0 && Selected == 5)
SceneTask = (int)Math.Clamp((long)SceneTask + direction * (scancode is 75 or 78 ? 10 : 1), 0, 999);
else if (Selected == 6 && scenes.Length > 0)
else if (Page == 0 && Selected == 6 && scenes.Length > 0)
{ sceneIndex = (sceneIndex + scenes.Length + direction) % scenes.Length; startIndex = 0; }
else if (Selected == 7 && Scene is { } scene)
else if (Page == 0 && Selected == 7 && Scene is { } scene)
startIndex = (startIndex + scene.Starts.Length + direction) % scene.Starts.Length;
}
else if (scancode is 40 or 88 && !repeat)
{
if (Page == 1) return Selected switch
{
0 => DebugAction.Noclip, 1 => DebugAction.NoclipSpeed, 2 => DebugAction.StopMotion,
3 => DebugAction.ShowObjective, 4 => DebugAction.ReturnNoclipEntry,
5 => DebugAction.LevelAvailability, 6 => DebugAction.InputOrder,
8 => DebugAction.ApplyJetpackState, 9 => DebugAction.RefillEnergy, _ => DebugAction.None
};
if (Page == 2) return Selected switch
{
0 => DebugAction.CameraObstruction, 1 => DebugAction.MuteMusic, 2 => DebugAction.MuteSpeech,
3 => DebugAction.MuteEffects, 4 => DebugAction.RestartMusic, 5 => DebugAction.StopEffects,
6 => DebugAction.SaveCheckpoint, 7 => DebugAction.LoadCheckpoint, 8 => DebugAction.Practice,
_ => DebugAction.None
};
return Selected switch
{
0 => DebugAction.Resume, 1 => DebugAction.Camera, 2 => DebugAction.SkipCutscene,
@@ -69,6 +128,7 @@ public sealed class DebugMenu
11 => DebugAction.ToggleOverlay,
_ => DebugAction.None
};
}
return DebugAction.None;
}
@@ -77,6 +137,30 @@ public sealed class DebugMenu
if (!Open) return new([], -1);
var c = CultureInfo.InvariantCulture;
string F(float value) => value.ToString("0.0", c);
var system = status.Systems ?? new();
if (Page != 0)
{
string V(Vector3 v) => $"{F(v.X)} {F(v.Y)} {F(v.Z)}";
string[] header = ["NEUTRON DEBUG MENU - F1", $"PAUSED - PAGE {Page + 1}/3: {(Page == 1 ? "PLAYER" : "SYSTEMS")}",
$"LEVEL {status.Level} / START {status.Start}", $"ROOT {V(status.Root)} NOCLIP {system.Noclip}",
Page == 1 ? $"VEL {V(system.Velocity)} MODE {system.MovementMode}" : $"STATIC POLYS {system.CameraPolygons} WALLS {system.CameraWallPolygons} TESTS {system.CameraTests}",
Page == 1 ? $"PENDING {V(system.PendingImpulse)}" : $"AUDIO BYTES MUSIC {system.MusicBytes} VOICE {system.SpeechBytes}",
Page == 1 ? $"JUMP {system.JumpState} HOLD {F(system.JumpHold)} BURN {F(system.BurnRemaining)}"
: $"EFFECT BYTES {system.EffectBytes} AUDIO AVAILABLE {system.AudioAvailable}",
$"OBJECTIVE {system.Objective} TIME {F(system.ObjectiveTime)} GADGET STATE {system.JetpackAvailability}", ""];
string[] items = Page == 1 ? [
$"NOCLIP (F3): {system.Noclip} (ENTER TOGGLE)",
$"FLY SPEED: {F(FlySpeed)} LIVE {F(system.NoclipSpeed)} (ENTER APPLIES)", "STOP MOTION / CLEAR QUEUED JUMP", "SHOW CURRENT OBJECTIVE",
"RETURN TO NOCLIP ENTRY POSITION", "APPLY THIS LEVEL'S GADGET AVAILABILITY",
$"INPUT AFTER PLAYER: {system.InputAfterPlayer} (TOGGLE)",
$"JET PACK STATE: {JetpackState} (0 NONE / 1 OWNED / 4 DISABLED)", "APPLY JET PACK STATE", "REFILL ENERGY TO 100"] : [
$"STATIC CAMERA OBSTRUCTION: {(system.CameraObstruction?.ToString() ?? "UNAVAILABLE")}",
$"MUTE MUSIC: {system.MusicMuted}", $"MUTE SPEECH: {system.SpeechMuted}", $"MUTE EFFECTS: {system.EffectsMuted}",
"RESTART SELECTED MUSIC", "STOP ALL EFFECTS / LOOPS", "SAVE DEBUG CHECKPOINT", "LOAD DEBUG CHECKPOINT", "SHOW JET PACK PRACTICE PROMPT"];
return new([.. header, .. items, "", "TAB NEXT PAGE UP/DOWN SELECT ENTER APPLY",
Page == 1 ? "FLY: WASD/ARROWS SPACE/E UP CTRL/Q DOWN SHIFT FAST" : "CHECKPOINT: DEBUG-CHECKPOINT.TSK BESIDE EXECUTABLE",
"F1 / ESC CLOSE - ACTIONS USE EXISTING SYSTEMS", Message], header.Length + Selected);
}
return new([
"NEUTRON DEBUG MENU - F1",
"PAUSED - MODERN DEBUG TOOLS",
@@ -100,9 +184,9 @@ public sealed class DebugMenu
$"FORCE CONTROL: {status.ForcedControl} (ENTER TOGGLE)",
$"LIVE OVERLAY: {status.DiagnosticsVisible} (F2 / ENTER TOGGLE)",
"",
"UP/DOWN SELECT LEFT/RIGHT CHANGE ENTER APPLY",
"SCENE TASK: PAGE UP/DOWN CHANGES BY 10",
"F1 / ESC CLOSE - GAME INPUT IS CAPTURED WHILE OPEN",
"TAB NEXT PAGE UP/DOWN SELECT LEFT/RIGHT CHANGE",
"ENTER APPLIES SCENE TASK: PAGE UP/DOWN CHANGES BY 10",
"F1 / ESC CLOSE F3 NOCLIP - GAME INPUT CAPTURED",
Message
], 9 + Selected);
}
+20 -7
View File
@@ -11,6 +11,9 @@ public sealed class SceneAudio : IDisposable
private readonly List<SdlAudio> effects = [];
private readonly Dictionary<string, SdlAudio> loops = new(StringComparer.OrdinalIgnoreCase);
public bool Paused { get; private set; }
public bool MusicMuted { get; private set; }
public bool SpeechMuted { get; private set; }
public bool EffectsMuted { get; private set; }
public int EffectCount => effects.Count;
public int LoopCount => loops.Count;
public int QueuedEffectBytes => effects.Sum(effect => effect.QueuedBytes) + loops.Values.Sum(effect => effect.QueuedBytes);
@@ -27,13 +30,13 @@ public sealed class SceneAudio : IDisposable
{
StopMusic();
if (selectedMusic is { } selection && resources.Wave(selection.Database, selection.Id) is { } wave)
music = new(wave.Path, true, Paused);
music = new(wave.Path, true, Paused, MusicMuted);
}
public void Speech(string database, int id)
{
StopSpeech();
var wave = resources.Wave(database, id) ?? throw new FileNotFoundException($"Missing prepared speech: {database}:{id}");
speech = new(wave.Path, paused: Paused);
speech = new(wave.Path, paused: Paused, muted: SpeechMuted);
}
public void StopSpeech() { speech?.Dispose(); speech = null; }
// Default current bank set by Jimmy PostLoad423642..656; positional attenuation
@@ -42,11 +45,11 @@ public sealed class SceneAudio : IDisposable
{
var wave = resources.Wave("SoundEffects.omt", id)
?? throw new FileNotFoundException($"Missing original default sound effect {id}");
if (loopOwner == null) effects.Add(new(wave.Path, paused: Paused));
if (loopOwner == null) effects.Add(new(wave.Path, paused: Paused, muted: EffectsMuted));
else
{
StopLoop(loopOwner);
loops.Add(loopOwner, new(wave.Path, true, Paused));
loops.Add(loopOwner, new(wave.Path, true, Paused, EffectsMuted));
}
}
public void StopLoop(string owner)
@@ -70,10 +73,20 @@ public sealed class SceneAudio : IDisposable
/// <summary>Modern debug pause; new streams also inherit this state.</summary>
public void SetPaused(bool paused)
{
music?.SetPaused(paused); speech?.SetPaused(paused);
foreach (var effect in effects) effect.SetPaused(paused);
foreach (var effect in loops.Values) effect.SetPaused(paused);
Paused = paused;
ApplyPause();
}
public void SetDebugMute(bool musicMuted, bool speechMuted, bool effectsMuted)
{
MusicMuted = musicMuted; SpeechMuted = speechMuted; EffectsMuted = effectsMuted;
ApplyPause();
}
private void ApplyPause()
{
music?.SetPaused(Paused); speech?.SetPaused(Paused);
music?.SetMuted(MusicMuted); speech?.SetMuted(SpeechMuted);
foreach (var effect in effects) { effect.SetPaused(Paused); effect.SetMuted(EffectsMuted); }
foreach (var effect in loops.Values) { effect.SetPaused(Paused); effect.SetMuted(EffectsMuted); }
}
public void Dispose() { StopEffects(); StopSpeech(); StopMusic(); }
}
+9 -1
View File
@@ -11,6 +11,7 @@ public sealed class SdlAudio : IDisposable
private readonly bool loop;
private bool audioInitialized;
public bool Paused { get; private set; }
public bool Muted { get; private set; }
public int QueuedBytes
{
get
@@ -19,7 +20,7 @@ public sealed class SdlAudio : IDisposable
return bytes >= 0 ? bytes : throw new InvalidOperationException(Sdl.Error);
}
}
public SdlAudio(string path,bool loop=false,bool paused=false)
public SdlAudio(string path,bool loop=false,bool paused=false,bool muted=false)
{
this.loop=loop;
if(!Sdl.SDL_InitSubSystem(Sdl.InitAudio))throw new InvalidOperationException(Sdl.Error);
@@ -34,6 +35,7 @@ public sealed class SdlAudio : IDisposable
// SDL_OpenAudioDeviceStream starts paused. Keep it paused from its
// first sample when created while a debug menu has stopped playback.
Paused = true;
SetMuted(muted);
SetPaused(paused);
Console.WriteLine($"SDL3 WAV stream: {spec.Frequency} Hz, {spec.Channels} channel(s), {length} source bytes.");
}
@@ -47,6 +49,12 @@ public sealed class SdlAudio : IDisposable
if (!changed) throw new InvalidOperationException(Sdl.Error);
Paused = paused;
}
public void SetMuted(bool muted)
{
ObjectDisposedException.ThrowIf(stream == 0, this);
if (!Sdl.SDL_SetAudioStreamGain(stream, muted ? 0 : 1)) throw new InvalidOperationException(Sdl.Error);
Muted = muted;
}
private void Queue(){if(!Sdl.SDL_PutAudioStreamData(stream,data,length))throw new InvalidOperationException(Sdl.Error);}
public void Pump(){if(!Paused && loop && QueuedBytes<length)Queue();}
public void Dispose()
+66 -2
View File
@@ -3,7 +3,8 @@ using GamePort.Assets;
namespace GamePort.Game;
public readonly record struct PlayerInput(bool Forward, bool Backward, bool Left, bool Right, bool Jump);
public readonly record struct PlayerInput(bool Forward, bool Backward, bool Left, bool Right, bool Jump,
bool Rise = false, bool Descend = false, bool StrafeLeft = false, bool StrafeRight = false, bool Fast = false);
public enum PlayerPose { Idle, Run, Backpedal, Jump, Fall, Fly }
/// <summary>
@@ -23,6 +24,11 @@ public sealed class LabSimulation
private int movementMode;
private JetpackBurstState jumpState;
private bool forceFall;
private Vector3 noclipEntry;
private float noclipEntryYaw;
public bool Noclip { get; private set; }
public bool HasNoclipEntry { get; private set; }
public float NoclipSpeed { get; set; } = 600;
public Func<int>? JetpackInventoryState { get; set; }
public string LevelCode { get; set; } = "LV1B";
public int GadgetMode { get; set; } = -1;
@@ -30,6 +36,8 @@ public sealed class LabSimulation
public float InteractionRadius { get; private set; } = 60;
public bool JetpackEffectVisible { get; private set; }
public float JetpackRemaining => jumpState.EffectRemaining;
public int JumpState => jumpState.JumpState;
public float JumpHoldSeconds => jumpState.HoldSeconds;
public int Bursts { get; private set; }
public float BodyHeight { get; }
public Vector3 Position { get; private set; } // Feet, not original actor root.
@@ -43,7 +51,8 @@ public sealed class LabSimulation
public float Speed { get; private set; }
public float TurnRate { get; private set; }
public bool Grounded { get; private set; }
public PlayerPose Pose => pendingImpulse.Y > 0 ? PlayerPose.Jump
public PlayerPose Pose => Noclip ? Velocity.LengthSquared() > 0 ? PlayerPose.Fly : PlayerPose.Idle
: pendingImpulse.Y > 0 ? PlayerPose.Jump
: Grounded ? Speed < -1 ? PlayerPose.Backpedal : Speed > 1 ? PlayerPose.Run : PlayerPose.Idle
: jumpState.JumpState == 3 && jumpState.EffectRemaining > 0 ? PlayerPose.Fly
: !forceFall && Velocity.Y > 0 ? PlayerPose.Jump : PlayerPose.Fall;
@@ -92,6 +101,7 @@ public sealed class LabSimulation
forceFall = JetpackEffectVisible = false;
InteractionRadius = 60; Bursts = 0;
Grounded = true;
Noclip = HasNoclipEntry = false;
Steps = Jumps = Landings = WallHits = 0;
Travel = MaximumRise = 0;
CameraEye = DesiredEye().Eye;
@@ -118,6 +128,7 @@ public sealed class LabSimulation
public void Step(PlayerInput input)
{
if (Noclip) { StepNoclip(input); return; }
//47E554 global body integration precedes473740 registry callbacks.
// This reconstructs the player/input/fire partial order, not the full
// scene registry, original cadence or original collision response.
@@ -130,6 +141,58 @@ public sealed class LabSimulation
Steps++;
}
/// <summary>Modern debug movement; never serialized into original save state.</summary>
public bool SetNoclip(bool enabled)
{
if (enabled == Noclip) return false;
if (enabled)
{
noclipEntry = Position; noclipEntryYaw = Yaw; HasNoclipEntry = true;
}
var returned = !enabled && !collision.CanOccupy(Position, BodyRadius, BodyHeight);
if (returned) { Position = noclipEntry; Yaw = targetYaw = noclipEntryYaw; }
Noclip = enabled;
StopDebugMotion();
Grounded = false;
CameraEye = DesiredEye().Eye;
return returned;
}
public void StopDebugMotion()
{
Velocity = pendingImpulse = Vector3.Zero;
Speed = TurnRate = extraAirAcceleration = lateralContribution = 0;
jumpState = default; movementMode = 0; forceFall = JetpackEffectVisible = false;
targetYaw = Yaw;
}
public bool ReturnToNoclipEntry()
{
if (!HasNoclipEntry) return false;
Position = noclipEntry; Yaw = targetYaw = noclipEntryYaw;
StopDebugMotion(); Grounded = false; CameraEye = DesiredEye().Eye;
return true;
}
private void StepNoclip(PlayerInput input)
{
if (!float.IsFinite(NoclipSpeed) || NoclipSpeed <= 0 || NoclipSpeed > 10000)
throw new ArgumentOutOfRangeException(nameof(NoclipSpeed));
const float dt = FixedStepClock.Step;
Yaw = targetYaw = (Yaw + ((input.Left ? 1 : 0) - (input.Right ? 1 : 0)) * 90 * dt) % 360;
var (sin, cos) = Trig(Yaw);
var direction = new Vector3(-sin, 0, cos) * ((input.Forward ? 1 : 0) - (input.Backward ? 1 : 0))
+ new Vector3(cos, 0, sin) * ((input.StrafeRight ? 1 : 0) - (input.StrafeLeft ? 1 : 0))
+ Vector3.UnitY * ((input.Rise ? 1 : 0) - (input.Descend ? 1 : 0));
if (direction.LengthSquared() > 1) direction = Vector3.Normalize(direction);
Velocity = direction * NoclipSpeed * (input.Fast ? 3 : 1);
var delta = Velocity * dt;
Position += delta; Travel += new Vector2(delta.X, delta.Z).Length();
MaximumRise = Math.Max(MaximumRise, Position.Y - startFloor);
Grounded = false; Steps++;
CameraEye = DesiredEye().Eye;
}
private void StepInput(PlayerInput input)
{
const float dt = FixedStepClock.Step;
@@ -241,6 +304,7 @@ public sealed class LabSimulation
{
var (sin, cos) = Trig(Yaw);
var eye = ActorRoot + new Vector3(sin * 350, 180, -cos * 350);
if (Noclip) return (eye, 1); // Debug exploration also bypasses camera obstruction.
if (cameraRay == null) return (collision.ClipCamera(CameraTarget, eye), 1);
//43B820: query from the computed look target; first accepted static hit
//moves desired eye25% toward look and returns follow gain1.5. No radius
+12
View File
@@ -17,6 +17,18 @@ public sealed class SceneCollision
private readonly Triangle[] triangles;
public int TriangleCount => triangles.Length;
/// <summary>Modern debug exit check against the current capsule adapter.</summary>
public bool CanOccupy(Vector3 feet, float radius, float height)
{
Validate(feet, Vector3.Zero, radius, height);
CapsuleBounds(feet, radius, height, out var min, out var max);
foreach (var triangle in triangles)
if (Overlaps(min, max, triangle)
&& Closest(feet, radius, height, triangle).DistanceSquared < (radius - Tolerance) * (radius - Tolerance))
return false;
return true;
}
private readonly record struct Triangle(Vector3 A, Vector3 B, Vector3 C,
Vector3 Normal, Vector3 Min, Vector3 Max);
private readonly record struct Hit(float Time, Vector3 Normal);
+1
View File
@@ -65,6 +65,7 @@ internal static unsafe class Sdl
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)] [return:MarshalAs(UnmanagedType.I1)]public static extern bool SDL_PauseAudioStreamDevice(nint stream);
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)] [return:MarshalAs(UnmanagedType.I1)]public static extern bool SDL_PutAudioStreamData(nint stream,nint buffer,int length);
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)]public static extern int SDL_GetAudioStreamQueued(nint stream);
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)] [return:MarshalAs(UnmanagedType.I1)]public static extern bool SDL_SetAudioStreamGain(nint stream,float gain);
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)]public static extern void SDL_DestroyAudioStream(nint stream);
[DllImport(Library,CallingConvention=CallingConvention.Cdecl)]public static extern void SDL_Delay(uint ms);
}
+195 -19
View File
@@ -88,6 +88,9 @@ internal static class Program
--smoke-objective-panel Show original lab objective; --story-time tests timeout
--smoke-objective-window SDL O-key reopen/close/timeout check
--debug-menu Start with the F1 debug menu open
--debug-page NAME Open general, player or systems debug page
--noclip Start modern debug flight (F3 toggles)
--smoke-debug-tools SDL pages/noclip/audio/checkpoint check
--debug-overlay Start with live F2 diagnostics visible
--smoke-debug-menu SDL debug navigation/pause/actions/resize check
--smoke-debug-overlay SDL live diagnostics/input/menu/resize check
@@ -251,6 +254,7 @@ internal static class Program
var practiceWindowSmoke = args.Contains("--smoke-practice-window");
var practiceReturnSmoke = args.Contains("--smoke-practice-return");
var debugSmoke = args.Contains("--smoke-debug-menu");
var toolsSmoke = args.Contains("--smoke-debug-tools");
var diagnosticsSmoke = args.Contains("--smoke-debug-overlay");
if (walkSmoke && jetpackSmoke) throw new ArgumentException("Select one movement smoke check");
var defaultStory = (defaultScene || args.Contains("--walk")) && !args.Contains("--inspect") && !walkSmoke && !args.Contains("--smoke-window")
@@ -283,6 +287,10 @@ internal static class Program
ObjectivePanel? objectivePanel = null;
var patrols = new Dictionary<string, ActorPatrol>(StringComparer.OrdinalIgnoreCase);
LevelTransition? transitionRequest = null;
OriginalSave? debugCheckpointToLoad = null;
OriginalCameraRay? debugCameraRay = null;
var debugCheckpointFile = toolsSmoke ? Path.GetFullPath("artifacts/debug-expansion/checkpoint.tsk")
: Path.Combine(AppContext.BaseDirectory, "debug-checkpoint.tsk");
Vector3 returnRoot = loadedSave?.StoredVector ?? Vector3.Zero;
void RequestTransition(LevelTransition request)
{
@@ -304,6 +312,7 @@ internal static class Program
{
var cameraRay = level!.Code is "LV1B" or "VR04" or "LEV1"
? OriginalCameraRay.FromRouteScene(world, level.Code) : null;
debugCameraRay = cameraRay;
simulation = new LabSimulation(new SceneCollision(world), standingPose, originalStart.Position, originalStart.Rotation.Y,
cameraRay == null ? null : (look, eye) => cameraRay.Trace(look, eye))
{ LevelCode = level.Code, InputAfterPlayerUpdate = carriedSave != null };
@@ -378,6 +387,14 @@ internal static class Program
? DebugMenu.AvailableScenes(root, Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene)!, ".."))) : [],
Path.GetFileName(levelPath), originalStart?.Tag);
if (args.Contains("--debug-menu")) debugMenu.Toggle(storyTasks?.Get("SCENE") ?? 0);
if (Option(args, "--debug-page") is { } debugPage)
{
var page = debugPage.ToLowerInvariant() switch { "general" => 0, "player" => 1, "systems" => 2,
_ => throw new ArgumentException("Debug page must be general, player or systems") };
if (!debugMenu.Open) debugMenu.Toggle(storyTasks?.Get("SCENE") ?? 0);
for (var i = 0; i < page; i++) debugMenu.Key(43);
}
if (args.Contains("--noclip") && simulation != null) simulation.SetNoclip(true);
var debugOverlay = new DebugMenuOverlay(mesh);
mesh = debugOverlay.Mesh;
Console.WriteLine($"Loaded original geometry and overlays: {mesh.Vertices.Length} vertices, {mesh.Indices.Length / 3} triangles, {mesh.Textures.Count + (scene == null ? 1 : 0)} textures.");
@@ -393,7 +410,9 @@ internal static class Program
var storyTime = double.Parse(Option(args, "--story-time") ?? "0", System.Globalization.CultureInfo.InvariantCulture);
if (!double.IsFinite(storyTime) || storyTime < 0 || storyTime > 3600 || storyTime > 0 && !headless)
throw new ArgumentException("Story time must be0..3600 seconds in headless mode.");
var frames = int.Parse(Option(args, "--frames") ?? (walkSmoke ? "240" : jetpackSmoke ? "300" : objectiveWindowSmoke ? "180" : carlSmoke ? "60" : debugSmoke ? "16" : diagnosticsSmoke ? "24" : headless ? "1" : "0"));
var frames = int.Parse(Option(args, "--frames") ?? (walkSmoke ? "240" : jetpackSmoke ? "300" : objectiveWindowSmoke ? "180" : carlSmoke ? "60" : toolsSmoke ? "20" : debugSmoke ? "16" : diagnosticsSmoke ? "24" : headless ? "1" : "0"));
if (toolsSmoke && (headless || frames < 16 || director == null || level?.Code != "LV1B" || loadedSave != null || debugMenu.Open))
throw new ArgumentException("Debug tools smoke requires a fresh windowed lab and at least16 frames");
if (debugSmoke && (headless || frames < 16 || director == null || level?.Code != "LV1B" || loadedSave != null || debugMenu.Open))
throw new ArgumentException("Debug SDL smoke requires fresh windowed LV1B, closed debug menu and at least16 frames");
if (diagnosticsSmoke && (headless || frames < 24 || director == null || level?.Code != "LV1B" || loadedSave != null
@@ -453,7 +472,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 || debugSmoke || diagnosticsSmoke) { sceneAudio?.StopSpeech(); director.Skip(); }
if (args.Contains("--skip-intro") || jetpackSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke) { sceneAudio?.StopSpeech(); director.Skip(); }
if (practiceReturnSmoke && level.Code == "VR04")
{
if (interactions!.Inventory.State(0, 3) != 4)
@@ -556,6 +575,8 @@ internal static class Program
var diagnosticsInitialTravel = simulation?.Travel ?? 0;
var debugPausedRoot = simulation?.ActorRoot ?? Vector3.Zero;
var debugPausedSteps = simulation?.Steps ?? 0;
var toolsPaused = false; var toolsMoved = false; var toolsStopped = false; var toolsSaved = false; var toolsSystems = false;
var toolsEntry = simulation?.ActorRoot ?? Vector3.Zero;
void ResetScene()
{
if (simulation == null) { debugMenu.Message = "RESET REQUIRES PLAY MODE"; return; }
@@ -612,10 +633,86 @@ internal static class Program
case DebugAction.ToggleOverlay:
diagnostics.Enabled = !diagnostics.Enabled;
debugMenu.Message = $"LIVE OVERLAY {diagnostics.Enabled}; F2 TOGGLE DURING PLAY"; break;
case DebugAction.Noclip when simulation != null:
if (inspecting) ToggleCamera();
var returnedToEntry = simulation.SetNoclip(!simulation.Noclip);
SyncDebugPlayer();
debugMenu.Message = returnedToEntry ? "NOCLIP OFF; INSIDE TERRAIN, RESTORED ENTRY POSITION"
: $"NOCLIP {simulation.Noclip}; F3 TOGGLE, CLOSE MENU TO MOVE";
break;
case DebugAction.NoclipSpeed when simulation != null:
simulation.NoclipSpeed = debugMenu.FlySpeed; debugMenu.Message = "FLY SPEED APPLIED"; break;
case DebugAction.StopMotion when simulation != null:
simulation.StopDebugMotion(); debugMenu.Message = "MOTION AND QUEUED JUMP CLEARED"; break;
case DebugAction.ReturnNoclipEntry when simulation != null:
debugMenu.Message = simulation.ReturnToNoclipEntry() ? "RESTORED NOCLIP ENTRY POSITION" : "ENABLE NOCLIP FIRST";
SyncDebugPlayer(); break;
case DebugAction.ShowObjective when objectivePanel != null:
objectivePanel.Show(); debugMenu.Message = "OBJECTIVE TIMER REOPENED"; break;
case DebugAction.LevelAvailability when interactions != null:
interactions.Inventory.ApplyLevelAvailability(level!.Code); debugMenu.Message = "SOURCE LEVEL AVAILABILITY APPLIED"; break;
case DebugAction.InputOrder when simulation != null:
simulation.InputAfterPlayerUpdate = !simulation.InputAfterPlayerUpdate;
debugMenu.Message = "DEBUG INPUT ORDER TOGGLED; NEW LEVEL RESTORES SOURCE POLICY"; break;
case DebugAction.ApplyJetpackState when interactions != null:
interactions.Inventory.SetState(0, 3, debugMenu.JetpackState); debugMenu.Message = "JET PACK AVAILABILITY APPLIED"; break;
case DebugAction.CameraObstruction when debugCameraRay != null:
debugCameraRay.Enabled = !debugCameraRay.Enabled; debugMenu.Message = "STATIC CAMERA QUERY TOGGLED"; break;
case DebugAction.MuteMusic or DebugAction.MuteSpeech or DebugAction.MuteEffects when sceneAudio != null:
sceneAudio.SetDebugMute(sceneAudio.MusicMuted ^ (action == DebugAction.MuteMusic),
sceneAudio.SpeechMuted ^ (action == DebugAction.MuteSpeech), sceneAudio.EffectsMuted ^ (action == DebugAction.MuteEffects));
debugMenu.Message = "AUDIO MUTE UPDATED; PLAYBACK CLOCK CONTINUES"; break;
case DebugAction.RestartMusic when sceneAudio != null:
sceneAudio.RestartMusic(); debugMenu.Message = "SELECTED MUSIC RESTARTED"; break;
case DebugAction.StopEffects when sceneAudio != null:
sceneAudio.StopEffects(); debugMenu.Message = "ALL EFFECTS AND LOOPS STOPPED"; break;
case DebugAction.Practice when interactions != null:
practice.Show(0); debugMenu.Close(); break;
case DebugAction.SaveCheckpoint when interactions != null:
try
{
var debugSnapshot = interactions.Snapshot() with { LevelCode = level!.Code, StartPoint = originalStart!.Tag!, StoredVector = returnRoot };
var temporaryCheckpoint = debugCheckpointFile + ".tmp";
Directory.CreateDirectory(Path.GetDirectoryName(debugCheckpointFile)!);
File.WriteAllBytes(temporaryCheckpoint, debugSnapshot.Encode()); File.Move(temporaryCheckpoint, debugCheckpointFile, true);
debugMenu.Message = "SAVED LEVEL/START/PROGRESSION; NOT LIVE POSITION";
}
catch (Exception error) when (error is IOException or UnauthorizedAccessException)
{ debugMenu.Message = "CHECKPOINT WRITE FAILED: " + error.Message; }
break;
case DebugAction.LoadCheckpoint when interactions != null:
try
{
var debugSave = OriginalSave.Load(debugCheckpointFile);
var savedScene = debugMenu.FindScene(debugSave.LevelCode);
if (savedScene == null) { debugMenu.Message = "CHECKPOINT LEVEL GEOMETRY UNAVAILABLE"; break; }
var savedStart = GamLevel.Load(AssetPath.Resolve(root, "gam/" + savedScene.LevelFile))
.FindStart(debugSave.StartPoint.Equals("none", StringComparison.OrdinalIgnoreCase) ? null : debugSave.StartPoint);
if (savedStart == null) { debugMenu.Message = "CHECKPOINT START UNAVAILABLE"; break; }
var savedWorld = Mesh.LoadSceneJson(AssetPath.Resolve(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, "..")),
Path.GetFileNameWithoutExtension(savedScene.LevelFile) + "/scene.json"));
if (new SceneCollision(savedWorld).GroundHeight(savedStart.Position, 2500) == null)
{ debugMenu.Message = "CHECKPOINT START HAS NO SUPPORTED FLOOR"; break; }
debugCheckpointToLoad = debugSave;
RequestTransition(new(savedScene.LevelFile, savedStart.Tag!, 0, -1)); debugMenu.Close();
}
catch (Exception error) when (error is IOException or UnauthorizedAccessException or InvalidDataException)
{ debugMenu.Message = "CHECKPOINT LOAD FAILED: " + error.Message; }
break;
case DebugAction.None: break;
case DebugAction.CameraObstruction: debugMenu.Message = "SOURCE STATIC QUERY UNAVAILABLE IN THIS SCENE"; break;
case DebugAction.MuteMusic or DebugAction.MuteSpeech or DebugAction.MuteEffects or DebugAction.RestartMusic or DebugAction.StopEffects:
debugMenu.Message = "SCENE AUDIO UNAVAILABLE (--MUTE / HEADLESS)"; break;
default: debugMenu.Message = "ACTION REQUIRES PLAY MODE"; break;
}
}
void SyncDebugPlayer()
{
if (simulation == null) return;
characterModel = simulation.Model;
if (level?.Player?.Tag is { } tag)
director?.SyncActor(tag, simulation.ActorRoot, new Vector3(0, simulation.Yaw, 0));
}
Vector2 Pointer()
{
Sdl.SDL_GetMouseState(out var x, out var y);
@@ -657,6 +754,12 @@ internal static class Program
if (e.Repeat == 0) diagnostics.Enabled = !diagnostics.Enabled;
continue;
}
if (e.Type == Sdl.KeyDown && e.Scancode == DebugMenu.NoclipKey)
{
debugCapturedKeys.Add(e.Scancode);
if (e.Repeat == 0) { DebugCommand(DebugAction.Noclip); DebugInputBoundary(); }
continue;
}
if (e.Type == Sdl.KeyDown && e.Scancode == DebugMenu.ToggleKey)
{
debugCapturedKeys.Add(e.Scancode);
@@ -693,7 +796,8 @@ internal static class Program
if (walkSmoke) sawWalkKeys |= e.Scancode == 82 ? 1 : e.Scancode == 79 ? 2 : e.Scancode == jumpScancode ? 4 : 0;
if (jetpackSmoke) sawJetpackKeys |= e.Scancode == 82 ? 1 : e.Scancode == 81 ? 2 : e.Scancode == 80 ? 4 : e.Scancode == jumpScancode ? 8 : 0;
if (smoke && e.Scancode == 79) sawKey = true;
if (e.Scancode is 41 or 44 && e.Repeat == 0 && director is { Controlled: false })
if (e.Scancode is 41 or 44 && e.Repeat == 0 && director is { Controlled: false }
&& (e.Scancode != 44 || simulation?.Noclip != true))
{ sceneAudio?.StopSpeech(); director.Skip(); keys.Clear(); mouseJump = false; }
else if (e.Scancode == 41) running = false;
if (inspecting && e.Repeat == 0 && animations?.Select(e.Scancode) == true)
@@ -722,17 +826,19 @@ internal static class Program
var dt = (float)Math.Min(elapsed, 0.1);
last = now;
if (debugMenu.Open) animationStarted += elapsed;
if (simulation != null && !debugMenu.Open && !inspecting && !practice.Active && (active || headless || walkSmoke || jetpackSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke))
if (simulation != null && !debugMenu.Open && !inspecting && !practice.Active && (active || headless || walkSmoke || jetpackSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke))
{
var steps = headless || walkSmoke || jetpackSmoke || practiceWindowSmoke || carlSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke ? 1 : stepClock.Advance(elapsed);
var steps = headless || walkSmoke || jetpackSmoke || practiceWindowSmoke || carlSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke ? 1 : stepClock.Advance(elapsed);
for (var step = 0; step < steps; step++)
{
var input = carlSmoke ? new PlayerInput(true, false, true, false, true)
: jetpackSmoke && headless ? LabSimulation.JetpackSmokeInput(simulation.Steps)
: walkSmoke && headless ? LabSimulation.SmokeInput(simulation.Steps) : new PlayerInput(
keys.Contains(82), keys.Contains(81), keys.Contains(80), keys.Contains(79),
mouseJump || keys.Contains(225) || keys.Contains(229) || keys.Contains(73) || keys.Contains(98));
if (director?.Controlled != false)
keys.Contains(82) || simulation.Noclip && keys.Contains(26), keys.Contains(81) || simulation.Noclip && keys.Contains(22), keys.Contains(80), keys.Contains(79),
mouseJump || keys.Contains(225) || keys.Contains(229) || keys.Contains(73) || keys.Contains(98),
keys.Contains(44) || keys.Contains(8), keys.Contains(224) || keys.Contains(228) || keys.Contains(20),
keys.Contains(4), keys.Contains(7), keys.Contains(225) || keys.Contains(229));
if (director?.Controlled != false || simulation.Noclip)
{
var before = simulation.Position;
var powered = simulation.JetpackEffectVisible && !simulation.Grounded;
@@ -744,17 +850,20 @@ internal static class Program
}
interactions?.UpdateEnergy(simulation.Energy);
director?.SyncActor(level!.Player!.Tag!, simulation.ActorRoot, new Vector3(0, simulation.Yaw, 0));
director?.Touch(level!.Player!.Tag!, simulation.ActorRoot);
interactions?.Update(simulation.ActorRoot, simulation.InteractionRadius);
if (!simulation.Noclip)
{
director?.Touch(level!.Player!.Tag!, simulation.ActorRoot);
interactions?.Update(simulation.ActorRoot, simulation.InteractionRadius);
}
if (practice.Active) { keys.Clear(); mouseJump = false; stepClock.Reset(); break; }
mechanisms?.Update(simulation.ActorRoot, simulation.InteractionRadius);
if (!simulation.Noclip) mechanisms?.Update(simulation.ActorRoot, simulation.InteractionRadius);
}
mechanisms?.Step(FixedStepClock.Step);
foreach (var patrol in patrols.Values) patrol.Step(FixedStepClock.Step);
director?.Step(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 }
var switched = director is { Controlled: false } && !simulation.Noclip
? animations!.SelectAction(director.FindActor(level!.Player!.Tag!)!.Animation)
: animations!.SelectPose(simulation.Pose);
if (switched) poseTime = 0;
@@ -786,7 +895,7 @@ internal static class Program
view = Matrix4x4.CreateLookAtLeftHanded(simulation.CameraEye, simulation.CameraTarget, Vector3.UnitY);
renderEye = simulation.CameraEye; renderTarget = simulation.CameraTarget;
}
if (!inspecting && director?.CameraEye is { } storyEye && director.CameraTarget is { } storyTarget)
if (!inspecting && simulation?.Noclip != true && director?.CameraEye is { } storyEye && director.CameraTarget is { } storyTarget)
{
view = Matrix4x4.CreateLookAtLeftHanded(storyEye, storyTarget, Vector3.UnitY);
renderEye = storyEye; renderTarget = storyTarget;
@@ -800,7 +909,7 @@ internal static class Program
hud?.Update(mesh, interactions!.CurrentObjective, level!.Code == "LV1B" && objectivePanel!.PadVisible,
practice.Active, objectivePanel!.YOffset, objectivePanel.ContentVisible, renderer.Width, renderer.Height);
var gameplayProjection = originalCamera || simulation != null && !inspecting;
var cameraMode = !inspecting && director?.CameraEye != null ? "CUTSCENE"
var cameraMode = simulation?.Noclip == true && !inspecting ? "NOCLIP" : !inspecting && director?.CameraEye != null ? "CUTSCENE"
: simulation != null && !inspecting ? "GAMEPLAY" : originalCamera ? "STRT" : "ORBIT";
var debugStatus = new DebugStatus(level?.Code ?? "PREVIEW", originalStart?.Tag ?? "NONE",
simulation?.ActorRoot ?? Vector3.Zero, simulation?.Yaw ?? 0, simulation?.Speed ?? 0,
@@ -808,7 +917,21 @@ internal static class Program
storyTasks?.Get("SCENE") ?? 0, director?.CurrentTag ?? "NONE", director?.Controlled ?? false,
(director?.Issues.Count ?? 0) + (interactions?.Unsupported.Count ?? 0) + (mechanisms?.Unsupported.Count ?? 0),
gameplayProjection ? SceneProjection.FarPlane(level?.Code) : radius * 20,
inspecting, director?.DebugForceControl ?? false, diagnostics.Enabled, cameraMode);
inspecting, director?.DebugForceControl ?? false, diagnostics.Enabled, cameraMode, new DebugSystems
{
Noclip = simulation?.Noclip ?? false, NoclipSpeed = simulation?.NoclipSpeed ?? 600,
Velocity = simulation?.Velocity ?? Vector3.Zero, PendingImpulse = simulation?.PendingImpulse ?? Vector3.Zero,
MovementMode = simulation?.MovementMode ?? 0, InputAfterPlayer = simulation?.InputAfterPlayerUpdate ?? false,
JumpState = simulation?.JumpState ?? 0, JumpHold = simulation?.JumpHoldSeconds ?? 0,
BurnRemaining = simulation?.JetpackRemaining ?? 0, JetpackAvailability = interactions?.Inventory.State(0, 3) ?? 0,
Objective = interactions?.CurrentObjective ?? 0, ObjectiveTime = objectivePanel?.Elapsed ?? 0,
CameraObstruction = debugCameraRay?.Enabled, CameraPolygons = debugCameraRay?.PolygonCount ?? 0,
CameraWallPolygons = debugCameraRay?.WallPolygonCount ?? 0, CameraTests = debugCameraRay?.LastTriangleTests ?? 0,
AudioAvailable = sceneAudio != null, MusicMuted = sceneAudio?.MusicMuted ?? false,
SpeechMuted = sceneAudio?.SpeechMuted ?? false, EffectsMuted = sceneAudio?.EffectsMuted ?? false,
MusicBytes = sceneAudio?.QueuedMusicBytes ?? 0, SpeechBytes = sceneAudio?.QueuedSpeechBytes ?? 0,
EffectBytes = sceneAudio?.QueuedEffectBytes ?? 0
});
var debugView = debugMenu.View(debugStatus);
var liveDebugLines = diagnostics.Lines(debugStatus, new(simulation?.Velocity ?? Vector3.Zero,
simulation?.TurnRate ?? 0, simulation?.Pose.ToString() ?? "NONE", simulation?.Steps ?? 0,
@@ -837,6 +960,51 @@ internal static class Program
count++;
audio?.Pump();
sceneAudio?.Pump();
if (toolsSmoke)
{
void PushTool(uint key, bool down = true, bool repeat = false)
{
var e = new Sdl.Event { Type = down ? Sdl.KeyDown : Sdl.KeyUp, Scancode = key,
Down = down ? (byte)1 : (byte)0, Repeat = repeat ? (byte)1 : (byte)0 };
if (!Sdl.SDL_PushEvent(ref e)) throw new InvalidOperationException(Sdl.Error);
}
void TapTool(uint key) { PushTool(key); PushTool(key, false); }
if (count == 1) { toolsEntry = simulation!.ActorRoot; TapTool(DebugMenu.ToggleKey); }
if (count == 2) { TapTool(43); TapTool(40); }
if (count == 3)
{
toolsPaused = debugMenu.Open && debugMenu.Page == 1 && simulation!.Noclip
&& simulation.ActorRoot == toolsEntry && sceneAudio?.Paused != false;
director!.Trigger("neutron1a"); // Flight must work without changing scripted control ownership.
TapTool(DebugMenu.ToggleKey); PushTool(26); PushTool(44);
}
if (count == 7)
{
toolsMoved = simulation!.Noclip && simulation.ActorRoot.Y > toolsEntry.Y + 20
&& Vector3.Distance(simulation.ActorRoot, toolsEntry) > 30 && simulation.Jumps == 0
&& director is { Controlled: false, Playing: true, CurrentTag: "neutron1a" };
PushTool(DebugMenu.NoclipKey); PushTool(DebugMenu.NoclipKey, repeat: true); PushTool(DebugMenu.NoclipKey, false);
}
if (count == 8)
{
toolsStopped = !simulation!.Noclip && simulation.PendingImpulse == Vector3.Zero && simulation.Speed == 0 && simulation.Jumps == 0;
PushTool(26, false); PushTool(44, false); TapTool(DebugMenu.ToggleKey);
}
if (count == 9) TapTool(43);
if (count == 10)
{
TapTool(40); TapTool(81); TapTool(40); // Camera query and music mute.
for (var i = 0; i < 5; i++) TapTool(81);
TapTool(40); // Save progression.
}
if (count == 11)
{
toolsSystems = debugMenu.Page == 2 && debugCameraRay?.Enabled == false && sceneAudio?.MusicMuted == true;
toolsSaved = File.Exists(debugCheckpointFile) && OriginalSave.Load(debugCheckpointFile).Tasks.Any(t => t.Name == "SCENE" && t.State == 30);
storyTasks!.SetExisting("SCENE", 35);
TapTool(81); TapTool(40); // Load the saved progression and rebuild through normal continuation.
}
}
if (diagnosticsSmoke)
{
void Push(uint key, bool down = true, bool repeat = false)
@@ -1003,6 +1171,13 @@ internal static class Program
Console.WriteLine($"Debug SDL check: paused={debugPauseObserved}, actions={debugActionsObserved}, Escape/input capture={debugEscapeObserved}, resumed={debugResumeObserved}, forced movement during MCA={debugForceObserved}, resize800x600={didResize}.");
if (!debugPauseObserved || !debugActionsObserved || !debugEscapeObserved || !debugResumeObserved || !debugForceObserved || !didResize) return 2;
}
if (toolsSmoke)
{
var loaded = debugCheckpointToLoad?.Tasks.Any(t => t.Name == "SCENE" && t.State == 30) == true
&& transitionRequest?.LevelFile.Equals("level1b.gam", StringComparison.OrdinalIgnoreCase) == true;
Console.WriteLine($"Debug tools SDL check: paused={toolsPaused}, flight={toolsMoved}, stop/input capture={toolsStopped}, systems={toolsSystems}, saved={toolsSaved}, loaded={loaded}.");
if (!toolsPaused || !toolsMoved || !toolsStopped || !toolsSystems || !toolsSaved || !loaded) return 2;
}
if (carlSmoke)
{
var locked = director is { Controlled: false, Playing: true, CurrentTag: "neutron1a" } && simulation!.Steps == 0;
@@ -1055,14 +1230,15 @@ internal static class Program
for (var i = 0; i < args.Length; i++)
{
if (args[i] is "--smoke-transition" or "--smoke-lab-route" or "--smoke-practice-prompt" or "--smoke-practice-transition"
or "--debug-menu" or "--smoke-debug-menu" or "--smoke-debug-overlay") continue;
if (args[i] is "--scene" or "--level" or "--start" or "--load-save" or "--story-time") { i++; continue; }
or "--debug-menu" or "--smoke-debug-menu" or "--smoke-debug-overlay" or "--smoke-debug-tools" or "--noclip") continue;
if (args[i] is "--scene" or "--level" or "--start" or "--load-save" or "--story-time" or "--debug-page") { i++; continue; }
nextArgs.Add(args[i]);
}
nextArgs.AddRange(["--scene", nextScene, "--level", "gam/" + transitionRequest.LevelFile,
"--start", transitionRequest.StartPoint]);
continuation = new(nextArgs.ToArray(), interactions!.Snapshot() with {
StartPoint = transitionRequest.StartPoint, StoredVector = returnRoot }, transitionRequest.Returning);
if (toolsSmoke) nextArgs.AddRange(["--frames", "2"]);
continuation = new(nextArgs.ToArray(), (debugCheckpointToLoad ?? interactions!.Snapshot()) with {
StartPoint = transitionRequest.StartPoint, StoredVector = debugCheckpointToLoad?.StoredVector ?? returnRoot }, transitionRequest.Returning);
Console.WriteLine($"Loading original destination: {transitionRequest.LevelFile}, start={transitionRequest.StartPoint}; fade behavior remains unreconstructed.");
}
if (walkSmoke && !simulation!.SmokePassed) return 2;