metaforce/Runtime/World/CRippleManager.cpp

46 lines
1.2 KiB
C++
Raw Permalink Normal View History

#include "Runtime/World/CRippleManager.hpp"
2021-04-10 08:42:06 +00:00
namespace metaforce {
2018-12-08 05:30:43 +00:00
CRippleManager::CRippleManager(int maxRipples, float alpha) : x14_alpha(alpha) { Init(maxRipples); }
2018-12-08 05:30:43 +00:00
void CRippleManager::Init(int maxRipples) {
x4_ripples.resize(maxRipples, CRipple(kInvalidUniqueId, zeus::skZero3f, 0.f));
2018-12-08 05:30:43 +00:00
for (CRipple& r : x4_ripples)
r.SetTime(9999.f);
}
2018-12-08 05:30:43 +00:00
void CRippleManager::Update(float dt) {
for (CRipple& ripple : x4_ripples) {
ripple.SetTime(ripple.GetTime() + dt);
if (ripple.GetTime() > 9999.f)
ripple.SetTime(9999.f);
}
}
2018-12-08 05:30:43 +00:00
float CRippleManager::GetLastRippleDeltaTime(TUniqueId rippler) const {
float res = 9999.f;
for (const CRipple& r : x4_ripples)
if (r.GetUniqueId() == rippler)
if (r.GetTime() < res)
res = r.GetTime();
return res;
}
2018-12-08 05:30:43 +00:00
void CRippleManager::AddRipple(const CRipple& ripple) {
float maxTime = 0.f;
auto oldestRipple = x4_ripples.end();
for (auto it = x4_ripples.begin(); it != x4_ripples.end(); ++it)
if (it->GetTime() > maxTime) {
oldestRipple = it;
maxTime = it->GetTime();
}
2018-12-08 05:30:43 +00:00
if (oldestRipple != x4_ripples.end()) {
*oldestRipple = ripple;
x0_maxTimeFalloff = std::max(x0_maxTimeFalloff, ripple.GetTimeFalloff());
}
}
2018-12-08 05:30:43 +00:00
2021-04-10 08:42:06 +00:00
} // namespace metaforce