chore,gd: refactored project structure and started the mantle system

This commit is contained in:
2025-05-22 13:35:01 +02:00
parent 67461aa4be
commit a926840570
212 changed files with 422 additions and 409 deletions

View File

@ -0,0 +1,44 @@
using Godot;
namespace PolarBears.PlayerControllerAddon;
public partial class FieldOfView: Node3D
{
[Export(PropertyHint.Range, "0,180,0.1,degrees")]
public float BaseFov { get; set; } = 75.0f;
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
public float FovChangeFactor { get; set; } = 1.2f;
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
public float FovChangeSpeed { get; set; } = 6.25f;
private Camera3D _camera;
public void Init(Camera3D cam)
{
_camera = cam;
}
public struct FovParameters
{
public bool IsCrouchingHeight;
public float Delta;
public float SprintSpeed;
public Vector3 Velocity;
}
public void PerformFovAdjustment(FovParameters parameters)
{
float velocityClamped = Mathf.Clamp(
Mathf.Abs(parameters.Velocity.X) + Mathf.Abs(parameters.Velocity.Z),
0.5f,
parameters.SprintSpeed * 2.0f);
float targetFov = BaseFov + FovChangeFactor * velocityClamped;
if (parameters.IsCrouchingHeight){
targetFov = BaseFov - FovChangeFactor * velocityClamped;
}
_camera.Fov = Mathf.Lerp(_camera.Fov, targetFov, parameters.Delta * FovChangeSpeed);
}
}