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,40 @@
using Godot;
namespace PolarBears.PlayerControllerAddon;
public partial class Stamina : Node
{
[Export(PropertyHint.Range, "0,60,0.1,suffix:s,or_greater")]
public float MaxRunTime { get; set; } = 10.0f;
// Regenerate run time multiplier (when run 10s and RunTimeMultiplier = 2.0f to full regenerate you need 5s)
[Export(PropertyHint.Range, "0,10,0.01,or_greater")]
public float RunTimeMultiplier { get; set; } = 2.0f;
private float _currentRunTime;
private float _walkSpeed;
private float _sprintSpeed;
public void SetSpeeds(float walkSpeed, float sprintSpeed)
{
_walkSpeed = walkSpeed;
_sprintSpeed = sprintSpeed;
}
public float AccountStamina(double delta, float wantedSpeed)
{
if (Mathf.Abs(wantedSpeed - _sprintSpeed) > 0.1f)
{
float runtimeLeft = _currentRunTime - (RunTimeMultiplier * (float)delta);
if (_currentRunTime != 0.0f)
_currentRunTime = Mathf.Clamp(runtimeLeft, 0, MaxRunTime);
return wantedSpeed;
}
_currentRunTime = Mathf.Clamp(_currentRunTime + (float) delta, 0, MaxRunTime);
return _currentRunTime >= MaxRunTime ? _walkSpeed : wantedSpeed;
}
}