2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 12:27:43 +00:00

New code style refactor

This commit is contained in:
Jack Andersen
2018-12-07 19:30:43 -10:00
parent 41ae32be31
commit 636c82a568
1451 changed files with 171430 additions and 203303 deletions

View File

@@ -1,44 +1,39 @@
#include "CPlayerEnergyDrain.hpp"
#include "CStateManager.hpp"
namespace urde
{
namespace urde {
CPlayerEnergyDrain::CPlayerEnergyDrain(u32 capacity) { x0_sources.reserve(capacity); }
void CPlayerEnergyDrain::AddEnergyDrainSource(TUniqueId id, float intensity) { x0_sources.emplace_back(id, intensity); }
void CPlayerEnergyDrain::RemoveEnergyDrainSource(TUniqueId id)
{
auto it = rstl::binary_find(x0_sources.begin(), x0_sources.end(), id,
[](const CEnergyDrainSource& item) {return item.GetEnergyDrainSourceId();});
if (it != x0_sources.end())
x0_sources.erase(it);
void CPlayerEnergyDrain::RemoveEnergyDrainSource(TUniqueId id) {
auto it = rstl::binary_find(x0_sources.begin(), x0_sources.end(), id,
[](const CEnergyDrainSource& item) { return item.GetEnergyDrainSourceId(); });
if (it != x0_sources.end())
x0_sources.erase(it);
}
float CPlayerEnergyDrain::GetEnergyDrainIntensity() const
{
float intensity = 0.f;
float CPlayerEnergyDrain::GetEnergyDrainIntensity() const {
float intensity = 0.f;
for (const CEnergyDrainSource& src : x0_sources)
intensity += src.GetEnergyDrainIntensity();
for (const CEnergyDrainSource& src : x0_sources)
intensity += src.GetEnergyDrainIntensity();
return intensity;
return intensity;
}
void CPlayerEnergyDrain::ProcessEnergyDrain(const CStateManager& mgr, float dt)
{
auto it = x0_sources.begin();
void CPlayerEnergyDrain::ProcessEnergyDrain(const CStateManager& mgr, float dt) {
auto it = x0_sources.begin();
for (; it != x0_sources.end(); ++it)
{
if (mgr.GetObjectById((*it).GetEnergyDrainSourceId()) == nullptr)
RemoveEnergyDrainSource((*it).GetEnergyDrainSourceId());
}
for (; it != x0_sources.end(); ++it) {
if (mgr.GetObjectById((*it).GetEnergyDrainSourceId()) == nullptr)
RemoveEnergyDrainSource((*it).GetEnergyDrainSourceId());
}
if (x0_sources.empty())
x10_energyDrainTime = 0.f;
else
x10_energyDrainTime += dt;
}
if (x0_sources.empty())
x10_energyDrainTime = 0.f;
else
x10_energyDrainTime += dt;
}
} // namespace urde