Expand debug system pages and add noclip exploration
This commit is contained in:
1 parent
b915a2c2e4
commit
d7838980fd
20 files changed
+628
-47
No files matched your search
@@ -3,7 +3,8 @@ using GamePort.Assets;
|
||||
|
||||
namespace GamePort.Game;
|
||||
|
||||
public readonly record struct PlayerInput(bool Forward, bool Backward, bool Left, bool Right, bool Jump);
|
||||
public readonly record struct PlayerInput(bool Forward, bool Backward, bool Left, bool Right, bool Jump,
|
||||
bool Rise = false, bool Descend = false, bool StrafeLeft = false, bool StrafeRight = false, bool Fast = false);
|
||||
public enum PlayerPose { Idle, Run, Backpedal, Jump, Fall, Fly }
|
||||
|
||||
/// <summary>
|
||||
@@ -23,6 +24,11 @@ public sealed class LabSimulation
|
||||
private int movementMode;
|
||||
private JetpackBurstState jumpState;
|
||||
private bool forceFall;
|
||||
private Vector3 noclipEntry;
|
||||
private float noclipEntryYaw;
|
||||
public bool Noclip { get; private set; }
|
||||
public bool HasNoclipEntry { get; private set; }
|
||||
public float NoclipSpeed { get; set; } = 600;
|
||||
public Func<int>? JetpackInventoryState { get; set; }
|
||||
public string LevelCode { get; set; } = "LV1B";
|
||||
public int GadgetMode { get; set; } = -1;
|
||||
@@ -30,6 +36,8 @@ public sealed class LabSimulation
|
||||
public float InteractionRadius { get; private set; } = 60;
|
||||
public bool JetpackEffectVisible { get; private set; }
|
||||
public float JetpackRemaining => jumpState.EffectRemaining;
|
||||
public int JumpState => jumpState.JumpState;
|
||||
public float JumpHoldSeconds => jumpState.HoldSeconds;
|
||||
public int Bursts { get; private set; }
|
||||
public float BodyHeight { get; }
|
||||
public Vector3 Position { get; private set; } // Feet, not original actor root.
|
||||
@@ -43,7 +51,8 @@ public sealed class LabSimulation
|
||||
public float Speed { get; private set; }
|
||||
public float TurnRate { get; private set; }
|
||||
public bool Grounded { get; private set; }
|
||||
public PlayerPose Pose => pendingImpulse.Y > 0 ? PlayerPose.Jump
|
||||
public PlayerPose Pose => Noclip ? Velocity.LengthSquared() > 0 ? PlayerPose.Fly : PlayerPose.Idle
|
||||
: pendingImpulse.Y > 0 ? PlayerPose.Jump
|
||||
: Grounded ? Speed < -1 ? PlayerPose.Backpedal : Speed > 1 ? PlayerPose.Run : PlayerPose.Idle
|
||||
: jumpState.JumpState == 3 && jumpState.EffectRemaining > 0 ? PlayerPose.Fly
|
||||
: !forceFall && Velocity.Y > 0 ? PlayerPose.Jump : PlayerPose.Fall;
|
||||
@@ -92,6 +101,7 @@ public sealed class LabSimulation
|
||||
forceFall = JetpackEffectVisible = false;
|
||||
InteractionRadius = 60; Bursts = 0;
|
||||
Grounded = true;
|
||||
Noclip = HasNoclipEntry = false;
|
||||
Steps = Jumps = Landings = WallHits = 0;
|
||||
Travel = MaximumRise = 0;
|
||||
CameraEye = DesiredEye().Eye;
|
||||
@@ -118,6 +128,7 @@ public sealed class LabSimulation
|
||||
|
||||
public void Step(PlayerInput input)
|
||||
{
|
||||
if (Noclip) { StepNoclip(input); return; }
|
||||
//47E554 global body integration precedes473740 registry callbacks.
|
||||
// This reconstructs the player/input/fire partial order, not the full
|
||||
// scene registry, original cadence or original collision response.
|
||||
@@ -130,6 +141,58 @@ public sealed class LabSimulation
|
||||
Steps++;
|
||||
}
|
||||
|
||||
/// <summary>Modern debug movement; never serialized into original save state.</summary>
|
||||
public bool SetNoclip(bool enabled)
|
||||
{
|
||||
if (enabled == Noclip) return false;
|
||||
if (enabled)
|
||||
{
|
||||
noclipEntry = Position; noclipEntryYaw = Yaw; HasNoclipEntry = true;
|
||||
}
|
||||
var returned = !enabled && !collision.CanOccupy(Position, BodyRadius, BodyHeight);
|
||||
if (returned) { Position = noclipEntry; Yaw = targetYaw = noclipEntryYaw; }
|
||||
Noclip = enabled;
|
||||
StopDebugMotion();
|
||||
Grounded = false;
|
||||
CameraEye = DesiredEye().Eye;
|
||||
return returned;
|
||||
}
|
||||
|
||||
public void StopDebugMotion()
|
||||
{
|
||||
Velocity = pendingImpulse = Vector3.Zero;
|
||||
Speed = TurnRate = extraAirAcceleration = lateralContribution = 0;
|
||||
jumpState = default; movementMode = 0; forceFall = JetpackEffectVisible = false;
|
||||
targetYaw = Yaw;
|
||||
}
|
||||
|
||||
public bool ReturnToNoclipEntry()
|
||||
{
|
||||
if (!HasNoclipEntry) return false;
|
||||
Position = noclipEntry; Yaw = targetYaw = noclipEntryYaw;
|
||||
StopDebugMotion(); Grounded = false; CameraEye = DesiredEye().Eye;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void StepNoclip(PlayerInput input)
|
||||
{
|
||||
if (!float.IsFinite(NoclipSpeed) || NoclipSpeed <= 0 || NoclipSpeed > 10000)
|
||||
throw new ArgumentOutOfRangeException(nameof(NoclipSpeed));
|
||||
const float dt = FixedStepClock.Step;
|
||||
Yaw = targetYaw = (Yaw + ((input.Left ? 1 : 0) - (input.Right ? 1 : 0)) * 90 * dt) % 360;
|
||||
var (sin, cos) = Trig(Yaw);
|
||||
var direction = new Vector3(-sin, 0, cos) * ((input.Forward ? 1 : 0) - (input.Backward ? 1 : 0))
|
||||
+ new Vector3(cos, 0, sin) * ((input.StrafeRight ? 1 : 0) - (input.StrafeLeft ? 1 : 0))
|
||||
+ Vector3.UnitY * ((input.Rise ? 1 : 0) - (input.Descend ? 1 : 0));
|
||||
if (direction.LengthSquared() > 1) direction = Vector3.Normalize(direction);
|
||||
Velocity = direction * NoclipSpeed * (input.Fast ? 3 : 1);
|
||||
var delta = Velocity * dt;
|
||||
Position += delta; Travel += new Vector2(delta.X, delta.Z).Length();
|
||||
MaximumRise = Math.Max(MaximumRise, Position.Y - startFloor);
|
||||
Grounded = false; Steps++;
|
||||
CameraEye = DesiredEye().Eye;
|
||||
}
|
||||
|
||||
private void StepInput(PlayerInput input)
|
||||
{
|
||||
const float dt = FixedStepClock.Step;
|
||||
@@ -241,6 +304,7 @@ public sealed class LabSimulation
|
||||
{
|
||||
var (sin, cos) = Trig(Yaw);
|
||||
var eye = ActorRoot + new Vector3(sin * 350, 180, -cos * 350);
|
||||
if (Noclip) return (eye, 1); // Debug exploration also bypasses camera obstruction.
|
||||
if (cameraRay == null) return (collision.ClipCamera(CameraTarget, eye), 1);
|
||||
//43B820: query from the computed look target; first accepted static hit
|
||||
//moves desired eye25% toward look and returns follow gain1.5. No radius
|
||||
|
||||
Reference in new issue
Block a user