Restore original airborne steering for jumps and jetpack bursts
This commit is contained in:
1 parent
b58138d7ba
commit
976e677019
16 files changed
+357
-54
No files matched your search
@@ -15,7 +15,10 @@ var tests = new (string Name, Action Check)[]
|
||||
("jump rises, falls and returns to support", JumpLanding),
|
||||
("held zero-burn jump repeats and release stops repetition", HeldJump),
|
||||
("airborne jump re-press rearms landing without a double jump", JumpRepress),
|
||||
("air mode ignores arrow steering", AirControl),
|
||||
("air input accelerates, brakes, turns and coasts at source limits", AirArithmetic),
|
||||
("ordinary jump responds to airborne arrows", AirControl),
|
||||
("powered jetpack starts moving and turns from stationary takeoff", JetpackControl),
|
||||
("powered steering remains independent of presentation rate", JetpackReplayRates),
|
||||
("reset restores spawn, camera and counters", Reset),
|
||||
("ten-minute simulation remains finite and supported", LongRun),
|
||||
("original lab placement, floor, walking and jump checkpoint", () => OriginalLab(project, originals)),
|
||||
@@ -162,25 +165,93 @@ static void HeldJump()
|
||||
Check(simulation.Jumps == jumpCount + 1 && !simulation.Grounded, "new grounded press starts another jump");
|
||||
}
|
||||
|
||||
static void AirArithmetic()
|
||||
{
|
||||
var input = new PlayerInput(true, false, true, false, true);
|
||||
var first = AirSteering.Step(0, 0, input, 1f / 60);
|
||||
Near(first.Speed, 30, 0, "air forward adds source30 per invocation");
|
||||
Near(first.TurnRate, 100f / 60, .00001f, "air turn ramps by100*dt");
|
||||
var both = AirSteering.Step(0, 0, input with { Right = true }, 1f / 60);
|
||||
Check(both == first, "Left wins over Right in air");
|
||||
var turn = 0f;
|
||||
for (var i = 0; i < 90; i++) turn = AirSteering.Step(0, turn, input, 1f / 60).TurnRate;
|
||||
Near(turn, 30, 0, "normal airborne turn limit30");
|
||||
for (var i = 0; i < 30; i++) turn = AirSteering.Step(0, turn, default, 1f / 60).TurnRate;
|
||||
Near(turn, 0, 0, "released turn decays to0 without crossing");
|
||||
var coast = 600f;
|
||||
for (var i = 0; i < 10; i++) coast = AirSteering.Step(coast, 0, default, 1f / 60).Speed;
|
||||
Near(coast, 530, 0, "unpowered input coasts after half-decay crosses max*10/11");
|
||||
var braking = new PlayerInput(false, true, false, false, false);
|
||||
for (var i = 0; i < 40; i++) coast = AirSteering.Step(coast, 0, braking, 1f / 60).Speed;
|
||||
Near(coast, 0, 0, "Down brakes to0 without reversing");
|
||||
Near(AirSteering.Step(100, 0, input with { Backward = true }, 1f / 60).Speed, 112.5f, 0,
|
||||
"air forward increment precedes Down braking");
|
||||
Near(AirSteering.Step(-10, 0, braking, 1f / 60).Speed, 0, 0, "negative takeoff speed brakes toward0");
|
||||
Throws<ArgumentOutOfRangeException>(() => AirSteering.Step(0, 0, default, float.NaN));
|
||||
}
|
||||
|
||||
static void AirControl()
|
||||
{
|
||||
var idleInput = FlatSimulation();
|
||||
var arrowInput = FlatSimulation();
|
||||
var simulation = FlatSimulation();
|
||||
simulation.Step(new(false, false, false, false, true));
|
||||
var origin = simulation.Position;
|
||||
for (var i = 0; i < 20; i++)
|
||||
{
|
||||
idleInput.Step(new(true, false, false, false, false));
|
||||
arrowInput.Step(new(true, false, false, false, false));
|
||||
Check(!simulation.Grounded, "ordinary jump steering fixture stays in air");
|
||||
simulation.Step(new(true, false, true, false, false));
|
||||
}
|
||||
idleInput.Step(new(true, false, false, false, true));
|
||||
arrowInput.Step(new(true, false, false, false, true));
|
||||
for (var i = 0; i < 24; i++)
|
||||
Check(simulation.Speed == 600 && simulation.Yaw > 5 && Vector2.Distance(
|
||||
new(origin.X, origin.Z), new(simulation.Position.X, simulation.Position.Z)) > 75,
|
||||
"airborne arrows must accelerate and turn an initially stationary jump");
|
||||
}
|
||||
|
||||
static void JetpackControl()
|
||||
{
|
||||
var straight = FlatSimulation();
|
||||
var left = FlatSimulation();
|
||||
var right = FlatSimulation();
|
||||
foreach (var simulation in new[] { straight, left, right })
|
||||
{
|
||||
Check(!idleInput.Grounded && !arrowInput.Grounded, "comparison remains airborne");
|
||||
idleInput.Step(default);
|
||||
arrowInput.Step(new(true, true, true, true, false));
|
||||
SameState(arrowInput, idleInput, "ordinary arrows ignored while airborne");
|
||||
simulation.JetpackInventoryState = () => 1;
|
||||
for (var i = 0; i < 40; i++) simulation.Step(new(false, false, false, false, true));
|
||||
Check(simulation.JetpackEffectVisible && !simulation.Grounded && simulation.Bursts == 1,
|
||||
"stationary takeoff reaches an active powered burst before directional input");
|
||||
}
|
||||
var initialHeight = left.Position.Y;
|
||||
for (var i = 0; i < 60; i++)
|
||||
{
|
||||
straight.Step(new(true, false, false, false, true));
|
||||
left.Step(new(true, false, true, false, true));
|
||||
right.Step(new(true, false, false, true, true));
|
||||
Check(!left.Grounded && left.JetpackEffectVisible, "steering occurs during powered flight");
|
||||
}
|
||||
Check(straight.Position.Z > 400 && left.Yaw > 20 && right.Yaw < -20,
|
||||
"powered Up moves from rest and Left/Right turn while airborne");
|
||||
Check(left.Position.X < -50 && right.Position.X > 50 && left.Position.Y > initialHeight,
|
||||
"powered paths change direction and retain vertical lift");
|
||||
var beforeBrake = left.Speed;
|
||||
for (var i = 0; i < 40; i++) left.Step(new(false, true, false, false, true));
|
||||
Check(beforeBrake > 0 && left.Speed == 0 && left.TurnRate == 0 && !left.Grounded,
|
||||
"Down brakes during active burst and released turn settles");
|
||||
left.Reset();
|
||||
Near(left.TurnRate, 0, 0, "reset clears accumulated airborne turn");
|
||||
}
|
||||
|
||||
static void JetpackReplayRates()
|
||||
{
|
||||
LabSimulation? reference = null;
|
||||
foreach (var rate in new[] { 60, 120, 144 })
|
||||
{
|
||||
var simulation = FlatSimulation();
|
||||
simulation.LevelCode = "VR04";
|
||||
var clock = new FixedStepClock();
|
||||
for (var frame = 0; frame < rate * 3; frame++)
|
||||
for (var step = clock.Advance(1.0 / rate); step > 0; step--)
|
||||
simulation.Step(new(simulation.Steps >= 40, false, simulation.Steps >= 80, false, true));
|
||||
Check(simulation.Bursts == 1 && simulation.Travel > 500, "render-rate replay exercises powered steering");
|
||||
if (reference != null) SameState(simulation, reference, "powered steering presentation rate");
|
||||
reference = simulation;
|
||||
}
|
||||
Near(arrowInput.Speed, 600, 0, "takeoff speed retained in air");
|
||||
}
|
||||
|
||||
static void JumpRepress()
|
||||
@@ -287,6 +358,7 @@ static void SameState(LabSimulation actual, LabSimulation expected, string messa
|
||||
NearVector(actual.CameraEye, expected.CameraEye, .0001f, $"{message}: camera");
|
||||
Near(actual.Yaw, expected.Yaw, .0001f, $"{message}: yaw");
|
||||
Near(actual.Speed, expected.Speed, 0, $"{message}: speed");
|
||||
Near(actual.TurnRate, expected.TurnRate, 0, $"{message}: turn rate");
|
||||
Check(actual.Grounded == expected.Grounded && actual.Pose == expected.Pose && actual.Jumps == expected.Jumps
|
||||
&& actual.Landings == expected.Landings, $"{message}: movement state/counters");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user