2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CRippleManager.hpp"
|
2017-03-30 22:36:18 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2017-03-30 22:36:18 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CRippleManager::CRippleManager(int maxRipples, float alpha) : x14_alpha(alpha) { Init(maxRipples); }
|
2017-03-30 22:36:18 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CRippleManager::Init(int maxRipples) {
|
2019-02-24 07:15:54 +00:00
|
|
|
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);
|
2017-03-30 22:36:18 +00:00
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
}
|
2017-03-30 22:36:18 +00:00
|
|
|
}
|
|
|
|
|
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;
|
2017-03-30 22:36:18 +00:00
|
|
|
}
|
|
|
|
|
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-06-04 01:56:21 +00:00
|
|
|
}
|
2017-03-30 22:36:18 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (oldestRipple != x4_ripples.end()) {
|
|
|
|
*oldestRipple = ripple;
|
2022-10-20 00:50:24 +00:00
|
|
|
oldestRipple->SetTime(0.f);
|
|
|
|
SetMaxTimeFalloff(std::max(GetMaxTimeFalloff(), ripple.GetTimeFalloff()));
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-03-30 22:36:18 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|