feat: split player movement into ground and noclip strategies

This commit is contained in:
2026-08-22 22:22:51 +02:00
parent 45c66ca7db
commit 76694a40f6
14 changed files with 123 additions and 62 deletions
@@ -0,0 +1,27 @@
using Godot;
namespace Game.Features.Players.Domain.Movement;
public sealed class GroundMovement(float moveSpeed, float jumpVelocity, float gravity) : IMovementStrategy
{
public Vector3 CalculateVelocity(Vector3 currentVelocity, MovementInput input)
{
Vector3 velocity = currentVelocity;
if (!input.IsOnFloor)
{
velocity.Y -= gravity * input.Delta;
}
else if (input.JumpPressed)
{
velocity.Y = jumpVelocity;
}
Vector3 moveDirection = input.Right * input.Direction.X + input.Back * input.Direction.Y;
Vector3 moveDirectionNormalized = moveDirection.Normalized();
velocity.X = moveDirectionNormalized.X * moveSpeed;
velocity.Z = moveDirectionNormalized.Z * moveSpeed;
return velocity;
}
}