CScriptBallTrigger: Brace statements where applicable

Makes the code consistent.
This commit is contained in:
Lioncash 2020-05-07 07:58:12 -04:00
parent ec6416e387
commit 0bb3fcae3b
1 changed files with 18 additions and 12 deletions

View File

@ -12,7 +12,7 @@
namespace urde { namespace urde {
static zeus::CAABox calculate_ball_aabox() { static zeus::CAABox calculate_ball_aabox() {
float extent = 0.33f * g_tweakPlayer->GetPlayerBallHalfExtent(); const float extent = 0.33f * g_tweakPlayer->GetPlayerBallHalfExtent();
return {-extent, extent}; return {-extent, extent};
} }
@ -26,9 +26,10 @@ CScriptBallTrigger::CScriptBallTrigger(TUniqueId uid, std::string_view name, con
, x158_maxDistance(f3) , x158_maxDistance(f3)
, x168_25_stopPlayer(b2) { , x168_25_stopPlayer(b2) {
if (vec.canBeNormalized()) if (vec.canBeNormalized()) {
x15c_forceAngle = vec.normalized(); x15c_forceAngle = vec.normalized();
} }
}
void CScriptBallTrigger::Accept(IVisitor& visitor) { visitor.Visit(this); } void CScriptBallTrigger::Accept(IVisitor& visitor) { visitor.Visit(this); }
@ -42,8 +43,10 @@ void CScriptBallTrigger::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid
} }
void CScriptBallTrigger::Think(float dt, CStateManager& mgr) { void CScriptBallTrigger::Think(float dt, CStateManager& mgr) {
if (!GetActive()) if (!GetActive()) {
return; return;
}
CScriptTrigger::Think(dt, mgr); CScriptTrigger::Think(dt, mgr);
CPlayer& player = mgr.GetPlayer(); CPlayer& player = mgr.GetPlayer();
@ -58,33 +61,36 @@ void CScriptBallTrigger::Think(float dt, CStateManager& mgr) {
const float distance = radiusPosDif.magnitude(); const float distance = radiusPosDif.magnitude();
if (!x168_24_canApplyForce) { if (!x168_24_canApplyForce) {
if (distance < ballRadius) if (distance < ballRadius) {
x168_24_canApplyForce = true; x168_24_canApplyForce = true;
else { } else {
zeus::CVector3f offset = radiusPosDif.normalized(); const zeus::CVector3f offset = radiusPosDif.normalized();
if (std::cos(zeus::degToRad(x154_minAngle)) < (-offset).dot(x15c_forceAngle) && distance < x158_maxDistance) { if (std::cos(zeus::degToRad(x154_minAngle)) < (-offset).dot(x15c_forceAngle) && distance < x158_maxDistance) {
float force = zeus::min((1.f / dt * distance), x150_force * (distance * distance)); const float force = zeus::min((1.f / dt * distance), x150_force * (distance * distance));
player.ApplyForceWR(force * (player.GetMass() * offset), zeus::CAxisAngle()); player.ApplyForceWR(force * (player.GetMass() * offset), zeus::CAxisAngle());
} }
} }
} }
if (x148_28_playerTriggerProc) { if (x148_28_playerTriggerProc) {
zeus::CVector3f offset = GetTranslation() - zeus::CVector3f(0.f, 0.f, ballRadius); const zeus::CVector3f offset = GetTranslation() - zeus::CVector3f(0.f, 0.f, ballRadius);
if (x168_25_stopPlayer) if (x168_25_stopPlayer) {
player.Stop(); player.Stop();
}
player.MoveToWR(offset, dt); player.MoveToWR(offset, dt);
} else } else {
x168_24_canApplyForce = false; x168_24_canApplyForce = false;
} }
}
void CScriptBallTrigger::InhabitantAdded(CActor& act, CStateManager& /*mgr*/) { void CScriptBallTrigger::InhabitantAdded(CActor& act, CStateManager& /*mgr*/) {
if (TCastToPtr<CPlayer> player = act) if (const TCastToPtr<CPlayer> player = act) {
player->GetMorphBall()->SetBallBoostState(CMorphBall::EBallBoostState::BoostDisabled); player->GetMorphBall()->SetBallBoostState(CMorphBall::EBallBoostState::BoostDisabled);
} }
}
void CScriptBallTrigger::InhabitantExited(CActor& act, CStateManager&) { void CScriptBallTrigger::InhabitantExited(CActor& act, CStateManager&) {
if (TCastToPtr<CPlayer> player = act) { if (const TCastToPtr<CPlayer> player = act) {
player->GetMorphBall()->SetBallBoostState(CMorphBall::EBallBoostState::BoostAvailable); player->GetMorphBall()->SetBallBoostState(CMorphBall::EBallBoostState::BoostAvailable);
x168_24_canApplyForce = false; x168_24_canApplyForce = false;
} }