CScriptEMPulse: Brace conditionals where applicable

This commit is contained in:
Lioncash 2020-05-07 13:29:46 -04:00
parent 51ffc0ef26
commit e4abedf16f
1 changed files with 23 additions and 16 deletions

View File

@ -32,19 +32,25 @@ CScriptEMPulse::CScriptEMPulse(TUniqueId uid, std::string_view name, const CEnti
void CScriptEMPulse::Accept(IVisitor& visitor) { visitor.Visit(this); } void CScriptEMPulse::Accept(IVisitor& visitor) { visitor.Visit(this); }
void CScriptEMPulse::Think(float dt, CStateManager& mgr) { void CScriptEMPulse::Think(float dt, CStateManager& mgr) {
if (!GetActive()) if (!GetActive()) {
return; return;
}
xf0_currentRadius += ((xec_finalRadius - xf4_initialRadius) / xe8_duration) * dt; xf0_currentRadius += ((xec_finalRadius - xf4_initialRadius) / xe8_duration) * dt;
if (xf0_currentRadius < xec_finalRadius) if (xf0_currentRadius < xec_finalRadius) {
mgr.FreeScriptObject(GetUniqueId()); mgr.FreeScriptObject(GetUniqueId());
}
x114_particleGen->Update(dt); x114_particleGen->Update(dt);
} }
void CScriptEMPulse::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) { void CScriptEMPulse::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
CActor::AcceptScriptMsg(msg, uid, mgr); CActor::AcceptScriptMsg(msg, uid, mgr);
if (msg == EScriptObjectMessage::Activate) {
if (msg != EScriptObjectMessage::Activate) {
return;
}
x114_particleGen = std::make_unique<CElementGen>(x108_particleDesc, CElementGen::EModelOrientationType::Normal, x114_particleGen = std::make_unique<CElementGen>(x108_particleDesc, CElementGen::EModelOrientationType::Normal,
CElementGen::EOptionalSystemFlags::One); CElementGen::EOptionalSystemFlags::One);
@ -53,7 +59,6 @@ void CScriptEMPulse::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CS
x114_particleGen->SetParticleEmission(true); x114_particleGen->SetParticleEmission(true);
mgr.GetPlayerState()->GetStaticInterference().AddSource(GetUniqueId(), x100_interferenceMag, xf8_interferenceDur); mgr.GetPlayerState()->GetStaticInterference().AddSource(GetUniqueId(), x100_interferenceMag, xf8_interferenceDur);
} }
}
void CScriptEMPulse::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) { void CScriptEMPulse::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) {
CActor::AddToRenderer(frustum, mgr); CActor::AddToRenderer(frustum, mgr);
@ -67,24 +72,26 @@ void CScriptEMPulse::CalculateRenderBounds() { x9c_renderBounds = CalculateBound
std::optional<zeus::CAABox> CScriptEMPulse::GetTouchBounds() const { return {CalculateBoundingBox()}; } std::optional<zeus::CAABox> CScriptEMPulse::GetTouchBounds() const { return {CalculateBoundingBox()}; }
void CScriptEMPulse::Touch(CActor& act, CStateManager& mgr) { void CScriptEMPulse::Touch(CActor& act, CStateManager& mgr) {
if (!GetActive()) if (!GetActive()) {
return; return;
}
if (TCastToPtr<CPlayer> pl = act) { if (const TCastToPtr<CPlayer> pl = act) {
zeus::CVector3f posDiff = GetTranslation() - pl->GetTranslation(); const zeus::CVector3f posDiff = GetTranslation() - pl->GetTranslation();
if (posDiff.magnitude() < xec_finalRadius) { if (posDiff.magnitude() < xec_finalRadius) {
float dur = const float dur =
((1.f - (posDiff.magnitude() / xec_finalRadius)) * (xfc_ - xf8_interferenceDur)) + xf8_interferenceDur; ((1.f - (posDiff.magnitude() / xec_finalRadius)) * (xfc_ - xf8_interferenceDur)) + xf8_interferenceDur;
float mag = const float mag =
((1.f - (posDiff.magnitude() / xec_finalRadius)) * (x104_ - xf8_interferenceDur)) + x100_interferenceMag; ((1.f - (posDiff.magnitude() / xec_finalRadius)) * (x104_ - xf8_interferenceDur)) + x100_interferenceMag;
if (dur > pl->GetStaticTimer()) if (dur > pl->GetStaticTimer()) {
pl->SetHudDisable(dur, 0.5f, 2.5f); pl->SetHudDisable(dur, 0.5f, 2.5f);
else } else {
mgr.GetPlayerState()->GetStaticInterference().AddSource(GetUniqueId(), mag, dur); mgr.GetPlayerState()->GetStaticInterference().AddSource(GetUniqueId(), mag, dur);
} }
} }
} }
}
zeus::CAABox CScriptEMPulse::CalculateBoundingBox() const { zeus::CAABox CScriptEMPulse::CalculateBoundingBox() const {
return zeus::CAABox(GetTranslation() - xf0_currentRadius, GetTranslation() + xf0_currentRadius); return zeus::CAABox(GetTranslation() - xf0_currentRadius, GetTranslation() + xf0_currentRadius);