CScriptDamageableTrigger: Brace conditions where applicable

Makes code consistent.
This commit is contained in:
Lioncash 2020-05-07 07:40:23 -04:00
parent ff0d14b52d
commit dab1784302
1 changed files with 33 additions and 20 deletions

View File

@ -67,23 +67,26 @@ void CScriptDamageableTrigger::Accept(IVisitor& visitor) { visitor.Visit(this);
void CScriptDamageableTrigger::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) { void CScriptDamageableTrigger::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId sender, CStateManager& mgr) {
switch (msg) { switch (msg) {
case EScriptObjectMessage::Deactivate: case EScriptObjectMessage::Deactivate:
if (x30_24_active && x300_25_alphaOut) if (x30_24_active && x300_25_alphaOut) {
return; return;
}
[[fallthrough]]; [[fallthrough]];
case EScriptObjectMessage::Activate: case EScriptObjectMessage::Activate:
if (!x30_24_active || x300_25_alphaOut) { if (!x30_24_active || x300_25_alphaOut) {
x250_alphaTimer = 0.f; x250_alphaTimer = 0.f;
x16c_hInfo = x164_origHInfo; x16c_hInfo = x164_origHInfo;
x300_25_alphaOut = false; x300_25_alphaOut = false;
if (x300_28_canOrbit) if (x300_28_canOrbit) {
AddMaterial(EMaterialTypes::Orbit, mgr); AddMaterial(EMaterialTypes::Orbit, mgr);
}
SetLinkedObjectAlpha(0.f, mgr); SetLinkedObjectAlpha(0.f, mgr);
x1e0_alpha = 0.f; x1e0_alpha = 0.f;
} }
break; break;
case EScriptObjectMessage::Damage: case EScriptObjectMessage::Damage:
if (x300_27_invulnerable) if (x300_27_invulnerable) {
x16c_hInfo = x164_origHInfo; x16c_hInfo = x164_origHInfo;
}
break; break;
case EScriptObjectMessage::Increment: case EScriptObjectMessage::Increment:
x300_27_invulnerable = true; x300_27_invulnerable = true;
@ -108,8 +111,8 @@ EWeaponCollisionResponseTypes CScriptDamageableTrigger::GetCollisionResponseType
void CScriptDamageableTrigger::Render(CStateManager& mgr) { void CScriptDamageableTrigger::Render(CStateManager& mgr) {
if (x30_24_active && x1dc_faceFlag != 0 && std::fabs(x1e0_alpha) >= 0.00001f) { if (x30_24_active && x1dc_faceFlag != 0 && std::fabs(x1e0_alpha) >= 0.00001f) {
zeus::CAABox aabb = x14c_bounds.getTransformedAABox(x214_faceDirInv); const zeus::CAABox aabb = x14c_bounds.getTransformedAABox(x214_faceDirInv);
zeus::CTransform xf = x34_transform * zeus::CTransform::Translate(x244_faceTranslate) * x1e4_faceDir; const zeus::CTransform xf = x34_transform * zeus::CTransform::Translate(x244_faceTranslate) * x1e4_faceDir;
x254_fluidPlane.Render(mgr, x1e0_alpha, aabb, xf, zeus::CTransform(), false, xe8_frustum, {}, x254_fluidPlane.Render(mgr, x1e0_alpha, aabb, xf, zeus::CTransform(), false, xe8_frustum, {},
kInvalidUniqueId, nullptr, 0, 0, zeus::skZero3f); kInvalidUniqueId, nullptr, 0, 0, zeus::skZero3f);
} }
@ -127,19 +130,24 @@ void CScriptDamageableTrigger::AddToRenderer(const zeus::CFrustum& /*frustum*/,
void CScriptDamageableTrigger::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) { void CScriptDamageableTrigger::PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) {
x300_26_outOfFrustum = !frustum.aabbFrustumTest(x14c_bounds.getTransformedAABox(x34_transform)); x300_26_outOfFrustum = !frustum.aabbFrustumTest(x14c_bounds.getTransformedAABox(x34_transform));
if (!x300_26_outOfFrustum) {
if (x300_26_outOfFrustum) {
return;
}
xe8_frustum = frustum; xe8_frustum = frustum;
CActor::PreRender(mgr, frustum); CActor::PreRender(mgr, frustum);
} }
}
void CScriptDamageableTrigger::SetLinkedObjectAlpha(float a, CStateManager& mgr) { void CScriptDamageableTrigger::SetLinkedObjectAlpha(float a, CStateManager& mgr) {
for (const SConnection& conn : x20_conns) { for (const SConnection& conn : x20_conns) {
if (conn.x0_state != EScriptObjectState::MaxReached || conn.x4_msg != EScriptObjectMessage::Activate) if (conn.x0_state != EScriptObjectState::MaxReached || conn.x4_msg != EScriptObjectMessage::Activate) {
continue; continue;
if (TCastToPtr<CScriptActor> act = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) { }
if (!act->GetActive()) if (const TCastToPtr<CScriptActor> act = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) {
if (!act->GetActive()) {
act->SetActive(true); act->SetActive(true);
}
act->SetDrawFlags(CModelFlags(5, 0, 3, zeus::CColor(1.f, a))); act->SetDrawFlags(CModelFlags(5, 0, 3, zeus::CColor(1.f, a)));
} }
} }
@ -147,34 +155,38 @@ void CScriptDamageableTrigger::SetLinkedObjectAlpha(float a, CStateManager& mgr)
float CScriptDamageableTrigger::GetPuddleAlphaScale() const { float CScriptDamageableTrigger::GetPuddleAlphaScale() const {
if (x250_alphaTimer <= 0.75f) { if (x250_alphaTimer <= 0.75f) {
if (x300_25_alphaOut) if (x300_25_alphaOut) {
return 1.f - x250_alphaTimer / 0.75f; return 1.f - x250_alphaTimer / 0.75f;
}
return x250_alphaTimer / 0.75f; return x250_alphaTimer / 0.75f;
} }
if (x300_25_alphaOut) if (x300_25_alphaOut) {
return 0.f; return 0.f;
}
return 1.f; return 1.f;
} }
void CScriptDamageableTrigger::Think(float dt, CStateManager& mgr) { void CScriptDamageableTrigger::Think(float dt, CStateManager& mgr) {
if (!GetActive()) if (!GetActive()) {
return; return;
}
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways()); const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways());
CGameArea::EOcclusionState occState = const auto occState = area->IsPostConstructed() ? area->GetOcclusionState() : CGameArea::EOcclusionState::Occluded;
area->IsPostConstructed() ? area->GetOcclusionState() : CGameArea::EOcclusionState::Occluded;
x300_24_notOccluded = occState == CGameArea::EOcclusionState::Visible; x300_24_notOccluded = occState == CGameArea::EOcclusionState::Visible;
if (x300_25_alphaOut) { if (x300_25_alphaOut) {
if (x250_alphaTimer >= 0.75f) { if (x250_alphaTimer >= 0.75f) {
SetActive(false); SetActive(false);
for (const SConnection& conn : x20_conns) { for (const SConnection& conn : x20_conns) {
if (conn.x0_state != EScriptObjectState::MaxReached || conn.x4_msg != EScriptObjectMessage::Activate) if (conn.x0_state != EScriptObjectState::MaxReached || conn.x4_msg != EScriptObjectMessage::Activate) {
continue; continue;
if (TCastToPtr<CScriptActor> act = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) }
if (const TCastToPtr<CScriptActor> act = mgr.ObjectById(mgr.GetIdForScript(conn.x8_objId))) {
act->SetActive(false); act->SetActive(false);
} }
}
SetLinkedObjectAlpha(0.f, mgr); SetLinkedObjectAlpha(0.f, mgr);
x300_25_alphaOut = false; x300_25_alphaOut = false;
@ -187,10 +199,11 @@ void CScriptDamageableTrigger::Think(float dt, CStateManager& mgr) {
x250_alphaTimer = 0.f; x250_alphaTimer = 0.f;
} }
if (x250_alphaTimer <= 0.75f) if (x250_alphaTimer <= 0.75f) {
x250_alphaTimer += dt; x250_alphaTimer += dt;
}
float objAlpha = GetPuddleAlphaScale(); const float objAlpha = GetPuddleAlphaScale();
x1e0_alpha = 0.2f * objAlpha; x1e0_alpha = 0.2f * objAlpha;
SetLinkedObjectAlpha(objAlpha, mgr); SetLinkedObjectAlpha(objAlpha, mgr);
} }