1949 lines
138 KiB
C#
1949 lines
138 KiB
C#
using System.Diagnostics;
|
|
using System.Numerics;
|
|
using GamePort.Assets;
|
|
using GamePort.Application;
|
|
using GamePort.Audio;
|
|
using GamePort.Game;
|
|
using GamePort.Platform;
|
|
using GamePort.Rendering.Vulkan;
|
|
|
|
namespace GamePort;
|
|
|
|
internal static class Program
|
|
{
|
|
public static int Main(string[] args)
|
|
{
|
|
try
|
|
{
|
|
using var observation = args.Contains("--help") || !args.Contains("--fidelity-output") ? null : FidelityObservation.FromArguments(args,
|
|
Directory.GetCurrentDirectory(), AssetPath.FindOriginal(Option(args, "--assets")));
|
|
using var presentation = new RenderSession();
|
|
OriginalSave? carriedSave = null;
|
|
PlayerLevelState? carriedPlayer = null;
|
|
var returning = false;
|
|
var diagnostics = new DebugDiagnostics { Enabled = args.Contains("--debug-overlay") };
|
|
var energy = new PlayerEnergy();
|
|
var grapplerMemory = new GrapplerMemory();
|
|
while (true)
|
|
{
|
|
var result = Run(args, carriedSave, carriedPlayer, returning, diagnostics, presentation, energy, grapplerMemory, observation, out var continuation);
|
|
if (result != 0 || continuation == null) { observation?.Complete(result); return result; }
|
|
args = continuation.Args; carriedSave = continuation.Save; returning = continuation.Returning;
|
|
carriedPlayer = continuation.Player;
|
|
}
|
|
}
|
|
catch (Exception error) { Console.Error.WriteLine(error); return 1; }
|
|
}
|
|
|
|
private static string? Option(string[] args, string name)
|
|
{
|
|
var i = Array.IndexOf(args, name);
|
|
if (i < 0) return null;
|
|
if (i + 1 >= args.Length || args[i + 1].StartsWith("--", StringComparison.Ordinal))
|
|
throw new ArgumentException($"{name} requires a value.");
|
|
return args[i + 1];
|
|
}
|
|
|
|
private sealed record SceneContinuation(string[] Args, OriginalSave Save, bool Returning, PlayerLevelState? Player);
|
|
|
|
private static int Run(string[] args, OriginalSave? carriedSave, PlayerLevelState? carriedPlayer, bool returning, DebugDiagnostics diagnostics,
|
|
RenderSession presentation, PlayerEnergy energy, GrapplerMemory grapplerMemory, FidelityObservation? observation, out SceneContinuation? continuation)
|
|
{
|
|
continuation = null;
|
|
if (args.Contains("--help"))
|
|
{
|
|
Console.WriteLine("""
|
|
Neutron reconstruction investigation runtime
|
|
--assets PATH Original asset directory
|
|
--scene PATH Extracted OMT scene JSON (default: prepared LV1B)
|
|
--model RELPATH Original ASE model (default without scene: ASE/jimstop.ase)
|
|
--texture RELPATH PNG override (default: png/jimycarl.png)
|
|
--level RELPATH Original GAM (default with prepared LV1B: gam/level1b.gam)
|
|
--original-camera Stored GAM start camera and recovered projection
|
|
--animation PATH Prepared Jimmy animation.json; place at GAM startpoint
|
|
--with-player Use prepared jimstop animation in scene
|
|
--walk Play prepared scene with recovered story/interactions
|
|
--inspect Pause simulation and inspect scene/animation
|
|
--smoke-walk Deterministic 240-step movement/jump check
|
|
--story Execute recovered original CAM/MCA/AI trigger sequence
|
|
--story-time N Headless scene-sequence time for GPU comparisons
|
|
--skip-intro Fast-forward original intro actions and restore control
|
|
--start TAG Use a named original STRT checkpoint
|
|
--load-save PATH Resume original TSK task/items/checkpoint state
|
|
--write-save PATH Write checkpoint state as TSK outside asset directory
|
|
--fidelity-output PATH New local diagnostic session directory
|
|
--fidelity-session ID Stable session identity across scene continuations
|
|
--fidelity-case ID Declared comparison case; does not establish acceptance
|
|
--mute Disable scene audio
|
|
--time SECONDS Fixed animation time for comparisons
|
|
--headless Render offscreen through Vulkan
|
|
--screenshot PATH Save actual GPU readback as PPM
|
|
--frames N Exit after N frames (headless default: 1)
|
|
--width N --height N Initial window/offscreen size (default960x720)
|
|
--audio PATH Play recovered WAV; --loop-audio repeats it
|
|
--audio-smoke PATH Verify audio-stream consumption
|
|
--scene-audio-smoke PATH Verify music/speech streams from entities.json
|
|
--cutscene-audio-smoke PATH Verify original cutscene music stop/restart
|
|
--effects-audio-smoke PATH Verify default effect bank and loop lifetime
|
|
--smoke-transition Headless VR01 RETURN / renderer-recreation check
|
|
--smoke-lab-route Headless source lab contact route / next-scene rebuild
|
|
--smoke-practice-prompt Headless original jet pack practice prompt
|
|
--smoke-practice-transition Headless lab-to-VR04 practice transition
|
|
--smoke-practice-return Headless lab/VR04/RETURN root and intro-suppression check
|
|
--smoke-practice-window SDL practice pause/dismiss/resize check (12 frames)
|
|
--smoke-jetpack 300-step powered steering/jump check in VR04
|
|
--smoke-shrink-ray Fire at an actual VR04 soldier; explicit player-placement fixture
|
|
--smoke-invisible Accelerated recharge/activation/flash/expiry/unequip fixture in VR03
|
|
--smoke-baseball VR07 aim/release/flight/target/respawn fixture
|
|
--smoke-scooter VR05 / outside summon-drive-cleanup replay
|
|
--smoke-grappler VR08 attach/reel/swing/cleanup fixture
|
|
--smoke-rocketship VR02 flight/turn/roll/control fixture
|
|
--smoke-bubble VR01 expand/throttle/bounce/cleanup/fade input fixture
|
|
--gadget-menu Render original gadget panel (--skip-intro); fixture owns item3
|
|
--smoke-gadget-menu SDL menu input/pause/selection/practice/Return check (24 frames)
|
|
--smoke-jump-key NAME Replay using shift/right-shift/insert/keypad0/right-mouse
|
|
--smoke-carl-cutscene Verify input stays locked during the lab conversation
|
|
--smoke-control-phases Airborne cutscene body/fire and restoration fixture
|
|
--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
|
|
--smoke-window-transitions Persistent window/renderer and widescreen UI check
|
|
--verify-assets Decode all original PNG/ASE files
|
|
--smoke-window Test keyboard event/resize (requires --frames 6 or more)
|
|
--no-validation Disable development validation
|
|
Walk: arrows move/turn; Shift, Insert or right mouse jump; R reset.
|
|
F1 debug menu. F2 live diagnostics. C inspect / chase camera. F11 fullscreen, Escape quit.
|
|
Inspector: arrows/WASD orbit, +/- zoom,
|
|
F11 fullscreen, Escape quit. Animation preview: 1 idle, 2 run, 3 jump, 4 scratch.
|
|
Collision/pivot/cadence and animation timing are provisional. Full gameplay remains incomplete.
|
|
""");
|
|
return 0;
|
|
}
|
|
var root = AssetPath.FindOriginal(Option(args, "--assets"));
|
|
if (args.Contains("--smoke-window-transitions"))
|
|
{
|
|
var preparedCandidates = new List<string>();
|
|
if (Option(args, "--scene") is { } explicitScene)
|
|
preparedCandidates.Add(Path.GetFullPath(Path.Combine(Path.GetDirectoryName(explicitScene)!, "..")));
|
|
preparedCandidates.AddRange([Path.Combine(AppContext.BaseDirectory, "scenes"), "artifacts/extracted"]);
|
|
var prepared = preparedCandidates
|
|
.FirstOrDefault(p => File.Exists(Path.Combine(p, "ui/ui.json")))
|
|
?? throw new DirectoryNotFoundException("Prepare scene/UI assets before window transition check");
|
|
var output = Option(args, "--screenshot") is { } capture
|
|
? Path.Combine(Path.GetDirectoryName(Path.GetFullPath(capture))!, "window-transitions") : "artifacts/window-transitions";
|
|
return WindowTransitionSmoke.Run(presentation, root, Path.GetFullPath(prepared), output, !args.Contains("--no-validation"));
|
|
}
|
|
var saveOutput = Option(args, "--write-save");
|
|
if (saveOutput != null)
|
|
{
|
|
saveOutput = Path.GetFullPath(saveOutput);
|
|
if (saveOutput.StartsWith(Path.GetFullPath(root) + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase))
|
|
throw new ArgumentException("Save output must be outside original asset directory");
|
|
for (var parent = new DirectoryInfo(Path.GetDirectoryName(saveOutput)!); parent != null; parent = parent.Parent)
|
|
if (parent.Exists && parent.LinkTarget != null) throw new ArgumentException("Save output directory must not redirect through a symbolic link");
|
|
}
|
|
if (args.Contains("--verify-assets")) return VerifyAssets(root);
|
|
if (Option(args, "--cutscene-audio-smoke") is { } cutsceneManifest)
|
|
{
|
|
var bank = new PreparedEntityResources(cutsceneManifest);
|
|
var cutsceneLevel = GamLevel.Load(AssetPath.Resolve(root, "gam/level1b.gam"));
|
|
var cutsceneSave = OriginalSave.Load(AssetPath.Resolve(root, "NewGame.tsk"));
|
|
var cutscene = new SceneDirector(cutsceneLevel, new TaskStates(cutsceneSave.Tasks), bank.Duration);
|
|
using var mixer = new SceneAudio(bank);
|
|
cutscene.Speech += mixer.Speech;
|
|
cutscene.MusicStopped += mixer.StopMusic;
|
|
cutscene.MusicRestarted += mixer.RestartMusic;
|
|
mixer.Music("musicsecretlab.omt", 0);
|
|
if (mixer.QueuedMusicBytes <= 0) throw new InvalidOperationException("No gameplay music before cutscene test");
|
|
cutscene.Begin(cutsceneLevel.FindStart()!);
|
|
var silentDuring = mixer.QueuedMusicBytes == 0 && mixer.QueuedSpeechBytes > 0;
|
|
for (var tick = 0; tick < 18000 && !cutscene.Controlled; tick++)
|
|
{
|
|
cutscene.Step(FixedStepClock.Step);
|
|
if (!cutscene.Controlled && mixer.QueuedMusicBytes != 0) silentDuring = false;
|
|
}
|
|
var naturalRestart = cutscene.Controlled && mixer.QueuedMusicBytes > 0;
|
|
cutscene.Begin(cutsceneLevel.FindStart()!);
|
|
var resetSilent = mixer.QueuedMusicBytes == 0;
|
|
mixer.StopSpeech(); cutscene.Skip();
|
|
var skipRestart = cutscene.Controlled && mixer.QueuedMusicBytes > 0;
|
|
Console.WriteLine($"Cutscene audio: music silent through intro={silentDuring}, natural restart={naturalRestart}, reset silent={resetSilent}, skip restart={skipRestart}.");
|
|
return silentDuring && naturalRestart && resetSilent && skipRestart ? 0 : 2;
|
|
}
|
|
if (Option(args, "--effects-audio-smoke") is { } effectsManifest)
|
|
{
|
|
using var mixer = new SceneAudio(new PreparedEntityResources(effectsManifest));
|
|
// Start transport only after both streams exist, so slow stream
|
|
// creation cannot consume the entire baseline before it is sampled.
|
|
mixer.SetPaused(true);
|
|
mixer.Effect(59, "bars"); mixer.Effect(58);
|
|
var before = mixer.QueuedEffectBytes;
|
|
mixer.SetPaused(false);
|
|
var consumptionClock = Stopwatch.StartNew();
|
|
while (mixer.QueuedEffectBytes >= before && consumptionClock.ElapsedMilliseconds < 3000) Thread.Sleep(20);
|
|
var after = mixer.QueuedEffectBytes;
|
|
var consumed = before > 0 && after < before;
|
|
mixer.Pump();
|
|
mixer.StopLoop("bars");
|
|
var stopped = mixer.LoopCount == 0 && mixer.EffectCount == 1;
|
|
mixer.Effect(230);
|
|
var mixed = mixer.EffectCount == 2;
|
|
mixer.StopEffects();
|
|
Console.WriteLine($"Original effects: consumed={consumed}, loop stopped={stopped}, independent one-shots={mixed}, cleared={mixer.QueuedEffectBytes == 0}; baseline={before}, after={after}.");
|
|
return consumed && stopped && mixed && mixer.QueuedEffectBytes == 0 ? 0 : 2;
|
|
}
|
|
if (Option(args, "--scene-audio-smoke") is { } sceneAudioManifest)
|
|
{
|
|
var bank = new PreparedEntityResources(sceneAudioManifest);
|
|
using var mixer = new SceneAudio(bank);
|
|
mixer.Music("musicsecretlab.omt", 0);
|
|
mixer.Speech("voiceneighborhood.omt", 36);
|
|
var beforeMusic = mixer.QueuedMusicBytes;
|
|
var beforeSpeech = mixer.QueuedSpeechBytes;
|
|
Thread.Sleep(500);
|
|
var consumed = mixer.QueuedMusicBytes < beforeMusic && mixer.QueuedSpeechBytes < beforeSpeech;
|
|
mixer.StopSpeech();
|
|
mixer.Speech("voiceneighborhood.omt", 46);
|
|
var restarted = mixer.QueuedMusicBytes > 0 && mixer.QueuedSpeechBytes > 0;
|
|
Console.WriteLine($"Scene music and speech consumed independently: {consumed}; speech replacement retained music: {restarted}.");
|
|
return consumed && restarted ? 0 : 2;
|
|
}
|
|
if (Option(args, "--audio-smoke") is { } audioSmoke)
|
|
{
|
|
using var sound = new SdlAudio(audioSmoke);
|
|
var before = sound.QueuedBytes;
|
|
Thread.Sleep(500);
|
|
var after = sound.QueuedBytes;
|
|
Console.WriteLine($"SDL3 audio stream consumed {before - after} source bytes in 500 ms; queued {after}.");
|
|
return after < before ? 0 : 2;
|
|
}
|
|
|
|
var scene = Option(args, "--scene");
|
|
var loadedSave = carriedSave ?? (Option(args, "--load-save") is { } savePath ? OriginalSave.Load(savePath) : null);
|
|
string? savedLevelPath = null;
|
|
if (loadedSave != null && carriedSave == null)
|
|
{
|
|
savedLevelPath = Directory.EnumerateFiles(AssetPath.Resolve(root, "gam"))
|
|
.Where(p => p.EndsWith(".gam", StringComparison.OrdinalIgnoreCase))
|
|
.FirstOrDefault(p => GamLevel.Load(p).Code == loadedSave.LevelCode)
|
|
?? throw new FileNotFoundException($"No GAM matches saved level {loadedSave.LevelCode}");
|
|
var prepared = new[] { "artifacts/extracted", Path.Combine(AppContext.BaseDirectory, "scenes") }
|
|
.FirstOrDefault(p => Directory.Exists(Path.Combine(p, "animations")))
|
|
?? throw new DirectoryNotFoundException("Prepare original scenes before loading saves");
|
|
scene = AssetPath.Resolve(prepared, Path.GetFileNameWithoutExtension(savedLevelPath) + "/scene.json");
|
|
}
|
|
var defaultScene = false;
|
|
if (scene == null && Option(args, "--model") == null)
|
|
{
|
|
scene = new[] { "artifacts/extracted/level1b/scene.json",
|
|
Path.Combine(AppContext.BaseDirectory, "scenes/level1b/scene.json") }.FirstOrDefault(File.Exists);
|
|
defaultScene = scene != null;
|
|
}
|
|
var levelPath = savedLevelPath == null ? Option(args, "--level") ?? (defaultScene ? "gam/level1b.gam" : null)
|
|
: "gam/" + Path.GetFileName(savedLevelPath);
|
|
GamLevel? level = levelPath == null ? null : GamLevel.Load(AssetPath.Resolve(root, levelPath));
|
|
var startTag = Option(args, "--start") ?? loadedSave?.StartPoint;
|
|
if (string.Equals(startTag, "none", StringComparison.OrdinalIgnoreCase)) startTag = null;
|
|
var originalStart = level?.FindStart(startTag);
|
|
if (level != null) Console.WriteLine($"Decoded GAM {level.Code}: {level.Entities.Count} entities.");
|
|
var originalCamera = args.Contains("--original-camera") || defaultScene;
|
|
if (originalCamera && originalStart == null)
|
|
throw new ArgumentException("Original camera requires a GAM with a matching startpoint.");
|
|
|
|
var mesh = scene != null ? Mesh.LoadSceneJson(scene)
|
|
: AseMesh.Load(AssetPath.Resolve(root, Option(args, "--model") ?? "ASE/jimstop.ase"));
|
|
var world = mesh;
|
|
var texture = scene != null ? PngImage.White
|
|
: PngImage.Load(AssetPath.Resolve(root, Option(args, "--texture") ?? "png/jimycarl.png"));
|
|
var bounds = mesh.Bounds();
|
|
var target = (bounds.Min + bounds.Max) / 2;
|
|
var radius = Math.Max(Vector3.Distance(bounds.Min, bounds.Max) * 1.15f, 1);
|
|
var animationPath = Option(args, "--animation");
|
|
var walkSmoke = args.Contains("--smoke-walk");
|
|
var jetpackSmoke = args.Contains("--smoke-jetpack");
|
|
var shrinkSmoke = args.Contains("--smoke-shrink-ray");
|
|
var invisibleSmoke = args.Contains("--smoke-invisible");
|
|
var bubbleSmoke = args.Contains("--smoke-bubble");
|
|
var baseballSmoke = args.Contains("--smoke-baseball");
|
|
var scooterSmoke=args.Contains("--smoke-scooter");
|
|
var grapplerSmoke = args.Contains("--smoke-grappler");
|
|
var rocketSmoke = args.Contains("--smoke-rocketship");
|
|
var carlSmoke = args.Contains("--smoke-carl-cutscene");
|
|
var controlPhaseSmoke = args.Contains("--smoke-control-phases");
|
|
var objectiveWindowSmoke = args.Contains("--smoke-objective-window");
|
|
var objectiveSmoke = args.Contains("--smoke-objective-panel") || objectiveWindowSmoke;
|
|
var jumpBinding = Option(args, "--smoke-jump-key") ?? "shift";
|
|
uint jumpScancode = jumpBinding switch { "shift" => 225, "right-shift" => 229,
|
|
"insert" => 73, "keypad0" => 98, "right-mouse" => 0,
|
|
_ => throw new ArgumentException("Unknown jump smoke binding") };
|
|
if (Option(args, "--smoke-jump-key") != null && !(walkSmoke || jetpackSmoke))
|
|
throw new ArgumentException("Jump binding smoke option requires a movement smoke mode");
|
|
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");
|
|
var gadgetWindowSmoke = args.Contains("--smoke-gadget-menu");
|
|
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")
|
|
&& animationPath == null && !args.Contains("--time");
|
|
var story = defaultStory || loadedSave != null || saveOutput != null || args.Contains("--story") || args.Contains("--story-time")
|
|
|| args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || scooterSmoke || gadgetWindowSmoke || practiceWindowSmoke || practiceReturnSmoke || carlSmoke || controlPhaseSmoke || objectiveSmoke;
|
|
if (story && (args.Contains("--inspect") || walkSmoke || args.Contains("--smoke-window")))
|
|
throw new ArgumentException("Story playback requires its own simulation mode.");
|
|
if (walkSmoke && args.Contains("--inspect")) throw new ArgumentException("Walk smoke cannot run in inspection mode.");
|
|
if (walkSmoke && args.Contains("--smoke-window")) throw new ArgumentException("Select one window smoke mode.");
|
|
var walking = !args.Contains("--inspect") && !args.Contains("--smoke-window") && (story || args.Contains("--walk") || walkSmoke
|
|
|| defaultScene && animationPath == null && !args.Contains("--time"));
|
|
if ((args.Contains("--with-player") || args.Contains("--walk") || defaultScene || walking) && scene != null)
|
|
animationPath ??= Path.Combine(Path.GetDirectoryName(scene)!, "../animations/jimstop/animation.json");
|
|
if (walking && (scene == null || originalStart == null))
|
|
throw new ArgumentException("Walking requires a scene and matching GAM startpoint.");
|
|
PreviewAnimationLibrary? animations = null;
|
|
LabSimulation? simulation = null;
|
|
SceneDirector? director = null;
|
|
TaskStates? storyTasks = null;
|
|
SceneActorVisuals? actorVisuals = null;
|
|
SceneSpriteVisuals? spriteVisuals = null;
|
|
StaticSceneVisuals? staticVisuals = null;
|
|
PreparedEntityResources? resources = null;
|
|
SceneInteractions? interactions = null;
|
|
SceneMechanisms? mechanisms = null;
|
|
SceneHud? hud = null;
|
|
GadgetScreen? gadgetScreen = null;
|
|
GadgetMenuOverlay? gadgetOverlay = null;
|
|
InvisibleMeterOverlay? invisibleMeter = null;
|
|
SceneGadgets? gadgets = null;
|
|
ShrinkRayVisuals? rayVisuals = null;
|
|
ShrinkSoldierVisuals? soldierVisuals = null;
|
|
JetpackVisuals? jetpackVisuals = null;
|
|
BubbleVisuals? bubbleVisuals = null;
|
|
SceneBaseballs? baseballs = null;
|
|
BaseballVisuals? baseballVisuals = null;
|
|
BaseballAimOverlay? baseballAim = null;
|
|
Scooter? scooter=null;
|
|
ScooterVisuals? scooterVisuals=null;
|
|
Rocketship? rocketship = null;
|
|
RocketshipVisuals? rocketshipVisuals = null;
|
|
GrapplerVisuals? grapplerVisuals = null;
|
|
var practice = new PracticePrompt();
|
|
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 ObserveControl(string boundary)
|
|
{
|
|
if (observation != null && director != null)
|
|
observation.RecordControl(level!.Code, simulation?.Steps ?? 0, director.Controlled,
|
|
director.ControlledTag, director.Playing, director.CurrentTag, boundary);
|
|
}
|
|
void SkipObservedDialogue(string source)
|
|
{
|
|
ObserveControl("before_skip");
|
|
director!.Skip();
|
|
ObserveControl("skip:" + source);
|
|
}
|
|
void StepObservedDirector(float delta)
|
|
{
|
|
ObserveControl("before_director_step");
|
|
director?.Step(delta);
|
|
ObserveControl("director_step");
|
|
}
|
|
void RequestTransition(LevelTransition request)
|
|
{
|
|
if (transitionRequest != null) return;
|
|
//43B5A0 captures live root for ordinary outbound transitions;
|
|
//RETURN preserves it for the destination PostLoad restore.
|
|
returnRoot = RuntimeCheckpoint.Stage(returnRoot, simulation!.ActorRoot, request.Returning).Root;
|
|
transitionRequest = request;
|
|
}
|
|
var characterOffset = mesh.Vertices.Length;
|
|
var characterModel = Matrix4x4.Identity;
|
|
MeshDraw? characterDraw = null;
|
|
if (animationPath != null)
|
|
{
|
|
if (scene == null || originalStart == null)
|
|
throw new ArgumentException("A scene and matching GAM are required to place an animated player.");
|
|
animations = new PreviewAnimationLibrary(animationPath);
|
|
var standingPose = AseMesh.Load(AssetPath.Resolve(root, "ASE/jimstop.ase"));
|
|
if (walking)
|
|
{
|
|
var cameraRay = level!.Code is "LV1B" or "VR01" or "VR02" or "VR04" or "VR05" or "VR07" or "VR08" or "LEV1"
|
|
? OriginalCameraRay.FromRouteScene(world, level.Code) : null;
|
|
debugCameraRay = cameraRay;
|
|
simulation = new LabSimulation(new SceneCollision(world), standingPose, originalStart.Position, originalStart.Rotation,
|
|
cameraRay == null ? null : (look, eye) => cameraRay.Trace(look, eye),
|
|
cameraRay == null ? null : (start, end) => cameraRay.TraceGeometry(start, end),
|
|
level.Code is "VR01" or "VR02" or "VR04" or "VR07" or "VR08" ? OriginalStaticCollision.FromRouteScene(world,level.Code) : null, energy)
|
|
//Successful TSK entry reuses the menu-background Jimmy, whose
|
|
//node precedes the new level game. Direct scene inspection
|
|
//still has fresh game-before-player order. See main-menu-player-lifetime.md.
|
|
{ LevelCode = level.Code, InputAfterPlayerUpdate = story || carriedSave != null };
|
|
if(level.Code=="VR08")simulation.EnableGrappler(world,grapplerMemory);
|
|
if (carriedPlayer != null)
|
|
{
|
|
var applied = simulation.ApplyRetainedLevelState(carriedPlayer);
|
|
if (applied)
|
|
Console.WriteLine($"Retained player scalars: mode={simulation.MovementMode}, hold={simulation.JumpHoldSeconds}, fire={simulation.JetpackRemaining}; jump={simulation.JumpState}, velocity={simulation.Velocity}, speed={simulation.Speed}.");
|
|
if (practiceReturnSmoke && (!applied || simulation.MovementMode != carriedPlayer.MovementMode
|
|
|| simulation.JumpHoldSeconds != carriedPlayer.HoldSeconds || simulation.JetpackRemaining != carriedPlayer.EffectRemaining
|
|
|| simulation.JumpState != 0 || simulation.Speed != 0 || simulation.Velocity != Vector3.Zero || simulation.PendingImpulse != Vector3.Zero))
|
|
throw new InvalidOperationException("Retained route scalar/body reset boundary changed");
|
|
}
|
|
}
|
|
if (walking && returning) simulation!.RestoreReturnRoot(returnRoot);
|
|
var placement = PreviewCharacterPlacement.Create(mesh, standingPose, originalStart.Position, originalStart.Rotation.Y);
|
|
characterModel = placement.Model;
|
|
mesh = animations.Current.AppendTo(mesh);
|
|
characterDraw = mesh.Draws[^1];
|
|
if (walking)
|
|
Console.WriteLine("Controllable lab: arrows move/turn; Shift/Insert/right mouse jump; Enter/Ctrl/left mouse fire; Tab/Space gadgets; R reset; C inspect; F11 fullscreen; Escape quit. Collision, pivot and timing remain provisional.");
|
|
else
|
|
Console.WriteLine($"Preview floor correction: +{placement.VerticalCorrection:F3} Y. 1 idle, 2 run, 3 jump, 4 scratch.");
|
|
}
|
|
if (story)
|
|
{
|
|
resources = new PreparedEntityResources(Path.Combine(Path.GetDirectoryName(scene!)!, "entities/entities.json"),
|
|
Path.Combine(Path.GetDirectoryName(scene!)!, "../effects/effects.json"));
|
|
var save = loadedSave ?? OriginalSave.Load(AssetPath.Resolve(root, "NewGame.tsk"));
|
|
returnRoot = save.StoredVector;
|
|
var tasks = new TaskStates(save.Tasks);
|
|
storyTasks = tasks;
|
|
director = new SceneDirector(level!, tasks, resources.Duration);
|
|
interactions = new SceneInteractions(director, tasks, save);
|
|
gadgetScreen = new GadgetScreen(interactions.Inventory,()=>simulation!.GadgetMode);
|
|
interactions.Inventory.ApplyLevelAvailability(level!.Code);
|
|
objectivePanel = new ObjectivePanel(interactions.CurrentObjective);
|
|
interactions.ObjectiveChanged += objectivePanel.Select;
|
|
simulation!.Energy = interactions.Energy;
|
|
simulation.JetpackInventoryState = () => interactions.Inventory.State(0, 3);
|
|
simulation.ScoreChanged += interactions.ChangeScore;
|
|
if(level.Code is "VR05" or "LEV1")
|
|
{
|
|
if(director.FindActor("C3DGODDARD")==null)
|
|
{
|
|
var behind=simulation.ActorRoot+RocketOrientation.Rotate(new(0,0,-250),new(0,simulation.Yaw,0));
|
|
var ray=OriginalCameraRay.FromRouteScene(world,level.Code);
|
|
director.EnsureCompanion(ray.TraceGeometry(simulation.ActorRoot,behind)==null?behind:originalStart!.Position,Vector3.Zero);
|
|
}
|
|
scooter=new(director.AddOwnedActor("C3DJEEP","3JEE",Vector3.Zero),world,level.Code);
|
|
}
|
|
if(level.Code=="VR02")rocketship=new(director.Actors.Single(a=>a.Kind=="3ROC"),world,level.Code);
|
|
if (level.Code is "LV1B" or "VR04" or "LEV1")
|
|
{
|
|
gadgets = new SceneGadgets(director,interactions.Inventory,simulation,world);
|
|
gadgets.ScoreAwarded += interactions.ChangeScore;
|
|
}
|
|
if(level.Code is "LV1B" or "VR01" or "VR04" or "VR05" or "VR07" or "VR08" or "LEV1")
|
|
{
|
|
baseballs=new(director,simulation,world);
|
|
baseballs.ScoreAwarded+=interactions.ChangeScore;
|
|
}
|
|
mechanisms = new SceneMechanisms(director);
|
|
interactions.Transition += RequestTransition;
|
|
interactions.PracticeRequested += practice.Show;
|
|
practice.Chosen += (mode, accepted) =>
|
|
{
|
|
if (!accepted) { objectivePanel.Show(); return; }
|
|
// Player43B5A0 captures root separately from42AF00's pickup checkpoint.
|
|
interactions.SetReturnContext(Path.GetFileName(levelPath!), originalStart!.Tag!);
|
|
RequestTransition(new(PracticePrompt.Destination(mode), "PHONEBOOTH", 0, -1));
|
|
};
|
|
gadgetScreen.PracticeRequested += item =>
|
|
{
|
|
interactions.SetReturnContext(Path.GetFileName(levelPath!), originalStart!.Tag!);
|
|
RequestTransition(new($"VR0{item + 1}.gam", "PHONEBOOTH", 0, -1));
|
|
};
|
|
interactions.Collected += (entity, points) => Console.WriteLine($"Collected {entity.Tag}: +{points}; score={interactions.Score}.");
|
|
foreach (var actor in director.Actors.Where(a => a.Kind is "3DOG" or "3CAR"))
|
|
{
|
|
var physics = new OriginalScenePhysics(world);
|
|
var grounded = false;
|
|
var patrol = new ActorPatrol(actor, director.FindActor, (body, dt) =>
|
|
{
|
|
var resolved = physics.Step(body.Position, body.Velocity,
|
|
actor.Kind == "3DOG" ? OriginalBodySupport.GoddardRadius : 100,
|
|
actor.Kind == "3DOG" ? OriginalBodySupport.GoddardFactor : .75f, grounded, dt);
|
|
grounded = resolved.Supported;
|
|
return new(resolved.Body.Position, resolved.Body.Velocity);
|
|
});
|
|
patrol.FollowPlayer=actor.Kind=="3DOG"&&level!.Code is "VR05" or "LEV1";
|
|
patrols.Add(actor.Tag, patrol);
|
|
director.RegisterPatrolConsumer(actor.Tag);
|
|
director.ActorChanged += changed => { if (ReferenceEquals(changed, actor)) patrol.SynchronizeAuthoredState(); };
|
|
}
|
|
actorVisuals = new SceneActorVisuals(mesh, world, director, Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, "..")),
|
|
actor => patrols.ContainsKey(actor.Tag));
|
|
mesh = actorVisuals.Mesh;
|
|
if (gadgets != null)
|
|
{
|
|
soldierVisuals = new ShrinkSoldierVisuals(mesh,gadgets.Soldiers,
|
|
Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, "..")),level!.Code);
|
|
mesh = soldierVisuals.Mesh;
|
|
}
|
|
spriteVisuals = new SceneSpriteVisuals(mesh, director, resources);
|
|
mesh = spriteVisuals.Mesh;
|
|
staticVisuals = new StaticSceneVisuals(mesh, director, root, Path.Combine(Path.GetDirectoryName(scene!)!, "models"));
|
|
mesh = staticVisuals.Mesh;
|
|
if (simulation!.UsesOriginalBody)
|
|
{
|
|
if (staticVisuals.DoorColliders().Any())
|
|
throw new NotSupportedException("Source ordinary-body scene has unsupported dynamic door colliders");
|
|
}
|
|
else simulation.DynamicRootResolver = (previous, position, radius) =>
|
|
DynamicBodyResponse.Resolve(staticVisuals.DoorColliders(), previous, position, radius);
|
|
if(scooter!=null)
|
|
{
|
|
scooter.DynamicRootResolver=(a,b,r)=>DynamicBodyResponse.Resolve(staticVisuals.DoorColliders(),a,b,r);
|
|
scooterVisuals=new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));mesh=scooterVisuals.Mesh;
|
|
}
|
|
jetpackVisuals = new JetpackVisuals(mesh, Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, "..")));
|
|
mesh = jetpackVisuals.Mesh;
|
|
bubbleVisuals = new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
|
mesh = bubbleVisuals.Mesh;
|
|
baseballVisuals = new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
|
mesh = baseballVisuals.Mesh;
|
|
if(rocketship!=null)
|
|
{
|
|
rocketshipVisuals=new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
|
mesh=rocketshipVisuals.Mesh;
|
|
}
|
|
if(simulation.Grappler!=null)
|
|
{
|
|
grapplerVisuals=new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
|
mesh=grapplerVisuals.Mesh;
|
|
}
|
|
if (gadgets != null)
|
|
{
|
|
rayVisuals = new ShrinkRayVisuals(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, "..")),root);
|
|
mesh = rayVisuals.Mesh;
|
|
}
|
|
hud = new SceneHud(mesh, Path.Combine(Path.GetDirectoryName(scene!)!, "../ui/ui.json"));
|
|
mesh = hud.Mesh;
|
|
invisibleMeter = new InvisibleMeterOverlay(mesh,Path.Combine(Path.GetDirectoryName(scene!)!,"../invisible-meter/meter.json"));
|
|
mesh = invisibleMeter.Mesh;
|
|
baseballAim = new(mesh,Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!,"..")));
|
|
mesh = baseballAim.Mesh;
|
|
gadgetOverlay = new GadgetMenuOverlay(mesh, Path.Combine(Path.GetDirectoryName(scene!)!, "../gadgets/gadgets.json"));
|
|
mesh = gadgetOverlay.Mesh;
|
|
Console.WriteLine($"Prepared source model actors: {staticVisuals.ActorCount}.");
|
|
}
|
|
using var gadgetLifetime = gadgets;
|
|
var debugMenu = new DebugMenu(scene != null && level != null
|
|
? 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.");
|
|
var fixedTimeText = Option(args, "--time");
|
|
double? fixedTime = fixedTimeText == null ? null : double.Parse(fixedTimeText, System.Globalization.CultureInfo.InvariantCulture);
|
|
var headless = args.Contains("--headless");
|
|
if (practiceReturnSmoke && (!headless || level?.Code is not ("LV1B" or "VR04") || carriedSave == null && loadedSave != null))
|
|
throw new ArgumentException("Practice RETURN check requires a fresh headless lab or its carried tutorial/return");
|
|
if (args.Contains("--smoke-transition") && (!headless || level?.Code is not ("VR01" or "VR04") || interactions == null))
|
|
throw new ArgumentException("Transition smoke requires headless story playback of VR01 or VR04.");
|
|
if (args.Contains("--smoke-lab-route") && (!headless || level?.Code != "LV1B" || interactions == null || loadedSave != null))
|
|
throw new ArgumentException("Lab route smoke requires fresh headless story playback of LV1B.");
|
|
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") ?? (scooterSmoke ? "10" : grapplerSmoke ? "9" : rocketSmoke ? "10" : walkSmoke ? "240" : jetpackSmoke ? "300" : shrinkSmoke ? "90" : invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke ? "8" : gadgetWindowSmoke ? "24" : objectiveWindowSmoke ? "180" : carlSmoke ? "60" : controlPhaseSmoke ? "32" : toolsSmoke ? "20" : debugSmoke ? "16" : diagnosticsSmoke ? "24" : headless ? "1" : "0"));
|
|
if (gadgetWindowSmoke && (headless || level?.Code != "LV1B" || loadedSave != null || frames < 24))
|
|
throw new ArgumentException("Gadget menu SDL fixture requires a fresh windowed lab and24 frames");
|
|
if (shrinkSmoke && (level?.Code != "VR04" || gadgets == null || frames < 60))
|
|
throw new ArgumentException("Shrink-ray smoke requires actual VR04 and at least60 frames");
|
|
if (invisibleSmoke && (level?.Code != "VR03" || frames < 8 || loadedSave != null))
|
|
throw new ArgumentException("Invisible smoke requires a fresh VR03 and at least8 frames");
|
|
if (bubbleSmoke && (level?.Code!="VR01" || frames<8 || loadedSave!=null))
|
|
throw new ArgumentException("Bubble smoke requires a fresh VR01 and at least8 frames");
|
|
if(baseballSmoke && (level?.Code!="VR07" || frames<8 || loadedSave!=null))
|
|
throw new ArgumentException("Baseball fixture requires a fresh VR07 and at least8 frames");
|
|
if(scooterSmoke&&(scooter==null||frames<10||loadedSave!=null))
|
|
throw new ArgumentException("Scooter replay requires fresh VR05 or outsideLEV1 and10 frames");
|
|
if(grapplerSmoke&&(level?.Code!="VR08"||frames<9||loadedSave!=null))
|
|
throw new ArgumentException("Grappler fixture requires fresh VR08 and at least9 frames");
|
|
if(rocketSmoke&&(level?.Code!="VR02"||frames<10||loadedSave!=null))
|
|
throw new ArgumentException("Rocketship fixture requires fresh VR02 and at least10 frames");
|
|
if (controlPhaseSmoke && (level?.Code != "LV1B" || loadedSave != null || frames < 32 || director == null))
|
|
throw new ArgumentException("Control-phase fixture needs a fresh lab and at least32 frames");
|
|
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
|
|
|| debugMenu.Open || diagnostics.Enabled || debugSmoke))
|
|
throw new ArgumentException("Live debug SDL smoke requires fresh windowed LV1B, hidden diagnostics and at least24 frames");
|
|
if (objectiveWindowSmoke && (headless || frames < 180)) throw new ArgumentException("Objective window smoke needs180 window frames");
|
|
if ((carlSmoke || objectiveSmoke) && (level?.Code != "LV1B" || loadedSave != null || objectiveSmoke && !headless && !objectiveWindowSmoke))
|
|
throw new ArgumentException("Lab conversation/objective smoke requires fresh LV1B (objective check is headless)");
|
|
if (jetpackSmoke && (level?.Code != "VR04" || frames < 300))
|
|
throw new ArgumentException("Jetpack smoke requires VR04 and at least300 frames");
|
|
if (walkSmoke && frames < 240) throw new ArgumentException("Walk smoke requires at least 240 frames.");
|
|
var smoke = args.Contains("--smoke-window");
|
|
if (frames < 0 || (smoke && (headless || frames < 6)))
|
|
throw new ArgumentException("Invalid frame count; window smoke requires at least six frames.");
|
|
if (practiceWindowSmoke && (headless || frames < 12 || level?.Code != "LV1B" || loadedSave != null))
|
|
throw new ArgumentException("Practice window smoke requires fresh LV1B and at least12 windowed frames.");
|
|
var width = uint.Parse(Option(args, "--width") ?? "960");
|
|
var height = uint.Parse(Option(args, "--height") ?? "720");
|
|
if (width is < 64 or > 8192 || height is < 64 or > 8192) throw new ArgumentException("Viewport dimensions must be64..8192");
|
|
using var playerBinding = director == null ? null
|
|
: new PlayerSceneBinding(director, simulation!, interactions!.Inventory, level!.Player!.Tag!,rocketship,scooter);
|
|
var renderer = presentation.LoadScene(mesh, texture, headless,
|
|
walking ? WalkTitle : animations?.WindowTitle ?? "Jimmy Neutron — scene preview | C camera",
|
|
width, height, !args.Contains("--no-validation"));
|
|
observation?.RecordSceneEntry(level?.Code ?? "preview", simulation?.Steps ?? 0, returning,
|
|
carriedPlayer != null, carriedSave != null ? "retained" : loadedSave != null ? "tsk-story" : "fresh-direct-scene");
|
|
var window = presentation.Window;
|
|
ShrinkSoldier? shrinkVictim = null;
|
|
var shrinkPhaseMask = 0;
|
|
var sawShrinkKey = false;
|
|
InvisibleSmoke? invisibleFixture = null;
|
|
BubbleSmoke? bubbleFixture = null;
|
|
BaseballSmoke? baseballFixture = null;
|
|
ScooterSmoke? scooterFixture=null;
|
|
var sawScooterKeys=0;
|
|
GrapplerSmoke? grapplerFixture=null;
|
|
RocketshipSmoke? rocketFixture=null;
|
|
var sawRocketKeys=0;
|
|
var sawGrapplerKeys=0;
|
|
var sawBaseballKeys=0;
|
|
var sawBubbleKeys=0;
|
|
Console.WriteLine($"Scene presentation: revision={renderer.SceneRevision}, windows={presentation.WindowCreationCount}, renderers={presentation.RendererCreationCount}, window ID={(window == 0 ? 0 : Sdl.SDL_GetWindowID(window))}, size={renderer.Width}x{renderer.Height}.");
|
|
{
|
|
using var audio = Option(args, "--audio") is { } audioFile
|
|
? new SdlAudio(audioFile, args.Contains("--loop-audio"), debugMenu.Open) : null;
|
|
using var sceneAudio = resources != null && !headless && !args.Contains("--mute") ? new SceneAudio(resources) : null;
|
|
using var scooterLifetime=scooter;
|
|
using var grapplerLifetime = simulation?.Grappler;
|
|
if(simulation?.Grappler is{} grapplerAudio)
|
|
{
|
|
grapplerAudio.Sound+=(id,loop)=>sceneAudio?.Effect(id,loop?"grappler":null);
|
|
grapplerAudio.LoopStopped+=()=>sceneAudio?.StopLoop("grappler");
|
|
}
|
|
sceneAudio?.SetPaused(debugMenu.Open);
|
|
if (simulation!=null)
|
|
{
|
|
simulation.GadgetSound += (id,loop) => sceneAudio?.Effect(id,loop?"bubble":null);
|
|
simulation.BubbleSoundStopped += () => sceneAudio?.StopLoop("bubble");
|
|
}
|
|
if(scooter!=null)
|
|
{
|
|
var scooterAudio=new ScooterAudio();
|
|
scooter.EngineStarted+=()=>{scooterAudio.Reset();sceneAudio?.Effect(46,"scooter");};
|
|
scooter.EngineStopped+=()=>sceneAudio?.StopLoop("scooter");
|
|
scooter.EngineSpeedChanged+=speed=>sceneAudio?.TuneLoop("scooter",baseFrequency=>
|
|
scooterAudio.Frequency(baseFrequency,speed,scooter.Root,
|
|
director?.CameraEye??(scooter.Mounted?scooter.CameraEye:simulation!.CameraEye)));
|
|
}
|
|
if(baseballs!=null)baseballs.Sound+=id=>sceneAudio?.Effect(id);
|
|
if(rocketship!=null)
|
|
{
|
|
rocketship.Sound+=id=>sceneAudio?.Effect(id);
|
|
rocketship.EngineSound+=id=>sceneAudio?.Effect(id,"rocket-engine");
|
|
rocketship.EngineStopped+=()=>sceneAudio?.StopLoop("rocket-engine");
|
|
}
|
|
if (gadgets != null)
|
|
{
|
|
gadgets.Sound += (id,loop) => sceneAudio?.Effect(id,loop ? "shrink-ray" : null);
|
|
gadgets.StopSound += () => sceneAudio?.StopLoop("shrink-ray");
|
|
}
|
|
if (gadgetScreen != null) gadgetScreen.Changed += () =>
|
|
{
|
|
gadgets?.Stop();
|
|
if (sceneAudio != null) sceneAudio.GameplayEffectsEnabled = !gadgetScreen.Open;
|
|
};
|
|
double initialPoseTime = 0;
|
|
if (director != null)
|
|
{
|
|
if (sceneAudio != null)
|
|
{
|
|
director.Speech += sceneAudio.Speech;
|
|
director.MusicStopped += sceneAudio.StopMusic;
|
|
director.MusicRestarted += sceneAudio.RestartMusic;
|
|
objectivePanel!.SoundEffect += id => { if (level!.Code == "LV1B") sceneAudio.Effect(id); };
|
|
interactions!.SoundEffect += id => sceneAudio.Effect(id);
|
|
simulation!.EnergySound += id => sceneAudio.Effect(id);
|
|
mechanisms!.Sound += (actor, id, loop) => sceneAudio.Effect(id, loop ? actor.Tag : null);
|
|
mechanisms.StopSound += actor => sceneAudio.StopLoop(actor.Tag);
|
|
sceneAudio.Music(originalStart!.Text("MusicDatabase") ?? "none", originalStart.Integer("MusicIndex", -1));
|
|
}
|
|
director.Begin(originalStart!, activateStartTrigger: !returning);
|
|
ObserveControl("scene_begin");
|
|
gadgets?.Reset();
|
|
baseballs?.Reset();
|
|
interactions!.Reset();
|
|
mechanisms!.Reset();
|
|
director.SyncActor(level!.Player!.Tag!, simulation!.ActorRoot, simulation.Rotation);
|
|
if (returning && director.FindActor("C3DGODDARD") is { } companion)
|
|
director.SyncActor(companion.Tag, returnRoot, companion.Rotation); //423AE3..423B1E, no offset.
|
|
if (practiceReturnSmoke && returning)
|
|
{
|
|
var restored = director.Controlled && !director.Playing && director.CurrentTag == null
|
|
&& Vector3.Distance(simulation.ActorRoot, returnRoot) < .001f
|
|
&& Vector2.Distance(new(returnRoot.X, returnRoot.Z), new(originalStart!.Position.X, originalStart.Position.Z)) > 100;
|
|
var companionRestored = director.FindActor("C3DGODDARD")?.Position == returnRoot;
|
|
restored &= companionRestored && simulation.InputAfterPlayerUpdate && interactions.Inventory.State(0, 3) == 1;
|
|
Console.WriteLine($"Practice RETURN: exact saved root={restored}, root={simulation.ActorRoot}, STRT yaw={simulation.Yaw}, intro suppressed={!director.Playing}, companion restored={companionRestored}, retained player input order={simulation.InputAfterPlayerUpdate}, gadget availability={interactions.Inventory.State(0, 3)}.");
|
|
if (!restored) throw new InvalidOperationException("RETURN did not restore the live departure root without replaying STRT actions");
|
|
}
|
|
if (args.Contains("--skip-intro") || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || scooterSmoke || gadgetWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke || controlPhaseSmoke) { sceneAudio?.StopSpeech(); SkipObservedDialogue("startup-option-or-fixture"); }
|
|
if (gadgetWindowSmoke) { interactions!.Inventory.SetState(0,3,1); interactions.Inventory.SelectGadget(3); }
|
|
if (controlPhaseSmoke)
|
|
{
|
|
//Enter with real airborne steering/destination state, rather
|
|
//than an upright fixture that cannot detect stale jump tilt.
|
|
for (var tick = 0; tick < 8; tick++)
|
|
playerBinding!.Step(new(true, false, true, false, true));
|
|
if (simulation.Grounded || !simulation.FacingDirty || simulation.FacingTarget.X >= 0 || simulation.FacingTarget.Z >= 0)
|
|
throw new InvalidOperationException("Control-phase fixture did not establish a banked jump");
|
|
var enteredRotation = simulation.Rotation;
|
|
interactions.Inventory.SetState(0, 3, 1); interactions.Inventory.SelectGadget(3);
|
|
simulation.ApplyRetainedLevelState(new("LV1B", 3, 1, .625f, 6.125f));
|
|
simulation.RestoreReturnRoot(simulation.ActorRoot + Vector3.UnitY * 200);
|
|
director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, simulation.Rotation);
|
|
director.Trigger("neutron1a");
|
|
var preparedRotation = new Vector3(0, enteredRotation.Y, 0);
|
|
if (simulation.Rotation != preparedRotation || simulation.FacingTarget != preparedRotation || !simulation.FacingDirty)
|
|
throw new InvalidOperationException("MCA did not copy upright current/destination Euler while retaining dirty");
|
|
Console.WriteLine($"Control-phase banked entry: Euler={enteredRotation}, prepared={simulation.Rotation}, destination={simulation.FacingTarget}, dirty={simulation.FacingDirty}.");
|
|
}
|
|
if (practiceReturnSmoke && level.Code == "VR04")
|
|
{
|
|
if (interactions!.Inventory.State(0, 3) != 1)
|
|
throw new InvalidOperationException("VR04 PostLoad tail did not re-enable its owned practice jetpack");
|
|
SkipObservedDialogue("fixture-setup");
|
|
interactions!.Update(level.Entities.First(e => e.Kind == "LOAD").Position);
|
|
if (transitionRequest is not { Returning: true }) throw new InvalidOperationException("VR04 exit did not preserve RETURN identity");
|
|
}
|
|
if (args.Contains("--smoke-transition"))
|
|
{
|
|
SkipObservedDialogue("fixture-setup");
|
|
interactions!.Update(level!.Entities.First(e => e.Kind == "LOAD").Position);
|
|
if (transitionRequest == null) throw new InvalidOperationException("Original VR01 RETURN contact did not request a transition");
|
|
}
|
|
if (args.Contains("--smoke-lab-route"))
|
|
{
|
|
LabRouteSmoke.Run(level!, director, interactions!, () => practice.Key(17, Vector2.Zero));
|
|
if (transitionRequest?.LevelFile != "level1.gam")
|
|
throw new InvalidOperationException("Original lab exit did not request level1.gam");
|
|
}
|
|
if (carlSmoke) LabRouteSmoke.StartCarl(level!, director, interactions!, () => practice.Key(17, Vector2.Zero));
|
|
if (objectiveSmoke)
|
|
{
|
|
SkipObservedDialogue("fixture-setup");
|
|
director.Touch(level!.Player!.Tag!, level.Entities.Single(e => e.Tag == "teleportexplanation").Position);
|
|
SkipObservedDialogue("fixture-setup");
|
|
if (interactions!.CurrentObjective != 1) throw new InvalidOperationException("Original explanation did not assign objective1");
|
|
if (objectiveWindowSmoke) objectivePanel!.Step(9);
|
|
}
|
|
if (args.Contains("--smoke-practice-prompt") || args.Contains("--smoke-practice-transition") || practiceWindowSmoke
|
|
|| practiceReturnSmoke && level.Code == "LV1B" && !returning)
|
|
{
|
|
if ((!headless && !practiceWindowSmoke) || level?.Code != "LV1B") throw new ArgumentException("Practice smoke requires the original lab");
|
|
SkipObservedDialogue("fixture-setup");
|
|
if (practiceReturnSmoke)
|
|
{
|
|
// Move the real player away from STRT so an accidental
|
|
// restart at the authored spawn cannot pass this check.
|
|
for (var tick = 0; tick < 45; tick++) simulation.Step(new(true, false, false, false, false));
|
|
director.SyncActor(level.Player!.Tag!, simulation.ActorRoot, simulation.Rotation);
|
|
}
|
|
director.Touch(level!.Player!.Tag!, level.Entities.Single(e => e.Tag == "teleportexplanation").Position);
|
|
SkipObservedDialogue("fixture-setup");
|
|
interactions!.Update(director.FindActor("shrinkray")!.Position);
|
|
if (!practice.Active) throw new InvalidOperationException("Original lab pickup did not open practice modal");
|
|
if (args.Contains("--smoke-practice-transition") || practiceReturnSmoke) practice.Key(28, Vector2.Zero);
|
|
}
|
|
for (var tick = 0; tick < (int)Math.Round(storyTime * 60) && !practice.Active && !debugMenu.Open; tick++)
|
|
{
|
|
gadgets?.StepBodies(FixedStepClock.Step);
|
|
playerBinding!.Step(default);
|
|
gadgets?.StepTimers(FixedStepClock.Step);
|
|
interactions!.UpdateEnergy(simulation!.Energy);
|
|
foreach (var patrol in patrols.Values) patrol.Step(FixedStepClock.Step);
|
|
mechanisms!.Step(FixedStepClock.Step);
|
|
StepObservedDirector(FixedStepClock.Step);
|
|
objectivePanel!.Step(FixedStepClock.Step, director.ControlledTag != null, practice.Active);
|
|
if (animations!.SelectAction(director.FindActor(level!.Player!.Tag!)!.Animation)) initialPoseTime = 0;
|
|
initialPoseTime += FixedStepClock.Step;
|
|
actorVisuals!.Update(FixedStepClock.Step, mesh);
|
|
soldierVisuals?.Update(FixedStepClock.Step,mesh);
|
|
spriteVisuals!.Step(FixedStepClock.Step);
|
|
}
|
|
if (args.Contains("--gadget-menu"))
|
|
{
|
|
interactions!.Inventory.SetState(0,3,1);
|
|
if (!gadgetScreen!.Toggle(director.Controlled && director.InventoryEnabled))
|
|
throw new InvalidOperationException("Gadget screen requires player control (--skip-intro)");
|
|
gadgetScreen.Point(new(200,380), level!.Code, storyTasks!.Get("SCENE"));
|
|
}
|
|
if (invisibleSmoke) invisibleFixture = new(simulation!,interactions!.Inventory);
|
|
if(baseballSmoke)baseballFixture=new(simulation!,playerBinding!,interactions!.Inventory,baseballs!,director);
|
|
if(scooterSmoke)scooterFixture=new(simulation!,playerBinding!,director,interactions!,level!.Code);
|
|
if(grapplerSmoke)grapplerFixture=new(simulation!,playerBinding!,director,interactions!);
|
|
if(rocketSmoke)rocketFixture=new(simulation!,playerBinding!,director,interactions!);
|
|
if (bubbleSmoke) bubbleFixture = new(simulation!,interactions!.Inventory);
|
|
if (shrinkSmoke)
|
|
{
|
|
//Explicit test placement near an ACTUAL authored soldier.
|
|
//No invented targets or relocation of the soldier to entry.
|
|
for (var tick = 0; tick < 600; tick++) gadgets!.StepBodies(FixedStepClock.Step);
|
|
var floorQuery = new SceneCollision(world);
|
|
var sourceQuery = OriginalCameraRay.FromRouteScene(world,"VR04");
|
|
foreach (var soldier in gadgets!.Soldiers)
|
|
{
|
|
foreach (var direction in new[] {Vector3.UnitZ,-Vector3.UnitZ,Vector3.UnitX,-Vector3.UnitX})
|
|
{
|
|
var candidate = soldier.Actor.Position - direction * 500;
|
|
var floor = floorQuery.GroundHeight(candidate + Vector3.UnitY * 500,2500);
|
|
if (floor == null) continue;
|
|
candidate.Y = floor.Value + OriginalBodySupport.JimmyRadius * OriginalBodySupport.JimmyFactor;
|
|
if (soldier.Actor.Position.Y <= candidate.Y - 150 || soldier.Actor.Position.Y >= candidate.Y + 60
|
|
|| sourceQuery.TraceGeometry(candidate + Vector3.UnitY * 150,soldier.Actor.Position + Vector3.UnitY * 150) != null) continue;
|
|
var fixtureYaw = OriginalHeading.Degrees(soldier.Actor.Position - candidate);
|
|
var (viewSin,viewCos) = LabSimulation.Trig(fixtureYaw);
|
|
var fixtureEye = candidate + new Vector3(viewSin*350,180,-viewCos*350);
|
|
if (sourceQuery.TraceGeometry(fixtureEye,soldier.Actor.Position + Vector3.UnitY*25) != null) continue;
|
|
simulation!.ApplyAuthoredTransform(candidate,fixtureYaw);
|
|
simulation.RestoreReturnRoot(candidate); //Fixture camera snap at the explicitly moved player.
|
|
shrinkVictim = soldier; break;
|
|
}
|
|
if (shrinkVictim != null) break;
|
|
}
|
|
if (shrinkVictim == null) throw new InvalidOperationException("No supported source ray fixture near actual VR04 soldier");
|
|
interactions!.Inventory.SetState(0,3,1); interactions.Inventory.SelectGadget(3);
|
|
Console.WriteLine($"Shrink fixture: actual target={shrinkVictim.Actor.Tag}, target root={shrinkVictim.Actor.Position}, player root={simulation!.ActorRoot}.");
|
|
}
|
|
}
|
|
var keys = new HashSet<uint>();
|
|
var gadgetHeldKeys = new HashSet<uint>();
|
|
var gadgetArrows = new HashSet<uint>();
|
|
var debugCapturedKeys = new HashSet<uint>();
|
|
var running = true;
|
|
var sawKey = false;
|
|
var didResize = false;
|
|
var clock = Stopwatch.StartNew();
|
|
var animationStarted = 0.0;
|
|
var animationSwitched = false;
|
|
var inspecting = !walking;
|
|
var active = presentation.HasInputFocus;
|
|
var mouseJump = false;
|
|
var mouseFire = false;
|
|
var stepClock = new FixedStepClock();
|
|
double poseTime = initialPoseTime;
|
|
var injectedInput = default(PlayerInput);
|
|
var sawWalkKeys = 0;
|
|
var sawJetpackKeys = 0;
|
|
float poweredAirTravel = 0;
|
|
var poweredAirTurn = false;
|
|
var objectiveWasHidden = false;
|
|
var objectiveReopened = false;
|
|
var objectiveClosing = false;
|
|
var sawPracticeDismiss = false;
|
|
var sawPracticePause = false;
|
|
double last = clock.Elapsed.TotalSeconds;
|
|
float angle = 0.6f, elevation = 0.32f;
|
|
var count = 0;
|
|
var lastPresentedAt = clock.Elapsed.TotalSeconds;
|
|
var debugPauseObserved = false;
|
|
var debugActionsObserved = false;
|
|
var debugEscapeObserved = false;
|
|
var debugResumeObserved = false;
|
|
var debugForceObserved = false;
|
|
float debugForceTravel = 0;
|
|
var diagnosticsShown = false;
|
|
var diagnosticsHidden = false;
|
|
var diagnosticsMoves = false;
|
|
var diagnosticsMenuPriority = false;
|
|
var diagnosticsPreference = false;
|
|
var diagnosticsMenuToggle = false;
|
|
var diagnosticsPausedSteps = 0;
|
|
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;
|
|
var controlEntry = simulation?.ActorRoot ?? Vector3.Zero;
|
|
var controlRotation = simulation?.Rotation ?? Vector3.Zero;
|
|
var controlControllers = simulation?.ControllerSteps ?? 0;
|
|
var controlPhysics = simulation?.PhysicsSteps ?? 0;
|
|
var controlEffects = simulation?.EffectSteps ?? 0;
|
|
var controlJumps = simulation?.Jumps ?? 0;
|
|
var controlTurn = simulation?.TurnRate ?? 0;
|
|
var phasesLocked = false; var phasesResumed = false;
|
|
var gadgetChecks = new bool[7];
|
|
var gadgetEntry = simulation?.ActorRoot ?? Vector3.Zero;
|
|
var gadgetPausedSteps = 0;
|
|
void ResetScene()
|
|
{
|
|
gadgetScreen?.Close();
|
|
if (simulation == null) { debugMenu.Message = "RESET REQUIRES PLAY MODE"; return; }
|
|
if (practice.Active) practice.Key(17, Vector2.Zero);
|
|
playerBinding?.ResetVehicle();simulation.Reset(); poseTime = 0; sceneAudio?.StopSpeech(); director?.Begin(originalStart!);
|
|
ObserveControl("reset_begin");
|
|
rocketship?.Reset();
|
|
if(scooter!=null)
|
|
{
|
|
var behind=simulation.ActorRoot+RocketOrientation.Rotate(new(0,0,-250),new(0,simulation.Yaw,0));
|
|
var ray=OriginalCameraRay.FromRouteScene(world,level!.Code);
|
|
director!.EnsureCompanion(ray.TraceGeometry(simulation.ActorRoot,behind)==null?behind:originalStart!.Position,Vector3.Zero);
|
|
}
|
|
interactions?.Reset(); mechanisms?.Reset(); gadgets?.Reset(); baseballs?.Reset(); mouseFire = false;
|
|
director?.SyncActor(level!.Player!.Tag!, simulation.ActorRoot, simulation.Rotation);
|
|
}
|
|
void ToggleCamera()
|
|
{
|
|
if (originalStart == null) { debugMenu.Message = "CAMERA REQUIRES A SCENE START"; return; }
|
|
if (simulation == null) { originalCamera = !originalCamera; return; }
|
|
inspecting = !inspecting;
|
|
originalCamera = false; target = simulation.ActorRoot; radius = 600;
|
|
if (window != 0 && !Sdl.SDL_SetWindowTitle(window, inspecting ? animations!.WindowTitle : WalkTitle))
|
|
throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
void DebugInputBoundary()
|
|
{
|
|
gadgetArrows.Clear();
|
|
gadgets?.Stop(); mouseFire = false;
|
|
debugCapturedKeys.UnionWith(keys);
|
|
keys.Clear(); mouseJump = false; stepClock.Reset(); last = clock.Elapsed.TotalSeconds;
|
|
audio?.SetPaused(debugMenu.Open); sceneAudio?.SetPaused(debugMenu.Open);
|
|
}
|
|
void DebugCommand(DebugAction action)
|
|
{
|
|
switch (action)
|
|
{
|
|
case DebugAction.Resume: debugMenu.Close(); break;
|
|
case DebugAction.Camera: ToggleCamera(); debugMenu.Close(); break;
|
|
case DebugAction.SkipCutscene:
|
|
if (director is { Playing: true } or { Blocked: true }||director is{Controlled:false}&&rocketship?.Mounted!=true)
|
|
{ sceneAudio?.StopSpeech(); SkipObservedDialogue("debug-menu"); debugMenu.Message = "CUTSCENE SKIPPED"; }
|
|
else debugMenu.Message = "NO ACTIVE CUTSCENE";
|
|
break;
|
|
case DebugAction.RefillEnergy when simulation != null:
|
|
simulation.Energy = 100; interactions?.UpdateEnergy(100); debugMenu.Message = "ENERGY REFILLED"; break;
|
|
case DebugAction.GiveJetpack when interactions != null:
|
|
interactions.Inventory.SetState(0, 3, 1); interactions.Inventory.SelectGadget(3);
|
|
debugMenu.Message = "JET PACK GIVEN AND SELECTED"; break;
|
|
case DebugAction.ApplySceneTask when storyTasks != null:
|
|
storyTasks.SetExisting("SCENE", debugMenu.SceneTask); debugMenu.Message = $"SCENE TASK SET TO {debugMenu.SceneTask}"; break;
|
|
case DebugAction.LoadScene when simulation != null && interactions != null && debugMenu.Scene is { } selected:
|
|
var prepared = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, ".."));
|
|
var selectedWorld = Mesh.LoadSceneJson(AssetPath.Resolve(prepared,
|
|
Path.GetFileNameWithoutExtension(selected.LevelFile) + "/scene.json"));
|
|
var selectedStart = GamLevel.Load(AssetPath.Resolve(root, "gam/" + selected.LevelFile)).FindStart(debugMenu.Start)!;
|
|
if (new SceneCollision(selectedWorld).GroundHeight(selectedStart.Position, 2500) == null)
|
|
{ debugMenu.Message = "SELECTED START HAS NO SUPPORTED FLOOR"; break; }
|
|
RequestTransition(new(selected.LevelFile, debugMenu.Start!, 0, -1)); debugMenu.Close(); break;
|
|
case DebugAction.Reset: ResetScene(); debugMenu.Close(); break;
|
|
case DebugAction.ForceControl when director != null:
|
|
director.DebugForceControl = !director.DebugForceControl;
|
|
debugMenu.Message = $"FORCE CONTROL {director.DebugForceControl}; CLOSE MENU TO RESUME"; break;
|
|
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.GiveInvisible when interactions != null:
|
|
interactions.Inventory.SetState(0,2,1); interactions.Inventory.SelectGadget(2);
|
|
debugMenu.Message = simulation?.GadgetMode == 2 ? "INVISIBLE EQUIPPED - RECHARGE 7 SECONDS, THEN FIRE"
|
|
: "INVISIBLE OWNED - ENERGY REQUIRED TO EQUIP"; break;
|
|
case DebugAction.UnequipGadget when interactions != null:
|
|
interactions.Inventory.SelectGadget(-1); debugMenu.Message = "GADGET UNEQUIPPED"; break;
|
|
case DebugAction.GiveBubble when interactions != null:
|
|
interactions.Inventory.SetState(0,0,1); interactions.Inventory.SelectGadget(0);
|
|
debugMenu.Message = simulation?.GadgetMode==0 ? "BUBBLE EQUIPPED - FIRE/UP ACCELERATES, JUMP BOUNCES HIGH"
|
|
: simulation?.Bubble.Collapsing==true ? "WAIT FOR THE BUBBLE TO FADE BEFORE REEQUIPPING" : "ENERGY REQUIRED TO EQUIP";
|
|
break;
|
|
case DebugAction.GiveBaseball when interactions != null:
|
|
interactions.Inventory.SetState(0,6,1); interactions.Inventory.SelectGadget(6);
|
|
debugMenu.Message="BASEBALL EQUIPPED - HOLD FIRE, UP/DOWN AIM, RELEASE TO THROW";
|
|
break;
|
|
case DebugAction.GiveAllGadgets when interactions != null:
|
|
for (var item = 0; item < 8; item++) interactions.Inventory.SetState(0,item,1);
|
|
debugMenu.Message = "ALL 8 GADGETS GIVEN - TAB/SPACE OPENS GADGETS DURING PLAY";
|
|
break;
|
|
case DebugAction.GiveRocketship when interactions != null:
|
|
interactions.Inventory.SetState(0,1,1);interactions.Inventory.SelectGadget(1);
|
|
debugMenu.Message=rocketship?.Mounted==true?"ROCKETSHIP EQUIPPED - ARROWS FLY, ENTER/T TURN, R ROLL":
|
|
"ROCKETSHIP GIVEN - SELECT ITS PRACTICE TILE TO FLY IN VR02";
|
|
break;
|
|
case DebugAction.GiveScooter when interactions != null:
|
|
interactions.Inventory.SetState(0,4,1);interactions.Inventory.SelectGadget(4);
|
|
debugMenu.Message=scooter?.Spawned==true?"SCOOTER SUMMONED AT GODDARD - WALK INTO IT TO MOUNT":
|
|
"SCOOTER GIVEN - AVAILABLE IN VR05 AND OUTSIDE";
|
|
break;
|
|
case DebugAction.GiveGrappler when interactions != null:
|
|
interactions.Inventory.SetState(0,7,1);interactions.Inventory.SelectGadget(7);
|
|
debugMenu.Message=simulation?.GadgetMode==7?"GRAPPLER EQUIPPED - FIRE ATTACH/REEL, JUMP DETACH":
|
|
"GRAPPLER GIVEN - SELECT ITS PRACTICE TILE TO USE IN VR08";
|
|
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, simulation.Rotation);
|
|
}
|
|
Vector2 Pointer()
|
|
{
|
|
Sdl.SDL_GetMouseState(out var x, out var y);
|
|
if (!Sdl.SDL_GetWindowSize(window, out var w, out var h) || w < 1 || h < 1) return Vector2.Zero;
|
|
return new UiViewport(renderer.Width, renderer.Height).InverseModal(new(x, y), (uint)w, (uint)h);
|
|
}
|
|
while (running)
|
|
{
|
|
scooterFixture?.BeforeFrame(count,(key,down)=>
|
|
{
|
|
var e=new Sdl.Event{Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
|
if(!Sdl.SDL_PushEvent(ref e))throw new InvalidOperationException(Sdl.Error);
|
|
},headless);
|
|
grapplerFixture?.BeforeFrame(count,(key,down)=>
|
|
{
|
|
var e=new Sdl.Event{Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
|
if(!Sdl.SDL_PushEvent(ref e))throw new InvalidOperationException(Sdl.Error);
|
|
},headless);
|
|
rocketFixture?.BeforeFrame(count,(key,down)=>
|
|
{
|
|
var e=new Sdl.Event{Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
|
if(!Sdl.SDL_PushEvent(ref e))throw new InvalidOperationException(Sdl.Error);
|
|
},headless);
|
|
baseballFixture?.BeforeFrame(count,(key,down)=>
|
|
{
|
|
var e=new Sdl.Event{Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
|
if(!Sdl.SDL_PushEvent(ref e))throw new InvalidOperationException(Sdl.Error);
|
|
},headless);
|
|
bubbleFixture?.BeforeFrame(count,(key,down)=>
|
|
{
|
|
var e=new Sdl.Event{Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
|
if(!Sdl.SDL_PushEvent(ref e))throw new InvalidOperationException(Sdl.Error);
|
|
},headless);
|
|
invisibleFixture?.BeforeFrame(count,(key,down)=>
|
|
{
|
|
var e = new Sdl.Event {Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
|
if(!Sdl.SDL_PushEvent(ref e)) throw new InvalidOperationException(Sdl.Error);
|
|
},headless);
|
|
if (gadgetWindowSmoke)
|
|
{
|
|
void Key(uint key,bool down) { var e=new Sdl.Event {Type=down?Sdl.KeyDown:Sdl.KeyUp,Scancode=key,Down=down?(byte)1:(byte)0};
|
|
if(!Sdl.SDL_PushEvent(ref e))throw new InvalidOperationException(Sdl.Error); }
|
|
void Click(bool down) { var e=new Sdl.Event {Type=down?Sdl.MouseButtonDown:Sdl.MouseButtonUp,MouseButton=1};
|
|
if(!Sdl.SDL_PushEvent(ref e))throw new InvalidOperationException(Sdl.Error); }
|
|
void Aim(Vector2 point) { Sdl.SDL_GetWindowSize(window,out var w,out var h);var v=new UiViewport(renderer.Width,renderer.Height);
|
|
var p=v.ToNdc(point+v.CenterOffset);Sdl.SDL_WarpMouseInWindow(window,(p.X+1)*w/2,(p.Y+1)*h/2); }
|
|
if(count==0)Key(43,true);
|
|
if(count==1){gadgetPausedSteps=simulation!.Steps;Key(44,true);}
|
|
if(count==2){gadgetChecks[0]=gadgetScreen!.Open&&simulation!.Steps==gadgetPausedSteps;Key(43,false);}
|
|
if(count==3){gadgetChecks[1]=gadgetScreen!.Open&&simulation!.Steps==gadgetPausedSteps;Key(41,true);}
|
|
if(count==4){gadgetChecks[2]=!gadgetScreen!.Open&&running;Key(41,false);Key(44,false);Key(43,true);}
|
|
if(count==5){Aim(new(200,380));Key(40,true);}
|
|
if(count==6){gadgetChecks[3]=!gadgetScreen!.Open&&interactions!.Inventory.SelectedGadget==3
|
|
&&simulation!.GadgetMode==-1&&gadgets?.Ray.Visible!=true;Key(40,false);Key(43,false);Key(43,true);}
|
|
if(count==7){Aim(new(520,120));Click(true);}
|
|
if(count==8){gadgetChecks[4]=gadgetScreen!.PracticeArmed;Click(false);Aim(new(50,120));Click(true);}
|
|
if(count==9){gadgetChecks[5]=!gadgetScreen!.Open&&!gadgetScreen.PracticeArmed&&transitionRequest==null;Key(43,false);Click(false);}
|
|
if(count==11){gadgetChecks[6]=simulation!.Jumps==0&&gadgets?.Ray.Visible!=true
|
|
&&Vector3.Distance(simulation.ActorRoot,gadgetEntry)<.1f;Key(43,true);Aim(new(200,380));}
|
|
}
|
|
if (shrinkSmoke && !headless && count == 0)
|
|
{
|
|
var fire = new Sdl.Event {Type=Sdl.KeyDown,Scancode=224,Down=1};
|
|
if (!Sdl.SDL_PushEvent(ref fire)) throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
if ((walkSmoke || jetpackSmoke) && !headless)
|
|
{
|
|
var requested = jetpackSmoke ? LabSimulation.JetpackSmokeInput(simulation!.Steps)
|
|
: LabSimulation.SmokeInput(simulation!.Steps);
|
|
foreach (var (scancode, down, previous) in new[] {
|
|
(82u, requested.Forward, injectedInput.Forward),
|
|
(81u, requested.Backward, injectedInput.Backward), (80u, requested.Left, injectedInput.Left),
|
|
(79u, requested.Right, injectedInput.Right), (jumpScancode, requested.Jump, injectedInput.Jump) })
|
|
{
|
|
if (down == previous) continue;
|
|
var injected = scancode == 0
|
|
? new Sdl.Event { Type = down ? Sdl.MouseButtonDown : Sdl.MouseButtonUp, MouseButton = 3 }
|
|
: new Sdl.Event { Type = down ? Sdl.KeyDown : Sdl.KeyUp, Scancode = scancode, Down = down ? (byte)1 : (byte)0 };
|
|
if (!Sdl.SDL_PushEvent(ref injected)) throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
injectedInput = requested;
|
|
}
|
|
while (!headless && Sdl.SDL_PollEvent(out var e))
|
|
{
|
|
observation?.RecordRawEvent(level?.Code ?? "preview", simulation?.Steps ?? 0,
|
|
e.Type, e.Type is Sdl.KeyDown or Sdl.KeyUp ? e.Scancode : null,
|
|
e.Type is Sdl.MouseButtonDown or Sdl.MouseButtonUp ? e.MouseButton : null,
|
|
e.Type is Sdl.KeyDown or Sdl.KeyUp ? e.Repeat : null);
|
|
if(scooterSmoke&&e.Type==Sdl.KeyDown)
|
|
sawScooterKeys|=e.Scancode switch{81=>1,82=>2,80=>4,225=>8,43=>16,60=>32,21=>64,_=>0};
|
|
if(grapplerSmoke&&e.Type==Sdl.KeyDown)
|
|
sawGrapplerKeys|=e.Scancode switch{80=>1,224=>2,82=>4,225=>8,60=>16,_=>0};
|
|
if(rocketSmoke&&e.Type==Sdl.KeyDown)
|
|
sawRocketKeys|=e.Scancode switch{82=>1,80=>2,40=>4,21=>8,43=>16,60=>32,_=>0};
|
|
if(baseballSmoke && e.Type==Sdl.KeyDown)
|
|
sawBaseballKeys|=e.Scancode switch{224=>1,80=>2,82=>4,43=>8,_=>0};
|
|
if (bubbleSmoke && e.Type==Sdl.KeyDown)
|
|
sawBubbleKeys |= e.Scancode switch {224=>1,80=>2,225=>4,43=>8,_=>0};
|
|
if (e.Type is Sdl.Quit or 0x210) running = false;
|
|
if (e.Type is Sdl.WindowResized or Sdl.WindowPixelSizeChanged) renderer.Resize();
|
|
if (e.Type is Sdl.WindowFocusLost or Sdl.WindowMinimized)
|
|
{ keys.Clear(); debugCapturedKeys.Clear(); gadgetHeldKeys.Clear(); gadgetArrows.Clear(); mouseJump = mouseFire = false; gadgets?.Stop(); active = false; stepClock.Reset(); }
|
|
if (e.Type is Sdl.WindowFocusGained or Sdl.WindowRestored)
|
|
{ active = true; stepClock.Reset(); last = clock.Elapsed.TotalSeconds; }
|
|
if (e.Type == Sdl.KeyUp) { gadgetHeldKeys.Remove(e.Scancode); gadgetArrows.Remove(e.Scancode); }
|
|
if (e.Type == Sdl.KeyUp && debugCapturedKeys.Remove(e.Scancode)) continue;
|
|
if (e.Type == Sdl.KeyDown && !debugMenu.Open && debugCapturedKeys.Contains(e.Scancode)) continue;
|
|
if (e.Type == Sdl.KeyDown && e.Scancode == DebugDiagnostics.ToggleKey)
|
|
{
|
|
debugCapturedKeys.Add(e.Scancode);
|
|
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);
|
|
if (e.Repeat == 0) { debugMenu.Toggle(storyTasks?.Get("SCENE") ?? 0); DebugInputBoundary(); }
|
|
continue;
|
|
}
|
|
if (debugMenu.Open)
|
|
{
|
|
if (e.Type == Sdl.KeyDown)
|
|
{
|
|
debugCapturedKeys.Add(e.Scancode);
|
|
DebugCommand(debugMenu.Key(e.Scancode, e.Repeat != 0));
|
|
if (!debugMenu.Open) DebugInputBoundary();
|
|
}
|
|
continue;
|
|
}
|
|
if (practice.Active && e.Type == Sdl.MouseButtonDown)
|
|
{ if (e.MouseButton == 1) practice.Click(Pointer()); keys.Clear(); mouseJump = mouseFire = false; stepClock.Reset(); continue; }
|
|
if (practice.Active && e.Type == Sdl.KeyDown)
|
|
{
|
|
if (e.Repeat == 0) practice.Key(e.Scancode, Pointer());
|
|
if (practiceWindowSmoke && e.Scancode == 17 && !practice.Active) sawPracticeDismiss = true;
|
|
keys.Clear(); mouseJump = mouseFire = false; stepClock.Reset(); continue;
|
|
}
|
|
if (e.Type == Sdl.KeyDown && e.Scancode is 43 or 44
|
|
&& !inspecting && simulation?.Noclip != true && !practice.Active && gadgetScreen != null
|
|
&& (gadgetScreen.Open || playerBinding?.InventoryControlled==true))
|
|
{
|
|
var first = gadgetHeldKeys.Count == 0;
|
|
gadgetHeldKeys.Add(e.Scancode);
|
|
if (first && e.Repeat == 0) gadgetScreen.Toggle(playerBinding?.InventoryControlled==true);
|
|
debugCapturedKeys.UnionWith(keys);
|
|
keys.Clear(); mouseJump = mouseFire = false; stepClock.Reset(); continue;
|
|
}
|
|
if (gadgetScreen?.Open == true)
|
|
{
|
|
if (e.Type == Sdl.KeyDown && e.Scancode is >= 79 and <= 82) gadgetArrows.Add(e.Scancode);
|
|
gadgetScreen.Point(Pointer(),level!.Code,storyTasks!.Get("SCENE"));
|
|
if (e.Type == Sdl.KeyDown) debugCapturedKeys.Add(e.Scancode);
|
|
if (e.Type == Sdl.KeyDown && e.Repeat == 0 && e.Scancode == 41) gadgetScreen.Close();
|
|
else if (e.Type == Sdl.MouseButtonDown && e.MouseButton is 1 or 3
|
|
|| e.Type == Sdl.KeyDown && e.Repeat == 0 && e.Scancode is 40 or 88 or 224 or 228 or 225 or 229 or 73 or 98)
|
|
gadgetScreen.Activate(level.Code,storyTasks.Get("SCENE"));
|
|
keys.Clear(); mouseJump = mouseFire = false; stepClock.Reset(); continue;
|
|
}
|
|
if (e.Type == Sdl.MouseButtonDown && e.MouseButton == 1) mouseFire = true;
|
|
if (e.Type == Sdl.MouseButtonUp && e.MouseButton == 1) mouseFire = false;
|
|
if (e.Type == Sdl.MouseButtonDown && e.MouseButton == 3)
|
|
{
|
|
mouseJump = true;
|
|
if (jumpScancode == 0) { if (jetpackSmoke) sawJetpackKeys |= 8; if (walkSmoke) sawWalkKeys |= 4; }
|
|
}
|
|
if (e.Type == Sdl.MouseButtonUp && e.MouseButton == 3) mouseJump = false;
|
|
if (e.Type == Sdl.KeyDown)
|
|
{
|
|
if ((shrinkSmoke || invisibleSmoke) && e.Scancode == 224) sawShrinkKey = true;
|
|
keys.Add(e.Scancode);
|
|
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 }&&rocketship?.Mounted!=true
|
|
&& (e.Scancode != 44 || simulation?.Noclip != true))
|
|
{ sceneAudio?.StopSpeech(); SkipObservedDialogue("sdl-key-" + e.Scancode); keys.Clear(); mouseJump = false; }
|
|
else if (e.Scancode == 41) running = false;
|
|
if (inspecting && e.Repeat == 0 && animations?.Select(e.Scancode) == true)
|
|
{
|
|
animationStarted = clock.Elapsed.TotalSeconds;
|
|
animationSwitched = true;
|
|
if (!Sdl.SDL_SetWindowTitle(window, animations.WindowTitle)) throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
if (e.Scancode == 6 && e.Repeat == 0 && originalStart != null)
|
|
{
|
|
ToggleCamera(); keys.Clear(); mouseJump = false; stepClock.Reset();
|
|
}
|
|
if (!inspecting && e.Scancode == 21 && e.Repeat == 0 && rocketship?.Mounted!=true)
|
|
{
|
|
ResetScene();
|
|
}
|
|
if (e.Scancode == 68 && e.Repeat == 0)
|
|
{
|
|
presentation.ToggleFullscreen();
|
|
}
|
|
}
|
|
if (e.Type == Sdl.KeyUp) keys.Remove(e.Scancode);
|
|
}
|
|
var now = clock.Elapsed.TotalSeconds;
|
|
var elapsed = now - last;
|
|
var dt = (float)Math.Min(elapsed, 0.1);
|
|
last = now;
|
|
if (gadgetScreen?.Open == true && !headless && !debugMenu.Open)
|
|
{
|
|
var axis = new Vector2((gadgetArrows.Contains(79) ? 1 : 0) - (gadgetArrows.Contains(80) ? 1 : 0),
|
|
(gadgetArrows.Contains(81) ? 1 : 0) - (gadgetArrows.Contains(82) ? 1 : 0));
|
|
var point = Pointer();
|
|
var moved = gadgetScreen.MovePointer(point,axis,dt);
|
|
if (moved != point && Sdl.SDL_GetWindowSize(window,out var menuWidth,out var menuHeight))
|
|
{
|
|
var viewport = new UiViewport(renderer.Width,renderer.Height);
|
|
var ndc = viewport.ToNdc(moved + viewport.CenterOffset);
|
|
Sdl.SDL_WarpMouseInWindow(window,(ndc.X + 1) * menuWidth / 2,(ndc.Y + 1) * menuHeight / 2);
|
|
}
|
|
}
|
|
if (debugMenu.Open) animationStarted += elapsed;
|
|
if (simulation != null && !debugMenu.Open && !inspecting && !practice.Active && gadgetScreen?.Open != true && (active || headless || walkSmoke || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || scooterSmoke || gadgetWindowSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke))
|
|
{
|
|
var steps = headless || walkSmoke || jetpackSmoke || shrinkSmoke || invisibleSmoke || bubbleSmoke || baseballSmoke || rocketSmoke || grapplerSmoke || scooterSmoke || gadgetWindowSmoke || practiceWindowSmoke || carlSmoke || controlPhaseSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke || toolsSmoke ? 1 : stepClock.Advance(elapsed);
|
|
for (var step = 0; step < steps; step++)
|
|
{
|
|
var input = carlSmoke || controlPhaseSmoke ? new PlayerInput(true, false, true, false, true)
|
|
: scooterSmoke && headless ? ScooterSmoke.Input(count,level!.Code)
|
|
: grapplerSmoke && headless ? GrapplerSmoke.Input(count)
|
|
: rocketSmoke && headless ? RocketshipSmoke.Input(count)
|
|
: baseballSmoke && headless ? BaseballSmoke.Input(count)
|
|
: bubbleSmoke && headless ? BubbleSmoke.Input(count)
|
|
: invisibleSmoke && headless ? new PlayerInput(false,false,false,false,false,Fire:count==1)
|
|
: shrinkSmoke && headless ? new PlayerInput(false,false,false,false,false,Fire:true)
|
|
: jetpackSmoke && headless ? LabSimulation.JetpackSmokeInput(simulation.Steps)
|
|
: walkSmoke && headless ? LabSimulation.SmokeInput(simulation.Steps) : new PlayerInput(
|
|
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),
|
|
mouseFire || keys.Contains(40) || keys.Contains(88) || keys.Contains(224) || keys.Contains(228),
|
|
RocketTurn:keys.Contains(40)||keys.Contains(88)||keys.Contains(23),RocketRoll:keys.Contains(21),RocketMouseRise:mouseJump,GrapplerEnter:keys.Contains(40)||keys.Contains(88));
|
|
gadgets?.StepBodies(FixedStepClock.Step);
|
|
baseballs?.StepBodies(FixedStepClock.Step);
|
|
var before = simulation.Position;
|
|
var powered = simulation.JetpackEffectVisible && !simulation.Grounded;
|
|
bool acceptsInput;
|
|
if (playerBinding != null) acceptsInput = playerBinding.Step(input);
|
|
else { simulation.Step(input); acceptsInput = true; }
|
|
observation?.RecordInput(level?.Code ?? "preview", simulation.Steps, input, acceptsInput,
|
|
director?.ControlledTag ?? (playerBinding == null ? "direct-simulation" : "script"));
|
|
observation?.RecordState(level?.Code ?? "preview", simulation.Steps, simulation.ActorRoot,
|
|
simulation.Rotation, simulation.Velocity, simulation.Grounded, simulation.MovementMode,
|
|
simulation.InputAfterPlayerUpdate, simulation.ControllerSteps, simulation.PhysicsSteps, simulation.EffectSteps);
|
|
ObserveControl("player_step");
|
|
scooterFixture?.Received(input);
|
|
grapplerFixture?.Received(input);
|
|
rocketFixture?.Received(input);
|
|
gadgets?.StepTimers(FixedStepClock.Step);
|
|
baseballs?.StepTargets(FixedStepClock.Step);
|
|
if (jetpackSmoke && powered)
|
|
{
|
|
poweredAirTravel += Vector2.Distance(new(before.X, before.Z), new(simulation.Position.X, simulation.Position.Z));
|
|
poweredAirTurn |= MathF.Abs(simulation.TurnRate) > 1;
|
|
}
|
|
interactions?.UpdateEnergy(simulation.Energy);
|
|
if (acceptsInput)
|
|
{
|
|
if (!simulation.Noclip)
|
|
{
|
|
director?.Touch(level!.Player!.Tag!, simulation.ActorRoot);
|
|
interactions?.Update(simulation.ActorRoot, simulation.InteractionRadius,rocketship is{Mounted:true}?rocketship.Actor:scooter is{Mounted:true}?scooter.Actor:null);
|
|
}
|
|
if (practice.Active) { keys.Clear(); mouseJump = false; stepClock.Reset(); break; }
|
|
if (!simulation.Noclip) mechanisms?.Update(simulation.ActorRoot, simulation.InteractionRadius);
|
|
}
|
|
mechanisms?.Step(FixedStepClock.Step);
|
|
foreach (var patrol in patrols.Values) patrol.Step(FixedStepClock.Step);
|
|
StepObservedDirector(FixedStepClock.Step);
|
|
objectivePanel?.Key(keys.Contains(18) && director is { Controlled: true, InventoryEnabled: true });
|
|
objectivePanel?.Step(FixedStepClock.Step, director?.ControlledTag != null, practice.Active);
|
|
var switched = director is { Controlled: false } && !simulation.Noclip
|
|
? animations!.SelectAction(director.FindActor(level!.Player!.Tag!)!.Animation)
|
|
: simulation.Pose==PlayerPose.Swing ? false : animations!.SelectPose(simulation.Pose);
|
|
if (switched) poseTime = 0;
|
|
poseTime += FixedStepClock.Step;
|
|
actorVisuals?.Update(FixedStepClock.Step, mesh);
|
|
soldierVisuals?.Update(FixedStepClock.Step,mesh);
|
|
spriteVisuals?.Step(FixedStepClock.Step);
|
|
}
|
|
characterModel = simulation.Model;
|
|
}
|
|
if (inspecting && !debugMenu.Open)
|
|
{
|
|
if (keys.Contains(80) || keys.Contains(4)) angle += dt;
|
|
if (keys.Contains(79) || keys.Contains(7)) angle -= dt;
|
|
if (keys.Contains(82) || keys.Contains(26)) elevation = Math.Min(elevation + dt, 1.4f);
|
|
if (keys.Contains(81) || keys.Contains(22)) elevation = Math.Max(elevation - dt, -1.4f);
|
|
if (keys.Contains(46) || keys.Contains(87)) radius *= MathF.Exp(-dt);
|
|
if (keys.Contains(45) || keys.Contains(86)) radius *= MathF.Exp(dt);
|
|
}
|
|
radius = Math.Max(radius, 0.01f);
|
|
var orbit = OrbitCamera.Create(target,radius,angle,elevation,(float)renderer.Width / renderer.Height);
|
|
var eye = orbit.Eye;
|
|
var view = originalCamera
|
|
? Matrix4x4.CreateLookAtLeftHanded(originalStart!.CameraPosition, originalStart.Position + new Vector3(0, 80, 0), Vector3.UnitY)
|
|
: orbit.View;
|
|
var renderEye = originalCamera ? originalStart!.CameraPosition : eye;
|
|
var renderTarget = originalCamera ? originalStart!.Position + new Vector3(0,80,0) : target;
|
|
if (simulation != null && !inspecting)
|
|
{
|
|
view = Matrix4x4.CreateLookAtLeftHanded(simulation.CameraEye, simulation.CameraTarget, Vector3.UnitY);
|
|
renderEye = simulation.CameraEye; renderTarget = simulation.CameraTarget;
|
|
}
|
|
if(!inspecting&&scooter is{Mounted:true})
|
|
{
|
|
renderEye=scooter.CameraEye;renderTarget=scooter.CameraTarget;
|
|
view=Matrix4x4.CreateLookAtLeftHanded(renderEye,renderTarget,Vector3.UnitY);
|
|
}
|
|
if(!inspecting&&rocketship is{Mounted:true})
|
|
{
|
|
renderEye=rocketship.CameraEye;renderTarget=rocketship.CameraTarget;
|
|
view=Matrix4x4.CreateLookAtLeftHanded(renderEye,renderTarget,Vector3.UnitY);
|
|
}
|
|
if (!inspecting && simulation?.Noclip != true && director?.CameraEye is { } storyEye && director.CameraTarget is { } storyTarget)
|
|
{
|
|
view = Matrix4x4.CreateLookAtLeftHanded(storyEye, storyTarget, Vector3.UnitY);
|
|
renderEye = storyEye; renderTarget = storyTarget;
|
|
}
|
|
staticVisuals?.Update(mesh);
|
|
if (debugMenu.Open || inspecting || practice.Active || director?.Controlled == false) gadgets?.Stop();
|
|
soldierVisuals?.Update(0,mesh);
|
|
if (gadgets != null) rayVisuals!.Update(mesh,gadgets.Ray,simulation!.Steps / 60d);
|
|
if (shrinkSmoke && gadgets!.Ray.Visible) shrinkPhaseMask |= 1 << gadgets.Ray.TexturePhase;
|
|
jetpackVisuals?.Update(mesh, simulation!);
|
|
bubbleVisuals?.Update(mesh,simulation!.Bubble,simulation.BubbleRoot,renderEye,renderTarget);
|
|
baseballVisuals?.Update(mesh,simulation!.Baseball.Projectiles,renderEye,renderTarget);
|
|
baseballAim?.Update(mesh,simulation!.Baseball,renderer.Width,renderer.Height);
|
|
if(rocketship!=null)rocketshipVisuals?.Update(mesh,rocketship,rocketship.FrameSteps/60d,simulation!.Appearance);
|
|
if(simulation?.Grappler is{} grapplerRender)grapplerVisuals?.Update(mesh,grapplerRender,simulation.ActorRoot,
|
|
new(simulation.Pitch,simulation.Yaw,simulation.Roll),poseTime,simulation.Appearance,renderEye,renderTarget);
|
|
if(scooter!=null)scooterVisuals?.Update(mesh,scooter,scooter.FrameSteps/60d,simulation!.Appearance);
|
|
spriteVisuals?.FaceCamera(renderEye, renderTarget, mesh);
|
|
objectivePanel?.Key(keys.Contains(18) && !debugMenu.Open && !inspecting && !practice.Active && gadgetScreen?.Open != true
|
|
&& director is { Controlled: true, InventoryEnabled: true });
|
|
objectivePanel?.Step(0, director?.ControlledTag != null, practice.Active);
|
|
hud?.Update(mesh, interactions!.CurrentObjective, level!.Code == "LV1B" && objectivePanel!.PadVisible && gadgetScreen?.Open != true,
|
|
practice.Active, objectivePanel!.YOffset, objectivePanel.ContentVisible, renderer.Width, renderer.Height);
|
|
invisibleMeter?.Update(mesh,simulation!.Invisible,renderer.Width,renderer.Height);
|
|
if (gadgetScreen != null)
|
|
{
|
|
if (!headless) gadgetScreen.Point(Pointer(),level!.Code,storyTasks!.Get("SCENE"));
|
|
gadgetOverlay!.Update(mesh,gadgetScreen.Canvases(level!.Code,storyTasks!.Get("SCENE")),renderer.Width,renderer.Height);
|
|
}
|
|
var gameplayProjection = originalCamera || simulation != null && !inspecting;
|
|
var cameraMode = simulation?.Noclip == true && !inspecting ? "NOCLIP" : !inspecting && director?.CameraEye != null ? "CUTSCENE"
|
|
: rocketship?.Mounted==true&&!inspecting?"ROCKETSHIP":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,
|
|
simulation?.Grounded ?? false, simulation?.Energy ?? 0, interactions?.Score ?? 0,
|
|
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, 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,
|
|
InvisibleRemaining = simulation?.Invisible.Remaining ?? 0, InvisibleRecharge = simulation?.Invisible.Recharge ?? 0,
|
|
Targetable = simulation?.Invisible.Targetable ?? true,
|
|
BubblePhase = simulation?.Bubble.Active==true ? "ACTIVE" : simulation?.Bubble.Expanding==true ? "EXPAND"
|
|
: simulation?.Bubble.Collapsing==true ? "FADE" : "OFF",
|
|
BaseballState=simulation==null?"OFF":$"{(simulation.Baseball.Equipped?"ON":"OFF")} AIM {simulation.Baseball.SavedPitch:F1} PENDING {simulation.Baseball.PendingThrow} THROWS {simulation.Baseball.Throws}",
|
|
GrapplerState=simulation?.Grappler is{} g?$"{(g.Attached?"ON":"OFF")} LEN {g.Memory.Length:F1} FIRST {g.Memory.FirstLength:F1} HIT {g.Contacts}":null,
|
|
ScooterState=scooter==null?null:$"{(scooter.Mounted?"RIDE":scooter.Spawned?"PARK":"OFF")} SPEED {scooter.Steering.Speed:F1} WHEELS {scooter.FrontSupports}/{scooter.RearSupports}",
|
|
RocketshipState=rocketship==null?null:$"{(rocketship.Mounted?"ON":"OFF")} SPEED {rocketship.Steering.Speed:F1} VY {rocketship.Velocity.Y:F1} HIT {rocketship.Contacts}",
|
|
BodyRadius = simulation?.InteractionRadius ?? 60, BodyFactor=simulation?.BodyFactor ?? 1.265f,
|
|
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,
|
|
simulation?.Jumps ?? 0, simulation?.WallHits ?? 0, interactions?.Inventory.State(0, 3) ?? 0,
|
|
simulation?.JetpackRemaining ?? 0, director?.CurrentShot ?? -1, director?.Blocked ?? false,
|
|
renderer.ValidationErrors, debugMenu.Open || practice.Active || inspecting || !active));
|
|
var liveDebugVisible = !debugMenu.Open && liveDebugLines.Length > 0;
|
|
debugOverlay.Update(mesh, debugMenu.Open ? debugView.Lines : liveDebugLines,
|
|
debugMenu.Open ? debugView.SelectedLine : -1, compact: !debugMenu.Open,
|
|
viewportWidth: renderer.Width, viewportHeight: renderer.Height);
|
|
var projection = gameplayProjection
|
|
? SceneProjection.CreateGameplay(level?.Code, (float)renderer.Width / renderer.Height)
|
|
: orbit.Projection;
|
|
projection.M22 *= -1;
|
|
if (animations != null)
|
|
{
|
|
animations.Current.Sample(simulation != null && !inspecting ? poseTime
|
|
: fixedTime ?? (headless ? count / 60.0 : now - animationStarted),
|
|
mesh.Vertices.AsSpan(characterOffset, animations.Current.Base.Vertices.Length), characterModel);
|
|
}
|
|
if (simulation != null && characterDraw != null)
|
|
{
|
|
characterDraw.Visible=rocketship?.Mounted!=true && scooter?.Mounted!=true && simulation.Grappler?.SwingPose!=true;
|
|
PlayerGadgetMaterial.Apply(characterDraw,simulation.Appearance);
|
|
var color=simulation.Appearance.Color;
|
|
for(var i=0;i<animations!.Current.Base.Vertices.Length;i++)
|
|
mesh.Vertices[characterOffset+i].Color *= new Vector3(color.X,color.Y,color.Z);
|
|
}
|
|
renderer.UpdateVertices(mesh.Vertices);
|
|
renderer.Render(view * projection);
|
|
if(simulation!=null&&((jetpackSmoke&&count is 74 or 109)||(walkSmoke&&count==89)))
|
|
{
|
|
var stage=jetpackSmoke?(count==74?"air-forward":"air-brake"):"air";
|
|
Console.WriteLine($"Movement {stage}: step={simulation.Steps}, Euler={simulation.Rotation}, target={simulation.FacingTarget}, speed={simulation.Speed:F3}, velocity={simulation.Velocity}.");
|
|
if(Option(args,"--screenshot") is{} capture)
|
|
renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm"));
|
|
}
|
|
if(scooterFixture!=null)
|
|
{
|
|
scooterFixture.AfterFrame(count);
|
|
if(ScooterSmoke.StageName(count) is{} stage&&Option(args,"--screenshot") is{} capture)
|
|
renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm"));
|
|
}
|
|
if(grapplerFixture!=null)
|
|
{
|
|
grapplerFixture.AfterFrame(count);
|
|
if(GrapplerSmoke.StageName(count) is{} stage&&Option(args,"--screenshot") is{} capture)
|
|
renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm"));
|
|
}
|
|
if(rocketFixture!=null)
|
|
{
|
|
rocketFixture.AfterFrame(count);
|
|
if(RocketshipSmoke.StageName(count) is{} stage&&Option(args,"--screenshot") is{} capture)
|
|
renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm"));
|
|
}
|
|
if(baseballFixture!=null)
|
|
{
|
|
baseballFixture.AfterFrame(count);
|
|
if(BaseballSmoke.StageName(count) is{} stage && Option(args,"--screenshot") is{} capture)
|
|
renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm"));
|
|
}
|
|
if (bubbleFixture!=null)
|
|
{
|
|
bubbleFixture.AfterFrame(count);
|
|
if(BubbleSmoke.StageName(count) is{} stage && Option(args,"--screenshot") is{} capture)
|
|
renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm"));
|
|
}
|
|
if (invisibleFixture != null)
|
|
{
|
|
invisibleFixture.AfterFrame(count,characterDraw!);
|
|
if (InvisibleSmoke.StageName(count) is { } stage && Option(args,"--screenshot") is { } capture)
|
|
renderer.SavePpm(Path.ChangeExtension(capture,$".{stage}.ppm"));
|
|
}
|
|
var presentedAt = clock.Elapsed.TotalSeconds;
|
|
diagnostics.ObserveFrame(presentedAt - lastPresentedAt);
|
|
lastPresentedAt = presentedAt;
|
|
count++;
|
|
if (controlPhaseSmoke && (count == 1 || count == 15) && Option(args, "--screenshot") is { } phaseCapture)
|
|
renderer.SavePpm(Path.ChangeExtension(phaseCapture, count == 1 ? ".locked-start.ppm" : ".locked-fall.ppm"));
|
|
if (controlPhaseSmoke && count == 16 && Option(args, "--screenshot") is { } returnCapture)
|
|
renderer.SavePpm(Path.ChangeExtension(returnCapture, ".returned.ppm"));
|
|
if (controlPhaseSmoke && count == 15)
|
|
{
|
|
phasesLocked = director is { Controlled: false, Playing: true }
|
|
&& simulation!.ControllerSteps == controlControllers && simulation.PhysicsSteps == controlPhysics + 15
|
|
&& simulation.EffectSteps == controlEffects + 15 && simulation.Jumps == controlJumps
|
|
&& simulation.Speed == 0 && simulation.TurnRate == controlTurn
|
|
&& simulation.Rotation == controlRotation && simulation.FacingTarget == controlRotation && !simulation.FacingDirty
|
|
&& simulation.ActorRoot.Y < controlEntry.Y && simulation.JetpackRemaining is > 0 and < 6.125f
|
|
&& simulation.Energy < 20 && Vector2.Distance(new(simulation.ActorRoot.X, simulation.ActorRoot.Z), new(controlEntry.X, controlEntry.Z)) < .001f;
|
|
CutsceneIdleSmoke.LandWhileLocked(playerBinding!, director!, simulation!);
|
|
sceneAudio?.StopSpeech();
|
|
SkipObservedDialogue("control-phase-fixture");
|
|
CutsceneIdleSmoke.VerifyReturn(playerBinding!, director!, simulation!);
|
|
controlControllers = simulation!.ControllerSteps;
|
|
}
|
|
if (controlPhaseSmoke && count == 30)
|
|
phasesResumed = director!.Controlled && simulation!.ControllerSteps == controlControllers + 15 && simulation.Travel > 1;
|
|
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)
|
|
{
|
|
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 Tap(uint key) { Push(key); Push(key, false); }
|
|
if (count == 1)
|
|
{
|
|
Push(82); Push(DebugDiagnostics.ToggleKey); Push(DebugDiagnostics.ToggleKey, repeat: true);
|
|
Push(DebugDiagnostics.ToggleKey, false);
|
|
if (!Sdl.SDL_SetWindowSize(window, 800, 600)) throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
if (count == 3)
|
|
diagnosticsShown = liveDebugVisible && !debugMenu.Open && sceneAudio?.Paused != true && liveDebugLines.Length == 12;
|
|
if (count == 4) Tap(DebugDiagnostics.ToggleKey);
|
|
if (count == 5) diagnosticsHidden = !liveDebugVisible && !diagnostics.Enabled && simulation!.Steps >= 5;
|
|
if (count == 6) Tap(DebugDiagnostics.ToggleKey);
|
|
if (count == 8)
|
|
{
|
|
diagnosticsMoves = liveDebugVisible && simulation!.Travel > diagnosticsInitialTravel + 5;
|
|
diagnosticsPausedSteps = simulation!.Steps;
|
|
Tap(DebugMenu.ToggleKey);
|
|
}
|
|
if (count == 9)
|
|
{
|
|
diagnosticsMenuPriority = debugMenu.Open && diagnostics.Enabled && !liveDebugVisible
|
|
&& simulation!.Steps == diagnosticsPausedSteps && sceneAudio?.Paused != false;
|
|
Tap(DebugDiagnostics.ToggleKey);
|
|
}
|
|
if (count == 10)
|
|
{
|
|
diagnosticsPreference = !diagnostics.Enabled && debugMenu.Open && sceneAudio?.Paused != false;
|
|
Tap(DebugDiagnostics.ToggleKey); Tap(DebugMenu.ToggleKey);
|
|
}
|
|
if (count == 11)
|
|
{
|
|
diagnosticsPreference &= diagnostics.Enabled && liveDebugVisible && !debugMenu.Open && sceneAudio?.Paused != true;
|
|
Push(82, false); Push(82);
|
|
}
|
|
if (count == 16) Tap(DebugDiagnostics.ToggleKey);
|
|
if (count == 18)
|
|
{
|
|
Tap(DebugMenu.ToggleKey); Tap(82); Tap(40); Tap(41); // Last menu row toggles the live panel.
|
|
}
|
|
if (count == 19) diagnosticsMenuToggle = diagnostics.Enabled && liveDebugVisible && !debugMenu.Open;
|
|
if (count == 20) Push(82, false);
|
|
}
|
|
if (debugSmoke)
|
|
{
|
|
void Push(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 Tap(uint key) { Push(key); Push(key, false); }
|
|
if (count == 1)
|
|
{
|
|
debugPausedRoot = simulation!.ActorRoot; debugPausedSteps = simulation.Steps;
|
|
director!.Trigger("neutron1a"); // Exercise opening the menu during an actual source MCA.
|
|
Push(82); Tap(DebugMenu.ToggleKey);
|
|
if (!Sdl.SDL_SetWindowSize(window, 800, 600)) throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
if (count == 3)
|
|
{
|
|
debugPauseObserved = debugMenu.Open && simulation!.ActorRoot == debugPausedRoot
|
|
&& simulation.Steps == debugPausedSteps && sceneAudio?.Paused != false && director!.Playing;
|
|
Tap(81); Tap(81); Tap(40); // Skip cutscene.
|
|
Tap(81); Tap(40); // Refill.
|
|
Tap(81); Tap(40); // Jet pack.
|
|
Tap(81); Tap(75); Tap(40); // SCENE30 ->40 via staged PageUp then apply.
|
|
}
|
|
if (count == 5)
|
|
{
|
|
debugActionsObserved = debugMenu.Open && director!.Controlled && !director.Playing
|
|
&& simulation!.Energy == 100 && interactions!.Inventory.State(0, 3) == 1
|
|
&& storyTasks!.Get("SCENE") == 40 && simulation.ActorRoot == debugPausedRoot
|
|
&& simulation.Steps == debugPausedSteps;
|
|
if (Option(args, "--screenshot") is { } debugScreenshot)
|
|
renderer.SavePpm(Path.ChangeExtension(debugScreenshot, ".open.ppm"));
|
|
}
|
|
if (count == 7) { Push(41); Push(41, repeat: true); Push(82, repeat: true); }
|
|
if (count == 8)
|
|
{
|
|
debugEscapeObserved = running && !debugMenu.Open && sceneAudio?.Paused != true
|
|
&& MathF.Abs(simulation!.ActorRoot.X - debugPausedRoot.X) < .001f
|
|
&& MathF.Abs(simulation.ActorRoot.Z - debugPausedRoot.Z) < .001f;
|
|
Push(41, false); Push(82, false); Push(82); // Release captured input, then a fresh movement press.
|
|
}
|
|
if (count == 12)
|
|
{
|
|
debugResumeObserved = simulation!.Steps > debugPausedSteps && simulation.Travel > 1;
|
|
Push(82, false);
|
|
director!.Trigger("neutron1a");
|
|
Tap(DebugMenu.ToggleKey);
|
|
for (var row = 5; row < 10; row++) Tap(81);
|
|
Tap(40); // Enable force control while the new MCA remains active.
|
|
}
|
|
if (count == 13) { debugForceTravel = simulation!.Travel; Tap(41); Push(82); }
|
|
if (count == 16)
|
|
debugForceObserved = director is { DebugForceControl: true, Controlled: true, Playing: true }
|
|
&& simulation!.Travel > debugForceTravel + .1f;
|
|
}
|
|
if (objectiveWindowSmoke)
|
|
{
|
|
if (count == 1) objectiveWasHidden = !objectivePanel!.PadVisible;
|
|
if (count == 60) objectiveReopened = objectivePanel!.ContentVisible;
|
|
if (count == 61) objectiveClosing = objectivePanel!.PadVisible && !objectivePanel.ContentVisible;
|
|
if (count is 1 or 2 or 60 or 61)
|
|
{
|
|
var down = count is 1 or 60;
|
|
var key = new Sdl.Event { Type = down ? Sdl.KeyDown : Sdl.KeyUp, Scancode = 18, Down = down ? (byte)1 : (byte)0 };
|
|
if (!Sdl.SDL_PushEvent(ref key)) throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
if (count == 1 && !Sdl.SDL_SetWindowSize(window, 800, 600)) throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
if (practiceWindowSmoke && count == 1)
|
|
{
|
|
sawPracticePause = practice.Active && simulation!.Steps == 0;
|
|
var key = new Sdl.Event { Type = Sdl.KeyDown, Scancode = 17, Down = 1 };
|
|
if (!Sdl.SDL_PushEvent(ref key) || !Sdl.SDL_SetWindowSize(window, 800, 600))
|
|
throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
if ((walkSmoke || jetpackSmoke) && !headless && count == 1 && !Sdl.SDL_SetWindowSize(window, 800, 600))
|
|
throw new InvalidOperationException(Sdl.Error);
|
|
if (smoke && count == 1)
|
|
{
|
|
var key = new Sdl.Event { Type = Sdl.KeyDown, Scancode = 79, Down = 1 };
|
|
if (!Sdl.SDL_PushEvent(ref key) || !Sdl.SDL_SetWindowSize(window, 800, 600))
|
|
throw new InvalidOperationException(Sdl.Error);
|
|
if (animations != null)
|
|
{
|
|
var cycle = new Sdl.Event { Type = Sdl.KeyDown, Scancode = 31, Down = 1 };
|
|
if (!Sdl.SDL_PushEvent(ref cycle)) throw new InvalidOperationException(Sdl.Error);
|
|
}
|
|
}
|
|
if ((smoke || walkSmoke || jetpackSmoke || practiceWindowSmoke || objectiveWindowSmoke || debugSmoke || diagnosticsSmoke) && renderer.Width == 800 && renderer.Height == 600) didResize = true;
|
|
if (frames > 0 && count >= frames) break;
|
|
if (transitionRequest != null) break;
|
|
}
|
|
if (Option(args, "--screenshot") is { } screenshot)
|
|
{
|
|
renderer.SavePpm(screenshot);
|
|
Console.WriteLine($"Saved Vulkan GPU readback: {screenshot}");
|
|
}
|
|
var pixels = renderer.ReadPixels();
|
|
var changed = 0;
|
|
for (var i = 0; i < pixels.Length; i += 4)
|
|
if (Math.Abs(pixels[i] - 31) + Math.Abs(pixels[i + 1] - 51) + Math.Abs(pixels[i + 2] - 76) > 6) changed++;
|
|
Console.WriteLine($"Rendered {count} frame(s), {changed} non-background pixels, {renderer.ValidationErrors} Vulkan validation error(s).");
|
|
if (simulation != null) Console.WriteLine(simulation.Report);
|
|
if (diagnostics.Enabled) Console.WriteLine($"Live debug overlay: enabled=True, frame samples={diagnostics.Frames}.");
|
|
if (diagnosticsSmoke)
|
|
{
|
|
Console.WriteLine($"Live debug SDL check: shown={diagnosticsShown}, hidden={diagnosticsHidden}, movement={diagnosticsMoves}, menu priority={diagnosticsMenuPriority}, preference={diagnosticsPreference}, menu toggle={diagnosticsMenuToggle}, resize800x600={didResize}.");
|
|
if (!diagnosticsShown || !diagnosticsHidden || !diagnosticsMoves || !diagnosticsMenuPriority
|
|
|| !diagnosticsPreference || !diagnosticsMenuToggle || !didResize) return 2;
|
|
}
|
|
if (debugSmoke)
|
|
{
|
|
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 is { ControllerSteps: 0, Jumps: 0, Speed: 0, TurnRate: 0 }
|
|
&& simulation.PhysicsSteps == simulation.Steps && simulation.EffectSteps == simulation.Steps && simulation.Steps >= frames;
|
|
Console.WriteLine($"Carl cutscene input lock with held move/turn/jump: {locked}; body/fire continue={simulation!.PhysicsSteps}/{simulation.EffectSteps}.");
|
|
if (!locked) return 2;
|
|
}
|
|
if (controlPhaseSmoke)
|
|
{
|
|
Console.WriteLine($"Control-phase fixture: upright current/destination with locked input and body/fire/energy continuing={phasesLocked}; held-input resumption={phasesResumed}.");
|
|
if (!phasesLocked || !phasesResumed) return 2;
|
|
}
|
|
if (objectiveSmoke) Console.WriteLine($"Objective panel: time={objectivePanel!.Elapsed:F3}, pad={objectivePanel.PadVisible}, content={objectivePanel.ContentVisible}, offset={objectivePanel.YOffset:F3}.");
|
|
if (objectiveWindowSmoke)
|
|
{
|
|
var timedOut = !objectivePanel!.PadVisible;
|
|
Console.WriteLine($"Objective SDL check: hidden={objectiveWasHidden}, O reopened={objectiveReopened}, O closed={objectiveClosing}, timed out={timedOut}, resize800x600={didResize}.");
|
|
if (!objectiveWasHidden || !objectiveReopened || !objectiveClosing || !timedOut || !didResize) return 2;
|
|
}
|
|
if (jetpackSmoke)
|
|
{
|
|
Console.WriteLine($"Powered jump: bursts={simulation!.Bursts}, remaining={simulation.JetpackRemaining:F3}, energy={simulation.Energy:F3}, grounded={simulation.Grounded}.");
|
|
Console.WriteLine($"Powered air steering: travel={poweredAirTravel:F2}, turned={poweredAirTurn}.");
|
|
if (!headless) Console.WriteLine($"Jetpack SDL keys received={sawJetpackKeys == 15}, resize800x600={didResize}, jump={jumpBinding}.");
|
|
if (simulation.Bursts == 0 || simulation.MaximumRise <= 137.62f || !simulation.Grounded
|
|
|| poweredAirTravel <= 20 || !poweredAirTurn || !headless && (sawJetpackKeys != 15 || !didResize)) return 2;
|
|
}
|
|
if (invisibleFixture != null)
|
|
{
|
|
Console.WriteLine(invisibleFixture.Report);
|
|
if (!headless) Console.WriteLine($"Invisible SDL primary received: {sawShrinkKey}.");
|
|
if (!invisibleFixture.Passed || !headless && !sawShrinkKey) return 2;
|
|
}
|
|
if(baseballFixture!=null)
|
|
{
|
|
Console.WriteLine(baseballFixture.Report);
|
|
if(!headless)Console.WriteLine($"Baseball SDL keys received: {sawBaseballKeys==15}.");
|
|
if(!baseballFixture.Passed || !headless && sawBaseballKeys!=15)return 2;
|
|
}
|
|
if(scooterFixture!=null)
|
|
{
|
|
Console.WriteLine(scooterFixture.Report);
|
|
if(!headless)Console.WriteLine($"Scooter SDL keys received: {sawScooterKeys==127}.");
|
|
if(!scooterFixture.Passed||!headless&&sawScooterKeys!=127)return 2;
|
|
}
|
|
if(grapplerFixture!=null)
|
|
{
|
|
Console.WriteLine(grapplerFixture.Report);
|
|
if(!headless)Console.WriteLine($"Grappler SDL keys received: {sawGrapplerKeys==31}.");
|
|
if(!grapplerFixture.Passed||!headless&&sawGrapplerKeys!=31)return 2;
|
|
}
|
|
if(rocketFixture!=null)
|
|
{
|
|
Console.WriteLine(rocketFixture.Report);
|
|
if(!headless)Console.WriteLine($"Rocketship SDL keys received: {sawRocketKeys==63}.");
|
|
if(!rocketFixture.Passed||!headless&&sawRocketKeys!=63)return 2;
|
|
}
|
|
if (bubbleFixture!=null)
|
|
{
|
|
Console.WriteLine(bubbleFixture.Report);
|
|
if(!headless)Console.WriteLine($"Bubble SDL input received: {sawBubbleKeys==15}.");
|
|
if(!bubbleFixture.Passed || !headless && sawBubbleKeys!=15)return 2;
|
|
}
|
|
if (shrinkSmoke)
|
|
{
|
|
var renderedHeight = soldierVisuals!.RenderedHeight(shrinkVictim!.Actor.Tag,mesh);
|
|
Console.WriteLine($"Shrink ray: target={shrinkVictim.Actor.Tag}, hits={gadgets!.ShrinkHits}, shrunk={shrinkVictim.Shrunk}, height={renderedHeight:F3}, remaining={shrinkVictim.Remaining:F3}, beam={gadgets.Ray.Visible}, phases={shrinkPhaseMask}, energy={simulation!.Energy:F3}, SDL fire={sawShrinkKey}.");
|
|
if (!shrinkVictim.Shrunk || gadgets.ShrinkHits < 1 || renderedHeight > 60 || !gadgets.Ray.Visible || shrinkPhaseMask != 7
|
|
|| simulation.Energy != 20 || !headless && !sawShrinkKey) return 2;
|
|
}
|
|
if (gadgetWindowSmoke)
|
|
{
|
|
Console.WriteLine($"Gadget menu SDL: shared-edge={gadgetChecks[0]}, pause={gadgetChecks[1]}, Escape={gadgetChecks[2]}, selection/fire-capture={gadgetChecks[3]}, practice={gadgetChecks[4]}, Return={gadgetChecks[5]}, stable-root={gadgetChecks[6]}.");
|
|
if (!gadgetChecks.All(c=>c)) return 2;
|
|
}
|
|
if (director != null)
|
|
{
|
|
Console.WriteLine($"Scene sequence: {director.CurrentTag ?? "none"}, shot={director.CurrentShot}, control={director.Controlled}, blocked={director.Blocked}, issues={director.Issues.Count}.");
|
|
foreach (var issue in director.Issues) Console.WriteLine($"Unrecovered scene behavior {issue.Tag}: {issue.Detail}");
|
|
foreach (var missing in actorVisuals!.UnsupportedAnimations) Console.WriteLine($"Unrecovered animation alias {missing}");
|
|
foreach (var missing in interactions!.Unsupported) Console.WriteLine(missing);
|
|
foreach (var missing in mechanisms!.Unsupported) Console.WriteLine(missing);
|
|
foreach (var (tag, patrol) in patrols)
|
|
Console.WriteLine($"Patrol {tag}: root={director.FindActor(tag)!.Position}, waypoint={patrol.CurrentWaypoint ?? "none"}, velocity={patrol.Velocity}; recovered support, provisional wall response.");
|
|
}
|
|
if (interactions != null && saveOutput is { } output)
|
|
{
|
|
Directory.CreateDirectory(Path.GetDirectoryName(output)!);
|
|
var snapshot = interactions.Snapshot() with { LevelCode = level!.Code, StartPoint = originalStart!.Tag!, StoredVector = returnRoot };
|
|
var temporary = output + "." + Guid.NewGuid().ToString("N") + ".tmp";
|
|
try
|
|
{
|
|
using (var stream = new FileStream(temporary, FileMode.CreateNew, FileAccess.Write, FileShare.None)) stream.Write(snapshot.Encode());
|
|
File.Move(temporary, output, true);
|
|
}
|
|
finally { if (File.Exists(temporary)) File.Delete(temporary); }
|
|
Console.WriteLine($"Wrote original-format checkpoint state: {output}");
|
|
}
|
|
if (transitionRequest != null && renderer.ValidationErrors == 0)
|
|
{
|
|
var prepared = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(scene!)!, ".."));
|
|
var nextScene = AssetPath.Resolve(prepared, Path.GetFileNameWithoutExtension(transitionRequest.LevelFile) + "/scene.json");
|
|
var nextArgs = new List<string>();
|
|
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" 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]);
|
|
if (toolsSmoke) nextArgs.AddRange(["--frames", "2"]);
|
|
// Deliberate test sentinels after the last departure tick: the
|
|
// destination assertion observes loader state, before grounding
|
|
// or controller/fire callbacks can legitimately change it.
|
|
if (practiceReturnSmoke && simulation != null)
|
|
simulation.ApplyRetainedLevelState(new(level!.Code, 3, 1, .625f, 6.125f));
|
|
continuation = new(nextArgs.ToArray(), (debugCheckpointToLoad ?? interactions!.Snapshot()) with {
|
|
StartPoint = transitionRequest.StartPoint, StoredVector = debugCheckpointToLoad?.StoredVector ?? returnRoot }, transitionRequest.Returning,
|
|
debugCheckpointToLoad == null ? simulation?.CaptureLevelState(interactions!.Inventory.SelectedGadget) : null);
|
|
observation?.RecordTransition(level!.Code, transitionRequest.LevelFile, simulation?.Steps ?? 0, transitionRequest.Returning);
|
|
Console.WriteLine($"Loading original destination: {transitionRequest.LevelFile}, start={transitionRequest.StartPoint}; fade behavior remains unreconstructed.");
|
|
}
|
|
if (walkSmoke && !simulation!.SmokePassed) return 2;
|
|
if (walkSmoke && !headless)
|
|
{
|
|
Console.WriteLine($"Walk SDL keyboard events received: {sawWalkKeys == 7}; resize800x600: {didResize}.");
|
|
if (sawWalkKeys != 7 || !didResize) return 2;
|
|
}
|
|
if (smoke)
|
|
{
|
|
Console.WriteLine($"SDL3 injected keyboard event received: {sawKey}; swapchain resized to 800x600: {didResize}.");
|
|
if (!sawKey || !didResize) return 2;
|
|
if (animations != null)
|
|
{
|
|
Console.WriteLine($"Animation preview switched by keyboard to {animations.Name}: {animationSwitched}; moving source samples: {animations.Current.HasVertexMotion}.");
|
|
if (!animationSwitched || !animations.Current.HasVertexMotion) return 2;
|
|
}
|
|
}
|
|
if (practiceWindowSmoke)
|
|
{
|
|
var resumed = !practice.Active && simulation!.Steps > 0;
|
|
Console.WriteLine($"Practice SDL check: paused={sawPracticePause}, N dismiss={sawPracticeDismiss}, resumed={resumed}, resize800x600={didResize}.");
|
|
if (!sawPracticePause || !sawPracticeDismiss || !resumed || !didResize) return 2;
|
|
}
|
|
return renderer.ValidationErrors > 0 || changed == 0 ? 2 : 0;
|
|
}
|
|
}
|
|
|
|
private const string WalkTitle = "Jimmy Neutron — lab checkpoint | Arrows move | Shift / Insert / right mouse jump | F1 menu | F2 overlay | R reset | C inspect";
|
|
|
|
private static int VerifyAssets(string root)
|
|
{
|
|
var pngs = Directory.GetFiles(root, "*", SearchOption.AllDirectories)
|
|
.Where(p => p.EndsWith(".png", StringComparison.OrdinalIgnoreCase)).ToArray();
|
|
foreach (var path in pngs) PngImage.Load(path);
|
|
var models = Directory.GetFiles(AssetPath.Resolve(root, "ASE"), "*", SearchOption.AllDirectories)
|
|
.Where(p => p.EndsWith(".ase", StringComparison.OrdinalIgnoreCase)).ToArray();
|
|
foreach (var path in models) AseMesh.Load(path);
|
|
Console.WriteLine($"Verified runtime decoders: {pngs.Length} PNG textures and {models.Length} ASE base meshes.");
|
|
return 0;
|
|
}
|
|
}
|