linter: varios

This commit is contained in:
2025-10-24 17:12:57 +02:00
parent 9979f31b4a
commit 636e4d932a
11 changed files with 136 additions and 106 deletions

View File

@@ -1,10 +1,11 @@
#pragma once
#include <algorithm> // Para std::max
class Cooldown {
public:
Cooldown(float first_delay_s = 0.0F, float repeat_delay_s = 0.0F)
: first_delay_s_(first_delay_s), repeat_delay_s_(repeat_delay_s),
remaining_s_(0.0F), held_before_(false) {}
: first_delay_s_(first_delay_s), repeat_delay_s_(repeat_delay_s) {}
// Llamar cada frame con delta en segundos (float)
void update(float delta_s) {
@@ -13,12 +14,14 @@ public:
return;
}
remaining_s_ -= delta_s;
if (remaining_s_ < 0.0F) remaining_s_ = 0.0F;
remaining_s_ = std::max(remaining_s_, 0.0F);
}
// Llamar cuando el input está activo. Devuelve true si debe ejecutarse la acción ahora.
bool tryConsumeOnHeld() {
if (remaining_s_ > 0.0F) return false;
auto tryConsumeOnHeld() -> bool {
if (remaining_s_ > 0.0F) {
return false;
}
float delay = held_before_ ? repeat_delay_s_ : first_delay_s_;
remaining_s_ = delay;
@@ -32,7 +35,7 @@ public:
remaining_s_ = 0.0F;
}
bool empty() const { return remaining_s_ == 0.0F; }
[[nodiscard]] auto empty() const -> bool { return remaining_s_ == 0.0F; }
// Fuerza un valor en segundos (útil para tests o resets)
void forceSet(float seconds) { remaining_s_ = seconds > 0.0F ? seconds : 0.0F; }
@@ -40,6 +43,6 @@ public:
private:
float first_delay_s_;
float repeat_delay_s_;
float remaining_s_;
bool held_before_;
float remaining_s_{0.0F};
bool held_before_{false};
};