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
1 changed files with 34 additions and 23 deletions

View File

@ -19,18 +19,22 @@ CBurstFire::CBurstFire(const SBurst* const* burstDefs, s32 firstBurstCount)
void CBurstFire::Update(CStateManager& mgr, float dt) {
x14_24_shouldFire = false;
if (x18_curBursts) {
x8_timeToNextShot -= dt;
if (x8_timeToNextShot < 0.f) {
x4_angleIdx += 1;
if (x18_curBursts->x4_shotAngles[x4_angleIdx] > 0) {
x14_24_shouldFire = true;
x8_timeToNextShot = x18_curBursts->x24_timeToNextShot;
x8_timeToNextShot += (mgr.GetActiveRandom()->Float() - 0.5f) * x18_curBursts->x28_timeToNextShotVariance;
} else {
x18_curBursts = nullptr;
}
}
if (!x18_curBursts) {
return;
}
x8_timeToNextShot -= dt;
if (x8_timeToNextShot >= 0.f) {
return;
}
x4_angleIdx += 1;
if (x18_curBursts->x4_shotAngles[x4_angleIdx] > 0) {
x14_24_shouldFire = true;
x8_timeToNextShot = x18_curBursts->x24_timeToNextShot;
x8_timeToNextShot += (mgr.GetActiveRandom()->Float() - 0.5f) * x18_curBursts->x28_timeToNextShotVariance;
} else {
x18_curBursts = nullptr;
}
}
@ -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) {
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);
ret.x() = std::cos(angle) * xMag;
ret.z() = std::sin(angle) * zMag;
}
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) {
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;
}