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

+7 -2
View File
@@ -43,12 +43,17 @@ The lab camera sequence stops background music and DEFAULT restarts it when
control returns, including after skipping.
**F1** opens the debug menu and pauses gameplay and audio. Use Up/Down to select,
Left/Right to change values, Enter to apply, and F1/Escape to close. It includes
Left/Right to change values, Enter to apply, Tab to switch General/Player/Systems
pages, and F1/Escape to close. It includes
live diagnostics, camera switching, cutscene skip, energy refill, jet-pack grant,
SCENE task editing, all 33 prepared levels and their original startpoints, and
reset. Page Up/Down changes the staged SCENE value by 10.
The Force Control toggle keeps Jimmy controllable during scripted control locks. See
[debug menu controls](docs/debug-menu.md).
[debug menu controls](docs/debug-menu.md). Player/System pages add movement and
jetpack state controls, camera obstruction, audio category mutes, objective/practice
controls and checkpoint save/load. **F3** toggles noclip: WASD moves/strafe, arrows
move/turn, Space/E rises, Ctrl/Q descends and Shift triples flight speed. Noclip
bypasses collision and contact triggers; reset or a new level disables it.
**F2** toggles a compact live debug overlay without pausing play. It shows frame
timing, position/velocity, movement, control/force state, tasks, camera/clipping
+10
View File
@@ -3,6 +3,16 @@
Compilation, native runtime, original behavior and full feature completion are
separate evidence categories. **The game is not fully reconstructed/playable yet.**
Debug expansion (2026-10-25): full scripts/test.sh passes, with70 Python checks,
21 movement groups, debug page/overlay groups, real SDL dummy pause/mute timing,
remaining managed/GPU routes and539 unchanged original hashes. Native Linux
GTX1070 at1920x1080 passes F1/Tab/F3, flight during a source cutscene, input capture,
camera/audio controls, checkpoint save/load and same-window rebuild. Enabled Vulkan
validation reports zero errors. Headless Player1920x1080 and Systems2560x1080
screenshots fit; see artifacts/debug-expansion/. SDL_SetAudioStreamGain is present
in the packaged Windows SDL3 DLL export table. Cross-build/export evidence does
not add native Windows runtime or original-game behavior verification.
Latest implementation continuation: controlled player phase ordering, route static
camera query and PostLoad gadget availability pass the full `scripts/test.sh`.
Evidence: artifacts/implementation/integration-final.log;70 Python regressions,
+70 -2
View File
@@ -9,8 +9,10 @@ audio. Closing resumes the previous mode. No new assets or dependencies are need
| --- | --- |
| F1 | Open/close |
| F2 | Toggle live diagnostics without pausing |
| F3 | Toggle noclip |
| Tab | Cycle General, Player and Systems pages |
| Up/Down | Select a row |
| Left/Right | Change selected level, startpoint or staged SCENE task value |
| Left/Right | Change selected level, startpoint, staged SCENE, flight speed or jetpack state |
| Page Up/Down | Change staged SCENE value by10 |
| Enter / numpad Enter | Apply the selected action |
| Escape | Close the menu |
@@ -22,6 +24,63 @@ the existing task system and its callbacks. Inventory/energy/task actions affect
current runtime state and its normal checkpoint snapshots; they do not write files
by themselves. Debug tools do not imply reconstructed progression or full gameplay.
## Player and Systems pages
The General page retains the existing actions. Player adds noclip, staged flight
speeds300/600/1200/2400 (Enter applies), clear motion/queued jump, reopen objective,
return to noclip entry, apply source level gadget availability, toggle input after
player, staged jetpack states0/1/4 with a separate Apply row, and energy refill.
State0 means unowned,1 enabled and4 disabled by the level. These controls expose
the current implementation; they are not proof of complete original behavior.
Systems adds the route static camera query toggle, independent music/speech/effects
mutes, restart selected music, stop all effects/loops, checkpoint save/load and the
practice prompt. Camera query control is available on LV1B/VR04/LEV1; elsewhere
it reports unavailable. Audio actions require scene audio (not headless/--mute).
Muting sets stream gain while playback clocks continue; new streams inherit mute.
F1 still pauses all stream clocks. Audio mute preferences reset with the scene.
Input-order override is for comparison; a new scene restores the continuation policy.
The practice action opens the existing prompt and closes F1.
Player diagnostics include velocity, pending impulse, movement mode/input order,
jump/hold/burst timers, jetpack state and objective time. Systems shows camera
polygon/query counts, category mute flags and queued audio bytes. Staged values
are separate from live values. `--debug-page general|player|systems` opens a page.
## Noclip (F3)
A modern investigation mode, enabled from F3 or Player/Noclip (`--noclip` at startup).
W/S or Up/Down move forward/back; A/D strafe; Left/Right turn. Space/E rises,
Ctrl/Q descends, Shift triples speed. Diagonal motion is normalized. Release stops
flight immediately. Gravity, body collision, camera obstruction, jetpack consumption
and contact-triggered script/pickup/mechanism/level actions are bypassed. Script,
actor and mechanism clocks still run; unrelated scripted transitions can still occur.
Flight uses the player camera during cutscenes without changing authored control
ownership. Space rises without skipping a cutscene while flying; Escape keeps its
normal skip action. F1 pauses flight. Toggle boundaries clear queued motion and
capture held input until release, so Space/Shift cannot become a jump on exit.
Reset and level changes clear noclip; it is never written into TSK saves.
Enabling remembers position/yaw. Return Noclip Entry restores them and clears
motion. Disabling retains the new position if the current static capsule adapter
accepts it, otherwise returns to entry. This checks static triangle proximity, not
full solid containment or moving objects; use Return Entry or reset if needed.
Normal gravity/collision resumes when disabled.
## Debug checkpoint
Save writes `debug-checkpoint.tsk` beside the executable using the existing original
TSK encoder and a temporary file replacement. It captures tasks, items, energy,
score, level/start and the existing RETURN departure vector; it does **not** capture
live Jimmy position, cutscene time, physics or debug preferences. Save errors appear
in the menu. Load validates the available prepared scene/start/support and uses the
normal scene rebuild, preserving the application window and renderer. Authored
start actions run normally. A load/reset clears force-control and noclip.
These are explicitly requested modern tools, a scoped exception to the gameplay
feature pause; no original debug-menu or noclip algorithm is claimed.
Force Control toggles a persistent debug override. Set it to TRUE and close the
menu to let Jimmy move even while a cutscene or scripted control lock is active.
Subsequent camera shots cannot clear the override. The cutscene, camera and audio
@@ -72,7 +131,7 @@ without changing their pause state. Visibility persists through resets and scene
loads within the process; it is not stored in TSK. `--debug-overlay` starts enabled.
Twelve bounded rows show measured FPS/frame milliseconds; level/start; root XYZ;
velocity XYZ; yaw/speed/turn rate; ground/pose/energy; control/force/pause; SCENE/
velocity XYZ; yaw/speed/turn rate; ground/pose/energy; control/force/pause/noclip; SCENE/
score/jetpack state and burst timer; actual camera mode/far plane; cutscene/shot/
blocked state; movement counters; and reported issue/Vulkan-error/frame counts.
STRT, orbit, gameplay and cutscene modes use the actual rendered view selection;
@@ -110,3 +169,12 @@ Windows verification. Full regression and package status is in progress.md.
Debug text scales uniformly with resolution. F1 uses a centered authored canvas
on widescreen; F2 stays top-left. The window/device survive level changes. See
presentation-and-ui.md for lifecycle, ultrawide and high-DPI pointer checks.
Expansion verification (2026-10-25): full `scripts/test.sh` passes, including70
Python checks,21 movement groups, debug pages and real SDL dummy pause/mute clocks;
539 originals remain unchanged. Native Linux GTX1070 at1920x1080 passes
`--smoke-debug-tools`: F1/Tab, cutscene flight without force-control, F3 repeats,
held-input capture, camera/audio actions, TSK save/load and retained window.
Validation enabled, zero errors. Headless Player1920x1080 and Systems2560x1080
captures fit the existing uniform canvas. Logs/captures: artifacts/debug-expansion/.
No new native Windows runtime verification is claimed.
+10
View File
@@ -128,3 +128,13 @@
group0 gadgets4→1, then disables owned1→4 in VR01..08. Preserve unknown states,
item8 and group1. This is availability, not acquisition or save normalization;
snapshots/constructors retain raw wire data. VR04's source jetpack bypass remains.
28. **Expose implemented systems through modern debug tools.** The user explicitly
requests expansion and noclip during the gameplay feature pause. Preserve
General-page controls; add Player/Systems pages and F3 flight. Keep authored
control ownership separate from flight and bypass player contact triggers.
Clear pending motion/held input at toggles, retain an entry escape position,
and reset transient overrides on scene rebuild. Mute by stream gain so clocks
continue. Debug checkpoint uses the existing TSK/start progression contract,
never pretends to save live physics/cutscene state. These are investigation
features with port verification, not recovered original behavior.
+19
View File
@@ -1,5 +1,24 @@
# Progress — 2026-10-25
## Requested debug expansion
F1 now has General/Player/Systems pages (Tab), preserving existing General actions.
Added F3 noclip with vertical/strafe/boost controls, entry restoration and static
exit-overlap fallback; queued motion and held inputs clear at toggles. Flight
bypasses collision/camera obstruction and contacts without changing script control
ownership. Added movement/input-order/availability, objective/practice, camera
query, category audio mutes and original-format checkpoint actions/diagnostics.
Mutes use SDL stream gain so playback clocks continue. Scene/reset lifetimes and
checkpoint limits are documented in debug-menu.md. This user-requested debug work
is a scoped exception; evidence-led gameplay continuation remains the direction.
Full scripts/test.sh passes:70 Python,21 movement groups, remaining managed/GPU/
SDL checks and539 unchanged originals. Native Linux GTX1070 debug-tools smoke
passes at1920x1080 with zero enabled Vulkan validation errors, including flight
during a source cutscene without force control and same-window checkpoint reload.
Widescreen/ultrawide captures fit. Logs: artifacts/debug-expansion/. Windows SDL3
exports the gain API; native Windows runtime remains unverified for these changes.
## Evidence-led implementation continuation
Old level-game removal is resolved by `checkpoint/level-game-lifetime.md`: class
+4
View File
@@ -40,6 +40,10 @@ compile, runtime and original-fidelity verification are separate.
- [x] Uniform widescreen game/debug UI with anchors and matched native pointer
mapping, strict boundaries and high-DPI rounding checks.
- [x] Requested F1 General/Player/Systems pages, F3 noclip with cutscene flight,
motion/input capture, entry restoration, movement/camera/audio/UI/TSK controls;
full suite plus native Linux1920x1080 SDL regression pass. See debug-menu.md.
## Immediate continuation
**Direction changed: pause feature expansion for the architecture checkpoint.**
+8 -1
View File
@@ -46,9 +46,16 @@ to save GPU readback. A Vulkan 1.3 graphics driver/loader is required.
This package includes the .NET runtime, SDL3, shaders and local asset copies.
The default opens the controllable original lab. Arrows walk/backpedal/turn;
Shift, Insert, numpad 0 or right mouse jump. R resets to the original start area;
F1 opens debug tools: arrows navigate/change, Enter applies, F1/Escape closes.
F1 opens debug tools: arrows navigate/change, Enter applies, Tab switches pages,
F1/Escape closes. General/Player/Systems pages cover implemented runtime controls.
The menu pauses gameplay/audio and provides diagnostics, camera/cutscene controls,
energy/jetpack/task changes, level/start selection, reset and Force Control toggle.
Player/Systems add input ordering, jetpack availability, objective/practice, camera
obstruction, audio category mutes and debug checkpoint save/load. Checkpoints save
level/start/progression, not live position; see docs/debug-menu.md.
F3 toggles noclip: WASD moves/strafe, arrows move/turn, Space/E up, Ctrl/Q down,
Shift boosts speed. Noclip bypasses collision and contact triggers. Reset/new level
disables it; Return Noclip Entry restores the position where it was enabled.
F2 toggles compact live diagnostics without pausing; --debug-overlay enables it
at startup. F1's Live Overlay toggle controls the same session preference.
Level changes retain the window, fullscreen and size. HUD/debug UI scales uniformly
+3
View File
@@ -36,6 +36,8 @@ dotnet run --no-build -- --headless --story --smoke-practice-prompt --screenshot
dotnet run --no-build -- --headless --story --smoke-practice-transition
dotnet run --no-build -- --headless --smoke-practice-return --screenshot artifacts/test-practice-return.ppm
dotnet run --no-build -- --headless --debug-menu --screenshot artifacts/test-debug-menu.ppm
dotnet run --no-build -- --headless --debug-page player --noclip --width 1920 --height 1080 --screenshot artifacts/test-debug-player.ppm
dotnet run --no-build -- --headless --debug-page systems --width 2560 --height 1080 --screenshot artifacts/test-debug-systems.ppm
dotnet run --no-build -- --headless --debug-overlay --frames 2 --screenshot artifacts/test-debug-overlay.ppm
dotnet run --no-build -- --headless --story --smoke-lab-route
dotnet run --no-build -- --headless --smoke-carl-cutscene --frames 60 --screenshot artifacts/test-carl-cutscene.ppm
@@ -58,6 +60,7 @@ SDL_AUDIODRIVER=dummy dotnet run --no-build -- --scene-audio-smoke artifacts/ext
SDL_AUDIODRIVER=dummy dotnet run --no-build -- --cutscene-audio-smoke artifacts/extracted/level1b/entities/entities.json
python3 tools/recon/inventory.py ../Original --verify docs/original-manifest.json
if [[ "${NEUTRON_WINDOW_TEST:-0}" == 1 ]]; then
dotnet run --no-build -- --smoke-debug-tools
dotnet run --no-build -- --smoke-window-transitions
dotnet run --no-build -- --smoke-debug-overlay --screenshot artifacts/test-live-debug-window.ppm
dotnet run --no-build -- --smoke-debug-menu --screenshot artifacts/test-debug-window.ppm
+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;
+22
View File
@@ -78,6 +78,28 @@ using (var scene = new SceneAudio(new PreparedEntityResources(manifest)))
}
Console.WriteLine("PASS mixer pauses all stream categories and preserves pause across replacement streams");
using (var muted = new SdlAudio(wave, muted: true))
{
var queued = muted.QueuedBytes;
Require(muted.Muted && !muted.Paused, "Muted audio remains running");
Thread.Sleep(200);
Require(muted.QueuedBytes < queued, "Mute must advance transport rather than freeze obsolete speech");
muted.SetMuted(false); Require(!muted.Muted, "Mute toggle restores gain");
}
using (var scene = new SceneAudio(new PreparedEntityResources(manifest)))
{
scene.SetDebugMute(true, true, true); scene.SetPaused(true);
scene.Music("music.omt", 0); scene.Speech("voice.omt", 1); scene.Effect(58);
var queued = Queued(scene);
scene.SetPaused(false);
Require(scene.MusicMuted && scene.SpeechMuted && scene.EffectsMuted, "Menu resume preserves category mute preferences");
Thread.Sleep(200);
var after = Queued(scene);
Require(after.Music < queued.Music && after.Speech < queued.Speech && after.Effects < queued.Effects,
"Muted categories consume audio after menu resume");
}
Console.WriteLine("PASS muted transport advances and category settings survive menu pause/new streams");
var disposed = new SdlAudio(wave, paused: true);
disposed.Dispose(); disposed.Dispose();
try { disposed.SetPaused(false); throw new InvalidOperationException("Expected disposed-state rejection"); }
@@ -50,13 +50,13 @@ try { lines = diagnostics.Lines(status, motion); }
finally { CultureInfo.CurrentCulture = originalCulture; }
Require(lines.Length == 12 && lines.All(l => l.Length <= 58), "Live diagnostics fit the compact overlay bounds");
Require(lines[2].Contains("76.5") && lines[2].Contains("-3.5") && !lines.Any(l => l.Contains("NEG")), "Numeric output is invariant under user culture");
Require(lines[6] == "CTRL T FORCE F PAUSED F", "Control and pause diagnostics use live state");
Require(lines[6] == "CTRL T FORCE F PAUSED F NOCLIP F", "Control, pause and noclip diagnostics use live state");
Require(lines[7].Contains("SCENE 60 SCORE 150 JETPACK 1 7.5S"), "Task, score, ownership and burst countdown are visible together");
var changedStatus = status with { Root = new(40, 50, 60), ForcedControl = true, Inspecting = true, Cutscene = "neutron1a" };
var changedStatus = status with { Root = new(40, 50, 60), ForcedControl = true, Inspecting = true, Cutscene = "neutron1a", Systems = new() { Noclip = true } };
var changedMotion = motion with { Velocity = new(0, 500, 0), Pose = "FLY", Shot = 2, Blocked = true, Paused = true, VulkanErrors = 3 };
var changed = diagnostics.Lines(changedStatus, changedMotion);
Require(changed[2] != lines[2] && changed[3] != lines[3] && changed[5].Contains("FLY"), "Motion and position text changes with every live snapshot");
Require(changed[6] == "CTRL T FORCE T PAUSED T" && changed[8].Contains("ORBIT") && changed[9].Contains("neutron1a SHOT 2 BLOCK T")
Require(changed[6] == "CTRL T FORCE T PAUSED T NOCLIP T" && changed[8].Contains("ORBIT") && changed[9].Contains("neutron1a SHOT 2 BLOCK T")
&& changed[11].Contains("VK ERR 3"), "Force/camera/cutscene/block/Vulkan diagnostics stay independent");
var authoredView = diagnostics.Lines(changedStatus with { CameraMode = "STRT", FarPlane = 5000 }, changedMotion);
Require(authoredView[8] == "CAM STRT FAR 5000.0", "Actual rendered camera/projection can override inferred mode");
+25
View File
@@ -41,6 +41,31 @@ menu.Toggle(65);
Require(menu.SceneTask == 65, "Reopening refreshes live task state");
Console.WriteLine("PASS debug navigation, input repeat, staged tasks, scene/start selection and view");
menu.Key(43);
Require(menu.Page == 1 && menu.Selected == 0 && menu.Key(40) == DebugAction.Noclip, "Tab reaches player tools and noclip");
menu.Key(43, true); Require(menu.Page == 1, "Tab repeat cannot change pages");
menu.Key(81); menu.Key(79);
Require(menu.FlySpeed == 1200 && menu.Key(40) == DebugAction.NoclipSpeed, "Fly speed is bounded and staged");
for (var i = 0; i < 6; i++) menu.Key(81);
menu.Key(79); Require(menu.JetpackState == 4, "Jetpack ownership/availability editor includes disabled state");
menu.Key(81); Require(menu.Key(40) == DebugAction.ApplyJetpackState, "Availability requires explicit apply");
menu.Key(43);
Require(menu.Page == 2 && menu.Selected == 0 && menu.Key(40) == DebugAction.CameraObstruction, "Systems page exposes existing static ray");
for (var i = 0; i < 6; i++) menu.Key(81);
Require(menu.Key(40) == DebugAction.SaveCheckpoint, "Systems checkpoint save action");
menu.Key(81); Require(menu.Key(40) == DebugAction.LoadCheckpoint, "Systems checkpoint load action");
for (var page = 0; page < 3; page++)
{
var pageView = menu.View(new("LV1B", "STARTEXP", Vector3.Zero, 0, 0, true, 20, 0, 30, "NONE", true, 0, 10000, false));
Require(pageView.Lines.Length <= 32 && pageView.SelectedLine >= 0 && pageView.SelectedLine < pageView.Lines.Length,
"Every menu page fits the fixed widescreen-aware overlay");
menu.Key(43);
}
menu.Key(43); // Return from systems to general.
Require(menu.Page == 0, "Tab cycles all three pages");
Require(menu.FindScene("VR04")?.LevelFile == "VR04.gam" && menu.FindScene("MISSING") == null, "Checkpoint resolution only uses prepared catalog");
Console.WriteLine("PASS paged player/systems tools, noclip, staged settings and bounded overlay views");
var original = Path.GetFullPath(args.Length == 1 ? args[0] : "../Original");
var catalog = DebugMenu.AvailableScenes(original, Path.GetFullPath("artifacts/extracted"));
Require(catalog.Length == 33 && catalog.All(s => s.Starts.Length > 0), "Only33 supplied scenes with prepared geometry are offered");
+50
View File
@@ -10,6 +10,7 @@ var tests = new (string Name, Action Check)[]
("clock remainder, stall bound, reset and invalid intervals", ClockBoundaries),
("physics consumes prior motion; fresh versus retained input order", FrameOrdering),
("source camera query origin, hit adjustment, gain and one query per input", CameraQueryConsumer),
("debug noclip bypasses walls/gravity/camera and exits without queued motion", Noclip),
("turn-only speed, forward acceleration/cap and release", SpeedLimits),
("backpedal cap and release", Backpedal),
("yaw sign, forward half-turn and left precedence", Turning),
@@ -124,6 +125,55 @@ static void CameraQueryConsumer()
Check(queries == beforeQueries + 1, "no additional camera obstruction query after interpolation");
}
static void Noclip()
{
var points = new[] {
new Vector3(-1000, 0, -1000), new(-1000, 0, 1000), new(1000, 0, 1000),
new Vector3(-1000, 0, -1000), new(1000, 0, 1000), new(1000, 0, -1000),
new Vector3(-1000, -1000, 50), new(1000, -1000, 50), new(1000, 1000, 50),
new Vector3(-1000, -1000, 50), new(1000, 1000, 50), new(-1000, 1000, 50) };
var mesh = new Mesh(points.Select(p => new MeshVertex(p, Vector2.Zero, Vector3.One)).ToArray(),
Enumerable.Range(0, points.Length).Select(i => (uint)i).ToArray());
var standing = new Mesh([new(new(-20, -20, -20), Vector2.Zero, Vector3.One), new(new(20, 80, 20), Vector2.Zero, Vector3.One)], []);
var collision = new SceneCollision(mesh);
var rayQueries = 0; var dynamicQueries = 0;
var simulation = new LabSimulation(collision, standing, new(0, 25, 0), 0,
(_, _) => { rayQueries++; return null; });
simulation.DynamicRootResolver = (a, b, r) => { dynamicQueries++; return b; };
var entry = simulation.Position;
simulation.Step(new(false, false, false, false, true));
Check(simulation.PendingImpulse.Y > 0, "Fixture has queued motion before noclip");
simulation.SetNoclip(true);
var rays = rayQueries; var bodies = dynamicQueries;
for (var i = 0; i < 10; i++) simulation.Step(new(true, false, false, false, true));
Check(simulation.Position.Z > 90 && !simulation.Grounded && simulation.Jumps == 1,
"Noclip crosses a solid wall without another gameplay jump");
Near(simulation.PendingImpulse.Length(), 0, 0, "Noclip discards queued impulse");
Check(rayQueries == rays && dynamicQueries == bodies && simulation.Energy == 20,
"Noclip bypasses camera/body queries and jetpack drain");
var height = simulation.Position.Y;
for (var i = 0; i < 10; i++) simulation.Step(new(false, false, false, false, false, Rise: true));
Check(simulation.Position.Y > height + 90, "Noclip ascends independently of jumping/gravity");
simulation.Step(new(false, false, false, false, false, Descend: true, Fast: true));
Near(simulation.Velocity.Y, -1800, .001f, "Fast descend uses bounded fly speed multiplier");
var saved = simulation.Position;
simulation.Step(default); NearVector(simulation.Position, saved, .0001f, "Released noclip has no momentum or gravity");
Check(!simulation.SetNoclip(false), "Clear exit retains exploration position");
NearVector(simulation.Position, saved, .0001f, "Disabling in clear space retains position");
Check(simulation.Velocity == Vector3.Zero && simulation.PendingImpulse == Vector3.Zero && simulation.JumpState == 0,
"Disabling clears fly velocity and queued gameplay work");
simulation.Step(default); Check(simulation.Position.Y < saved.Y, "Normal gravity resumes after disabling");
simulation.ReturnToNoclipEntry(); NearVector(simulation.Position, entry, .001f, "Explicit return restores entry");
simulation.Reset(); simulation.SetNoclip(true);
for (var i = 0; i < 5; i++) simulation.Step(new(true, false, false, false, false));
Check(!collision.CanOccupy(simulation.Position, LabSimulation.BodyRadius, simulation.BodyHeight), "Exit fixture intersects wall");
Check(simulation.SetNoclip(false), "Embedded exit restores known entry instead of leaving the capsule trapped");
NearVector(simulation.Position, entry, .001f, "Embedded exit restores cached position");
simulation.SetNoclip(true); simulation.Reset();
Check(!simulation.Noclip && !simulation.HasNoclipEntry, "Reset clears modern noclip state");
}
static void SpeedLimits()
{
var turn = FlatSimulation();