2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-05-13 15:51:22 +00:00

CBurstFire: Unindent conditionals where applicable

Makes it nicer to read early-exit conditions.
This commit is contained in:
Lioncash 2020-04-19 00:35:37 -04:00
parent e50d363e88
commit ec5d680be0

View File

@ -19,9 +19,15 @@ CBurstFire::CBurstFire(const SBurst* const* burstDefs, s32 firstBurstCount)
void CBurstFire::Update(CStateManager& mgr, float dt) {
x14_24_shouldFire = false;
if (x18_curBursts) {
if (!x18_curBursts) {
return;
}
x8_timeToNextShot -= dt;
if (x8_timeToNextShot < 0.f) {
if (x8_timeToNextShot >= 0.f) {
return;
}
x4_angleIdx += 1;
if (x18_curBursts->x4_shotAngles[x4_angleIdx] > 0) {
x14_24_shouldFire = true;
@ -31,8 +37,6 @@ void CBurstFire::Update(CStateManager& mgr, float dt) {
x18_curBursts = nullptr;
}
}
}
}
zeus::CVector3f CBurstFire::GetDistanceCompensatedError(float dist, float maxErrDist) const {
float xErr = GetMaxXError();
@ -67,18 +71,25 @@ void CBurstFire::Start(CStateManager& mgr) {
}
zeus::CVector3f CBurstFire::GetError(float xMag, float zMag) const {
zeus::CVector3f ret;
if (x14_24_shouldFire && x18_curBursts) {
if (!x14_24_shouldFire || !x18_curBursts) {
return {};
}
s32 r0 = x18_curBursts->x4_shotAngles[x4_angleIdx];
if (x14_25_avoidAccuracy && (r0 == 4 || r0 == 12))
r0 = x4_angleIdx > 0 ? x18_curBursts->x4_shotAngles[x4_angleIdx - 1]
: x18_curBursts->x4_shotAngles[x4_angleIdx + 1];
if (r0 > 0) {
float angle = r0 * zeus::degToRad(-22.5f);
if (x14_25_avoidAccuracy && (r0 == 4 || r0 == 12)) {
r0 =
x4_angleIdx > 0 ? x18_curBursts->x4_shotAngles[x4_angleIdx - 1] : x18_curBursts->x4_shotAngles[x4_angleIdx + 1];
}
if (r0 <= 0) {
return {};
}
const float angle = r0 * zeus::degToRad(-22.5f);
zeus::CVector3f ret;
ret.x() = std::cos(angle) * xMag;
ret.z() = std::sin(angle) * zMag;
}
}
return ret;
}