25 lines
717 B
C++
25 lines
717 B
C++
#include "components/StatsComponent.hpp"
|
|
|
|
void StatsComponent::Setup() {}
|
|
|
|
void StatsComponent::SetValue(float newValue) {
|
|
const float oldValue = value;
|
|
value = newValue;
|
|
if (context && oldValue != value) {
|
|
// notify listeners so the hud and gravity meter stay in sync with the updated value
|
|
context->EmitMeterChanged(oldValue, value);
|
|
}
|
|
}
|
|
|
|
void StatsComponent::AddValue(float delta) { SetValue(std::clamp(value + delta, 0.0f, maxValue)); }
|
|
|
|
void StatsComponent::Drain(float amount) { AddValue(-amount); }
|
|
|
|
void StatsComponent::AddStar() { ++stars; }
|
|
|
|
int StatsComponent::GetStarCount() const { return stars; }
|
|
|
|
void StatsComponent::Update(float) {}
|
|
|
|
void StatsComponent::Cleanup() {}
|