Update tests for player movement validation and serialization, add migration for version 33 Player Start jump settings
This commit is contained in:
@@ -382,6 +382,67 @@ describe("player-locomotion", () => {
|
||||
expect(step?.verticalVelocity).toBeLessThan(0);
|
||||
});
|
||||
|
||||
it("disables jump-phase air movement when move while jumping is off", () => {
|
||||
const step = stepPlayerLocomotion({
|
||||
dt: 0.1,
|
||||
feetPosition: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
},
|
||||
movementYawRadians: 0,
|
||||
standingShape: FIRST_PERSON_PLAYER_SHAPE,
|
||||
verticalVelocity: 2,
|
||||
previousLocomotionState: createIdleRuntimeLocomotionState("airborne"),
|
||||
previousPlanarDisplacement: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
jumpBufferRemainingMs: 0,
|
||||
coyoteTimeRemainingMs: 0,
|
||||
jumpHoldRemainingMs: 0,
|
||||
crouched: false,
|
||||
wasJumpPressed: false,
|
||||
input: FORWARD_INPUT,
|
||||
movement: {
|
||||
...DEFAULT_MOVEMENT,
|
||||
jump: {
|
||||
...DEFAULT_MOVEMENT.jump,
|
||||
moveWhileJumping: false
|
||||
}
|
||||
},
|
||||
resolveMotion: (feetPosition, motion): ResolvedPlayerMotion => ({
|
||||
feetPosition: {
|
||||
x: feetPosition.x + motion.x,
|
||||
y: feetPosition.y + motion.y,
|
||||
z: feetPosition.z + motion.z
|
||||
},
|
||||
grounded: false,
|
||||
collisionCount: 0,
|
||||
groundCollisionNormal: null,
|
||||
collidedAxes: {
|
||||
x: false,
|
||||
y: false,
|
||||
z: false
|
||||
}
|
||||
}),
|
||||
resolveVolumeState: () => createVolumeState(),
|
||||
probeGround: () => ({
|
||||
grounded: false,
|
||||
distance: null,
|
||||
normal: null,
|
||||
slopeDegrees: null
|
||||
}),
|
||||
canOccupyShape: () => true
|
||||
});
|
||||
|
||||
expect(step).not.toBeNull();
|
||||
expect(step?.locomotionState.locomotionMode).toBe("airborne");
|
||||
expect(step?.planarDisplacement.z).toBeCloseTo(0);
|
||||
expect(step?.locomotionState.planarSpeed).toBeCloseTo(0);
|
||||
});
|
||||
|
||||
it("keeps falling when airborne input pushes into a wall and the pre-move probe flickers grounded", () => {
|
||||
let probeCount = 0;
|
||||
|
||||
@@ -452,6 +513,67 @@ describe("player-locomotion", () => {
|
||||
expect(step?.verticalVelocity).toBeLessThan(-1.5);
|
||||
});
|
||||
|
||||
it("disables falling air movement when move while falling is off", () => {
|
||||
const step = stepPlayerLocomotion({
|
||||
dt: 0.1,
|
||||
feetPosition: {
|
||||
x: 0,
|
||||
y: 1,
|
||||
z: 0
|
||||
},
|
||||
movementYawRadians: 0,
|
||||
standingShape: FIRST_PERSON_PLAYER_SHAPE,
|
||||
verticalVelocity: -2,
|
||||
previousLocomotionState: createIdleRuntimeLocomotionState("airborne"),
|
||||
previousPlanarDisplacement: {
|
||||
x: 0,
|
||||
y: 0,
|
||||
z: 0
|
||||
},
|
||||
jumpBufferRemainingMs: 0,
|
||||
coyoteTimeRemainingMs: 0,
|
||||
jumpHoldRemainingMs: 0,
|
||||
crouched: false,
|
||||
wasJumpPressed: false,
|
||||
input: FORWARD_INPUT,
|
||||
movement: {
|
||||
...DEFAULT_MOVEMENT,
|
||||
jump: {
|
||||
...DEFAULT_MOVEMENT.jump,
|
||||
moveWhileFalling: false
|
||||
}
|
||||
},
|
||||
resolveMotion: (feetPosition, motion): ResolvedPlayerMotion => ({
|
||||
feetPosition: {
|
||||
x: feetPosition.x + motion.x,
|
||||
y: feetPosition.y + motion.y,
|
||||
z: feetPosition.z + motion.z
|
||||
},
|
||||
grounded: false,
|
||||
collisionCount: 0,
|
||||
groundCollisionNormal: null,
|
||||
collidedAxes: {
|
||||
x: false,
|
||||
y: false,
|
||||
z: false
|
||||
}
|
||||
}),
|
||||
resolveVolumeState: () => createVolumeState(),
|
||||
probeGround: () => ({
|
||||
grounded: false,
|
||||
distance: null,
|
||||
normal: null,
|
||||
slopeDegrees: null
|
||||
}),
|
||||
canOccupyShape: () => true
|
||||
});
|
||||
|
||||
expect(step).not.toBeNull();
|
||||
expect(step?.locomotionState.locomotionMode).toBe("airborne");
|
||||
expect(step?.planarDisplacement.z).toBeCloseTo(0);
|
||||
expect(step?.locomotionState.planarSpeed).toBeCloseTo(0);
|
||||
});
|
||||
|
||||
it("sinks toward the water surface while keeping the head above water", () => {
|
||||
const step = stepPlayerLocomotion({
|
||||
dt: 0.1,
|
||||
|
||||
Reference in New Issue
Block a user