Fix lab cutscene control, landing steering, clipping and objective timeout
This commit is contained in:
1 parent
976e677019
commit
ca08c468ba
33 files changed
+871
-64
No files matched your search
@@ -11,6 +11,17 @@ namespace GamePort.Application;
|
||||
public static class LabRouteSmoke
|
||||
{
|
||||
public static void Run(GamLevel level, SceneDirector director, SceneInteractions interactions, Action? dismissPractice = null)
|
||||
{
|
||||
StartCarl(level, director, interactions, dismissPractice);
|
||||
director.Skip();
|
||||
if (!director.Controlled || interactions.Score != 150 || interactions.Inventory.State(0, 3) != 1
|
||||
|| interactions.CurrentObjective != 3)
|
||||
throw new InvalidOperationException("Original lab contact route did not reach the recovered exit state");
|
||||
interactions.Update(level.Entities.Single(e => e.Tag == "LABTONEIGH").Position);
|
||||
Console.WriteLine("Lab direct-contact integration: explanation, shrinkray, Carl callback and exit; score150, gadget3, objective3. Navigation was not exercised.");
|
||||
}
|
||||
|
||||
public static void StartCarl(GamLevel level, SceneDirector director, SceneInteractions interactions, Action? dismissPractice = null)
|
||||
{
|
||||
if (level.Code != "LV1B") throw new ArgumentException("Lab route check requires original LV1B");
|
||||
director.Skip();
|
||||
@@ -22,11 +33,7 @@ public static class LabRouteSmoke
|
||||
var carl = director.FindActor("C3DCARL")!;
|
||||
director.SyncActor(player, carl.Position, Vector3.Zero);
|
||||
interactions.Update(carl.Position);
|
||||
director.Skip();
|
||||
if (!director.Controlled || interactions.Score != 150 || interactions.Inventory.State(0, 3) != 1
|
||||
|| interactions.CurrentObjective != 3)
|
||||
throw new InvalidOperationException("Original lab contact route did not reach the recovered exit state");
|
||||
interactions.Update(level.Entities.Single(e => e.Tag == "LABTONEIGH").Position);
|
||||
Console.WriteLine("Lab direct-contact integration: explanation, shrinkray, Carl callback and exit; score150, gadget3, objective3. Navigation was not exercised.");
|
||||
if (!director.Playing || director.Controlled || director.CurrentTag != "neutron1a")
|
||||
throw new InvalidOperationException("Carl dialogue did not start with original control lock");
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ public sealed class SceneHud
|
||||
|
||||
/// <summary>Writes the final merged buffer, including when later visual composers copied these vertices.</summary>
|
||||
public void Update(Mesh destination, int currentObjective, bool objectivesVisible, bool practiceVisible,
|
||||
float objectiveYOffset = -69)
|
||||
float objectiveYOffset = -69, bool objectiveContentVisible = true)
|
||||
{
|
||||
if (!float.IsFinite(objectiveYOffset) || objectiveYOffset < -480 || objectiveYOffset > 480)
|
||||
throw new ArgumentOutOfRangeException(nameof(objectiveYOffset));
|
||||
@@ -83,7 +83,8 @@ public sealed class SceneHud
|
||||
var draw = destination.Draws.FirstOrDefault(d => d.FirstIndex == quad.FirstIndex && d.ScreenSpace
|
||||
&& d.IndexCount == 6) ?? throw new ArgumentException("Destination omits HUD draws", nameof(destination));
|
||||
draw.Visible = quad.Canvas == 169 ? practiceVisible : objectivesVisible && currentObjective is >= 1 and <= 3
|
||||
&& (quad.Canvas == 156 || quad.Canvas == 119 + currentObjective || quad.Canvas == 82 + currentObjective);
|
||||
&& (quad.Canvas == 156 || objectiveContentVisible
|
||||
&& (quad.Canvas == 119 + currentObjective || quad.Canvas == 82 + currentObjective));
|
||||
var digit = quad.Canvas is >= 83 and <= 85;
|
||||
var x = quad.Canvas == 169 ? 210f : digit ? 393f : 384f;
|
||||
var y = quad.Canvas == 169 ? 210f : (quad.Canvas == 156 ? 380f : digit ? 450f : 448f) + objectiveYOffset;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Numerics;
|
||||
|
||||
namespace GamePort.Application;
|
||||
|
||||
/// <summary>Original geometry-layer clipping overrides from level initializers.
|
||||
/// The port currently combines both geometry layers, so it uses their larger far
|
||||
/// limit. Layer masks and LV4B's task-driven fog/clip transition remain separate.
|
||||
/// </summary>
|
||||
public static class SceneProjection
|
||||
{
|
||||
public const float NearPlane = 20;
|
||||
public const float FieldOfView = 0xAAA / 16384f * MathF.Tau;
|
||||
|
||||
public static float FarPlane(string? levelCode) => levelCode?.ToUpperInvariant() switch
|
||||
{
|
||||
"LV1A" => 5000,
|
||||
"LV1B" or "LV1C" or "LV4A" or "LV4D" or "LEV7" => 10000,
|
||||
"LV1D" or "LV1E" => 120000,
|
||||
"LV1F" => 15000,
|
||||
"LEV1" => 28000,
|
||||
"LV2A" => 3500,
|
||||
"LV2B" or "LEV2" => 50000,
|
||||
"LV3A" => 80000,
|
||||
"LV3B" or "LV3C" or "LV3D" or "LV3E" or "LEV3" => 40000,
|
||||
"LV4B" => 7200,
|
||||
"LV4C" or "LEV4" => 30000,
|
||||
"LV5A" or "LV5B" => 16000,
|
||||
"LEV5" => 12000,
|
||||
"LV6A" or "LEV6" => 4000,
|
||||
"VR01" or "VR02" or "VR03" or "VR04" or "VR05" or "VR06" or "VR07" or "VR08" => 50000,
|
||||
_ => 3200 // Original OMediaLayer constructor default, not a universal level setting.
|
||||
};
|
||||
|
||||
/// <summary>Original positive-Z,0..1 depth perspective. Caller applies the
|
||||
/// existing Vulkan viewport Y flip, just as for the inspection projection.
|
||||
/// </summary>
|
||||
public static Matrix4x4 CreateGameplay(string? levelCode, float aspect)
|
||||
{
|
||||
if (!float.IsFinite(aspect) || aspect <= 0) throw new ArgumentOutOfRangeException(nameof(aspect));
|
||||
return Matrix4x4.CreatePerspectiveFieldOfViewLeftHanded(FieldOfView, aspect, NearPlane, FarPlane(levelCode));
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,9 @@ public sealed class LabSimulation
|
||||
float lateral = 0;
|
||||
if (Grounded)
|
||||
{
|
||||
//437B9E..437BAC uses an interface pointer: interface+614 is
|
||||
//complete+6D4. Normal grounded/released input clears air turn.
|
||||
if (!input.Jump) TurnRate = 0;
|
||||
InteractionRadius = 60; // Jimmy's ordinary grounded update42469B.
|
||||
float yawDelta = 0;
|
||||
if (input.Left) { yawDelta += 20; lateral = -1000; Speed = RecoveredMotion.AddSpeed(Speed); }
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
namespace GamePort.Game;
|
||||
|
||||
/// <summary>
|
||||
/// Objective pad timing from EXE406F50/407070. Layout offset belongs to the
|
||||
/// separate gadget UI layout; O controls the animation timer, not that offset.
|
||||
/// Current rendering has one selected objective rather than the full44 flags.
|
||||
/// </summary>
|
||||
public sealed class ObjectivePanel
|
||||
{
|
||||
public const float SlideInSeconds = .7f; //48D974.
|
||||
public const float SlideScale = 1.4285714626312256f; //48D970, original float reciprocal.
|
||||
public const float SlideDistance = 100; //48D96C.
|
||||
public const float HoldUntilSeconds = 7; //Integer4EC498.
|
||||
public const float ExitDuration = 1.7f; //48D940.
|
||||
public const float HiddenInitialTime = 20; //4018A8/423EC6.
|
||||
public static float ExitEnd => HoldUntilSeconds + ExitDuration;
|
||||
|
||||
private bool objectiveKeyHeld;
|
||||
private bool openingSoundPlayed;
|
||||
private bool renderAllowed;
|
||||
public int CurrentObjective { get; private set; }
|
||||
public float Elapsed { get; private set; } = HiddenInitialTime;
|
||||
public float LayoutOffset { get; }
|
||||
public bool PadVisible => renderAllowed && CurrentObjective > 0 && Elapsed < ExitEnd;
|
||||
public bool ContentVisible => PadVisible && Elapsed >= SlideInSeconds && Elapsed < HoldUntilSeconds;
|
||||
public float SlideOffset => Elapsed < SlideInSeconds ? (1 - Elapsed * SlideScale) * SlideDistance
|
||||
: Elapsed < HoldUntilSeconds ? 0 : (Elapsed - HoldUntilSeconds) * SlideScale * SlideDistance;
|
||||
public float YOffset => LayoutOffset + (PadVisible ? SlideOffset : 0);
|
||||
public event Action<int>? SoundEffect;
|
||||
|
||||
/// <summary>Loaded selector starts hidden; source initializes its independent timer to20.</summary>
|
||||
public ObjectivePanel(int initialObjective = 0, float layoutOffset = -69)
|
||||
{
|
||||
if (initialObjective is < 0 or > 43) throw new ArgumentOutOfRangeException(nameof(initialObjective));
|
||||
if (!float.IsFinite(layoutOffset) || layoutOffset is < -480 or > 480)
|
||||
throw new ArgumentOutOfRangeException(nameof(layoutOffset));
|
||||
CurrentObjective = initialObjective;
|
||||
LayoutOffset = layoutOffset;
|
||||
}
|
||||
|
||||
/// <summary>Source406F50: positive assignments reset timing, even for the same selector.</summary>
|
||||
public void Select(int objective)
|
||||
{
|
||||
if (objective <= 0) return;
|
||||
if (objective > 43) throw new ArgumentOutOfRangeException(nameof(objective));
|
||||
CurrentObjective = objective;
|
||||
Show();
|
||||
}
|
||||
|
||||
/// <summary>Also used after source practice No404D97 resets the panel timer to0.</summary>
|
||||
public void Show() => Elapsed = 0;
|
||||
|
||||
/// <summary>407142..407198 edge latch. O hides an opening/stationary panel, otherwise opens it.</summary>
|
||||
public void Key(bool held)
|
||||
{
|
||||
if (held && !objectiveKeyHeld)
|
||||
Elapsed = Elapsed >= 0 && Elapsed < HoldUntilSeconds ? HoldUntilSeconds : 0;
|
||||
objectiveKeyHeld = held;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// UI clock4043D9..4043F9 advances only with a non-null controlled entity.
|
||||
/// Modal4044D7..404504 forces exit time and hides pad/content. Pause/focus policy
|
||||
/// is explicit: caller supplies0 elapsed while its UI clock is paused.
|
||||
/// </summary>
|
||||
public void Step(float seconds, bool hasControlledActor = true, bool modalActive = false)
|
||||
{
|
||||
if (!float.IsFinite(seconds) || seconds < 0) throw new ArgumentOutOfRangeException(nameof(seconds));
|
||||
if (hasControlledActor)
|
||||
{
|
||||
var next = Elapsed + seconds;
|
||||
if (!float.IsFinite(next)) throw new ArgumentOutOfRangeException(nameof(seconds));
|
||||
Elapsed = next;
|
||||
}
|
||||
if (modalActive) Elapsed = ExitEnd;
|
||||
renderAllowed = hasControlledActor && !modalActive;
|
||||
if (!PadVisible) return;
|
||||
if (Elapsed < SlideInSeconds)
|
||||
{
|
||||
if (openingSoundPlayed) return;
|
||||
openingSoundPlayed = true;
|
||||
SoundEffect?.Invoke(216); //4070BA..4070CA.
|
||||
}
|
||||
else if (Elapsed < HoldUntilSeconds) openingSoundPlayed = false;
|
||||
}
|
||||
}
|
||||
@@ -320,7 +320,8 @@ public sealed class SceneDirector
|
||||
|
||||
private void StartMulti(GamEntity entity)
|
||||
{
|
||||
SetControl(entity);
|
||||
// MCA's PlayerControlled is its completion target (4311F0), not an
|
||||
// activation grant. Each valid shot clears control at43159E..4315A7.
|
||||
Toggle(entity);
|
||||
if (skipping) { FinishMulti(entity); return; }
|
||||
StartCamera(entity, 0, applyCommon: false);
|
||||
@@ -350,6 +351,7 @@ public sealed class SceneDirector
|
||||
Block(entity, $"Camera target {targetTag} absent", entity.Text("NextTrigger"));
|
||||
return;
|
||||
}
|
||||
if (index >= 0) ControlledTag = null;
|
||||
var database = entity.Text("SoundDatabase") ?? "none";
|
||||
var duration = soundDuration(database, sound);
|
||||
if (!double.IsFinite(duration) || duration < 0)
|
||||
|
||||
+87
-19
@@ -77,6 +77,10 @@ internal static class Program
|
||||
--smoke-practice-transition Headless lab-to-VR04 practice transition
|
||||
--smoke-practice-window SDL practice pause/dismiss/resize check (12 frames)
|
||||
--smoke-jetpack 300-step powered steering/jump check in VR04
|
||||
--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-objective-panel Show original lab objective; --story-time tests timeout
|
||||
--smoke-objective-window SDL O-key reopen/close/timeout 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
|
||||
@@ -211,12 +215,21 @@ internal static class Program
|
||||
var animationPath = Option(args, "--animation");
|
||||
var walkSmoke = args.Contains("--smoke-walk");
|
||||
var jetpackSmoke = args.Contains("--smoke-jetpack");
|
||||
var carlSmoke = args.Contains("--smoke-carl-cutscene");
|
||||
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");
|
||||
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 || practiceWindowSmoke;
|
||||
|| args.Contains("--skip-intro") || jetpackSmoke || practiceWindowSmoke || carlSmoke || 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.");
|
||||
@@ -239,7 +252,7 @@ internal static class Program
|
||||
SceneHud? hud = null;
|
||||
JetpackVisuals? jetpackVisuals = null;
|
||||
var practice = new PracticePrompt();
|
||||
var objectiveOffset = -69f;
|
||||
ObjectivePanel? objectivePanel = null;
|
||||
var patrols = new Dictionary<string, ActorPatrol>(StringComparer.OrdinalIgnoreCase);
|
||||
LevelTransition? transitionRequest = null;
|
||||
var characterOffset = mesh.Vertices.Length;
|
||||
@@ -268,6 +281,8 @@ internal static class Program
|
||||
var tasks = new TaskStates(save.Tasks);
|
||||
director = new SceneDirector(level!, tasks, resources.Duration);
|
||||
interactions = new SceneInteractions(director, tasks, save, level!.Code);
|
||||
objectivePanel = new ObjectivePanel(interactions.CurrentObjective);
|
||||
interactions.ObjectiveChanged += objectivePanel.Select;
|
||||
simulation!.Energy = interactions.Energy;
|
||||
simulation.JetpackInventoryState = () => interactions.Inventory.State(0, 3);
|
||||
mechanisms = new SceneMechanisms(director);
|
||||
@@ -275,7 +290,7 @@ internal static class Program
|
||||
interactions.PracticeRequested += practice.Show;
|
||||
practice.Chosen += (mode, accepted) =>
|
||||
{
|
||||
if (!accepted) return;
|
||||
if (!accepted) { objectivePanel.Show(); return; }
|
||||
// Player43B5A0 receives current/requested GAM and latest STRT tag
|
||||
// as return context;42AF00's runtime checkpoint is separate.
|
||||
interactions.SetReturnContext(Path.GetFileName(levelPath!), originalStart!.Tag!);
|
||||
@@ -324,7 +339,10 @@ internal static class Program
|
||||
var storyTime = double.Parse(Option(args, "--story-time") ?? "0", System.Globalization.CultureInfo.InvariantCulture);
|
||||
if (!double.IsFinite(storyTime) || storyTime < 0 || storyTime > 3600 || storyTime > 0 && !headless)
|
||||
throw new ArgumentException("Story time must be0..3600 seconds in headless mode.");
|
||||
var frames = int.Parse(Option(args, "--frames") ?? (walkSmoke ? "240" : jetpackSmoke ? "300" : headless ? "1" : "0"));
|
||||
var frames = int.Parse(Option(args, "--frames") ?? (walkSmoke ? "240" : jetpackSmoke ? "300" : objectiveWindowSmoke ? "180" : carlSmoke ? "60" : headless ? "1" : "0"));
|
||||
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.");
|
||||
@@ -355,6 +373,7 @@ internal static class Program
|
||||
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);
|
||||
mechanisms!.Sound += (actor, id, loop) => sceneAudio.Effect(id, loop ? actor.Tag : null);
|
||||
mechanisms.StopSound += actor => sceneAudio.StopLoop(actor.Tag);
|
||||
@@ -377,6 +396,15 @@ internal static class Program
|
||||
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)
|
||||
{
|
||||
director.Skip();
|
||||
director.Touch(level!.Player!.Tag!, level.Entities.Single(e => e.Tag == "teleportexplanation").Position);
|
||||
director.Skip();
|
||||
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)
|
||||
{
|
||||
if ((!headless && !practiceWindowSmoke) || level?.Code != "LV1B") throw new ArgumentException("Practice smoke requires the original lab");
|
||||
@@ -392,6 +420,7 @@ internal static class Program
|
||||
foreach (var patrol in patrols.Values) patrol.Step(FixedStepClock.Step);
|
||||
mechanisms!.Step(FixedStepClock.Step);
|
||||
director.Step(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);
|
||||
@@ -416,6 +445,9 @@ internal static class Program
|
||||
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;
|
||||
@@ -436,10 +468,12 @@ internal static class Program
|
||||
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), (225u, requested.Jump, injectedInput.Jump) })
|
||||
(79u, requested.Right, injectedInput.Right), (jumpScancode, requested.Jump, injectedInput.Jump) })
|
||||
{
|
||||
if (down == previous) continue;
|
||||
var injected = new Sdl.Event { Type = down ? Sdl.KeyDown : Sdl.KeyUp, Scancode = scancode, Down = down ? (byte)1 : (byte)0 };
|
||||
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;
|
||||
@@ -460,19 +494,21 @@ internal static class Program
|
||||
if (practiceWindowSmoke && e.Scancode == 17 && !practice.Active) sawPracticeDismiss = true;
|
||||
keys.Clear(); mouseJump = false; stepClock.Reset(); continue;
|
||||
}
|
||||
if (e.Type == Sdl.MouseButtonDown && e.MouseButton == 3) mouseJump = true;
|
||||
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)
|
||||
{
|
||||
keys.Add(e.Scancode);
|
||||
if (walkSmoke) sawWalkKeys |= e.Scancode == 82 ? 1 : e.Scancode == 79 ? 2 : e.Scancode == 225 ? 4 : 0;
|
||||
if (jetpackSmoke) sawJetpackKeys |= e.Scancode == 82 ? 1 : e.Scancode == 81 ? 2 : e.Scancode == 80 ? 4 : e.Scancode == 225 ? 8 : 0;
|
||||
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 })
|
||||
{ sceneAudio?.StopSpeech(); director.Skip(); keys.Clear(); mouseJump = false; }
|
||||
else if (e.Scancode == 41) running = false;
|
||||
if (e.Scancode == 18 && e.Repeat == 0 && director is { Controlled: true, InventoryEnabled: true })
|
||||
objectiveOffset = objectiveOffset == -69 ? 0 : -69;
|
||||
if (inspecting && e.Repeat == 0 && animations?.Select(e.Scancode) == true)
|
||||
{
|
||||
animationStarted = clock.Elapsed.TotalSeconds;
|
||||
@@ -510,12 +546,13 @@ internal static class Program
|
||||
var elapsed = now - last;
|
||||
var dt = (float)Math.Min(elapsed, 0.1);
|
||||
last = now;
|
||||
if (simulation != null && !inspecting && !practice.Active && (active || headless || walkSmoke || jetpackSmoke))
|
||||
if (simulation != null && !inspecting && !practice.Active && (active || headless || walkSmoke || jetpackSmoke || objectiveWindowSmoke))
|
||||
{
|
||||
var steps = headless || walkSmoke || jetpackSmoke || practiceWindowSmoke ? 1 : stepClock.Advance(elapsed);
|
||||
var steps = headless || walkSmoke || jetpackSmoke || practiceWindowSmoke || carlSmoke || objectiveWindowSmoke ? 1 : stepClock.Advance(elapsed);
|
||||
for (var step = 0; step < steps; step++)
|
||||
{
|
||||
var input = jetpackSmoke && headless ? LabSimulation.JetpackSmokeInput(simulation.Steps)
|
||||
var input = carlSmoke ? new PlayerInput(true, false, true, false, true)
|
||||
: jetpackSmoke && headless ? LabSimulation.JetpackSmokeInput(simulation.Steps)
|
||||
: walkSmoke && headless ? LabSimulation.SmokeInput(simulation.Steps) : new PlayerInput(
|
||||
keys.Contains(82), keys.Contains(81), keys.Contains(80), keys.Contains(79),
|
||||
mouseJump || keys.Contains(225) || keys.Contains(229) || keys.Contains(73) || keys.Contains(98));
|
||||
@@ -539,6 +576,8 @@ internal static class Program
|
||||
mechanisms?.Step(FixedStepClock.Step);
|
||||
foreach (var patrol in patrols.Values) patrol.Step(FixedStepClock.Step);
|
||||
director?.Step(FixedStepClock.Step);
|
||||
objectivePanel?.Key(keys.Contains(18) && director is { Controlled: true, InventoryEnabled: true });
|
||||
objectivePanel?.Step(FixedStepClock.Step, director?.ControlledTag != null, practice.Active);
|
||||
var switched = director is { Controlled: false }
|
||||
? animations!.SelectAction(director.FindActor(level!.Player!.Tag!)!.Animation)
|
||||
: animations!.SelectPose(simulation.Pose);
|
||||
@@ -579,10 +618,13 @@ internal static class Program
|
||||
staticVisuals?.Update(mesh);
|
||||
jetpackVisuals?.Update(mesh, simulation!);
|
||||
spriteVisuals?.FaceCamera(renderEye, renderTarget, mesh);
|
||||
hud?.Update(mesh, interactions!.CurrentObjective, level!.Code == "LV1B" && director!.Controlled, practice.Active, objectiveOffset);
|
||||
var far = level?.Code == "LV1B" ? 10000 : 3200;
|
||||
objectivePanel?.Key(keys.Contains(18) && !inspecting && !practice.Active
|
||||
&& director is { Controlled: true, InventoryEnabled: true });
|
||||
objectivePanel?.Step(0, director?.ControlledTag != null, practice.Active);
|
||||
hud?.Update(mesh, interactions!.CurrentObjective, level!.Code == "LV1B" && objectivePanel!.PadVisible,
|
||||
practice.Active, objectivePanel!.YOffset, objectivePanel.ContentVisible);
|
||||
var projection = originalCamera || simulation != null && !inspecting
|
||||
? Matrix4x4.CreatePerspectiveFieldOfViewLeftHanded(0xAAA / 16384f * MathF.Tau, (float)renderer.Width / renderer.Height, 20, far)
|
||||
? SceneProjection.CreateGameplay(level?.Code, (float)renderer.Width / renderer.Height)
|
||||
: Matrix4x4.CreatePerspectiveFieldOfView(MathF.PI / 3, (float)renderer.Width / renderer.Height, Math.Max(radius / 10000, 0.01f), radius * 20);
|
||||
projection.M22 *= -1;
|
||||
if (animations != null)
|
||||
@@ -596,6 +638,19 @@ internal static class Program
|
||||
count++;
|
||||
audio?.Pump();
|
||||
sceneAudio?.Pump();
|
||||
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;
|
||||
@@ -616,7 +671,7 @@ internal static class Program
|
||||
if (!Sdl.SDL_PushEvent(ref cycle)) throw new InvalidOperationException(Sdl.Error);
|
||||
}
|
||||
}
|
||||
if ((smoke || walkSmoke || jetpackSmoke || practiceWindowSmoke) && renderer.Width == 800 && renderer.Height == 600) didResize = true;
|
||||
if ((smoke || walkSmoke || jetpackSmoke || practiceWindowSmoke || objectiveWindowSmoke) && renderer.Width == 800 && renderer.Height == 600) didResize = true;
|
||||
if (frames > 0 && count >= frames) break;
|
||||
if (transitionRequest != null) break;
|
||||
}
|
||||
@@ -631,11 +686,24 @@ internal static class Program
|
||||
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 (carlSmoke)
|
||||
{
|
||||
var locked = director is { Controlled: false, Playing: true, CurrentTag: "neutron1a" } && simulation!.Steps == 0;
|
||||
Console.WriteLine($"Carl cutscene input lock with held move/turn/jump: {locked}.");
|
||||
if (!locked) 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}.");
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user