mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-05-13 21:51:22 +00:00
CBurstFire: Unindent conditionals where applicable
Makes it nicer to read early-exit conditions.
This commit is contained in:
parent
e50d363e88
commit
ec5d680be0
@ -19,18 +19,22 @@ CBurstFire::CBurstFire(const SBurst* const* burstDefs, s32 firstBurstCount)
|
|||||||
|
|
||||||
void CBurstFire::Update(CStateManager& mgr, float dt) {
|
void CBurstFire::Update(CStateManager& mgr, float dt) {
|
||||||
x14_24_shouldFire = false;
|
x14_24_shouldFire = false;
|
||||||
if (x18_curBursts) {
|
if (!x18_curBursts) {
|
||||||
x8_timeToNextShot -= dt;
|
return;
|
||||||
if (x8_timeToNextShot < 0.f) {
|
}
|
||||||
x4_angleIdx += 1;
|
|
||||||
if (x18_curBursts->x4_shotAngles[x4_angleIdx] > 0) {
|
x8_timeToNextShot -= dt;
|
||||||
x14_24_shouldFire = true;
|
if (x8_timeToNextShot >= 0.f) {
|
||||||
x8_timeToNextShot = x18_curBursts->x24_timeToNextShot;
|
return;
|
||||||
x8_timeToNextShot += (mgr.GetActiveRandom()->Float() - 0.5f) * x18_curBursts->x28_timeToNextShotVariance;
|
}
|
||||||
} else {
|
|
||||||
x18_curBursts = nullptr;
|
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 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);
|
|
||||||
ret.x() = std::cos(angle) * xMag;
|
|
||||||
ret.z() = std::sin(angle) * zMag;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user