mirror of https://github.com/AxioDL/metaforce.git
CScriptEffect: Brace conditionals where applicable
This commit is contained in:
parent
e4abedf16f
commit
631c449453
|
@ -131,10 +131,11 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
|
||||||
for (const SConnection& conn : x20_conns) {
|
for (const SConnection& conn : x20_conns) {
|
||||||
if ((conn.x0_state == EScriptObjectState::Modify && conn.x4_msg == EScriptObjectMessage::Follow) ||
|
if ((conn.x0_state == EScriptObjectState::Modify && conn.x4_msg == EScriptObjectMessage::Follow) ||
|
||||||
(conn.x0_state == EScriptObjectState::InheritBounds && conn.x4_msg == EScriptObjectMessage::Activate)) {
|
(conn.x0_state == EScriptObjectState::InheritBounds && conn.x4_msg == EScriptObjectMessage::Activate)) {
|
||||||
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
const auto search = mgr.GetIdListForScript(conn.x8_objId);
|
||||||
for (auto it = search.first; it != search.second; ++it) {
|
for (auto it = search.first; it != search.second; ++it) {
|
||||||
if (TCastToConstPtr<CScriptTrigger>(mgr.GetObjectById(it->second)))
|
if (TCastToConstPtr<CScriptTrigger>(mgr.GetObjectById(it->second))) {
|
||||||
x13c_triggerId = it->second;
|
x13c_triggerId = it->second;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -145,7 +146,7 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
|
||||||
|
|
||||||
CActor::AcceptScriptMsg(msg, uid, mgr);
|
CActor::AcceptScriptMsg(msg, uid, mgr);
|
||||||
|
|
||||||
TCastToPtr<CActor> light = mgr.ObjectById(x108_lightId);
|
const TCastToPtr<CActor> light = mgr.ObjectById(x108_lightId);
|
||||||
mgr.SendScriptMsg(light, uid, msg);
|
mgr.SendScriptMsg(light, uid, msg);
|
||||||
|
|
||||||
if (oldActive != GetActive()) {
|
if (oldActive != GetActive()) {
|
||||||
|
@ -163,24 +164,28 @@ void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CSt
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!playIds.empty()) {
|
if (!playIds.empty()) {
|
||||||
TCastToConstPtr<CActor> otherAct =
|
const TCastToConstPtr<CActor> otherAct =
|
||||||
mgr.GetObjectById(playIds[u32(0.99f * playIds.size() * mgr.GetActiveRandom()->Float())]);
|
mgr.GetObjectById(playIds[u32(0.99f * playIds.size() * mgr.GetActiveRandom()->Float())]);
|
||||||
if (otherAct) {
|
if (otherAct) {
|
||||||
SetTransform(otherAct->GetTransform());
|
SetTransform(otherAct->GetTransform());
|
||||||
if (light)
|
if (light) {
|
||||||
light->SetTransform(otherAct->GetTransform());
|
light->SetTransform(otherAct->GetTransform());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x110_24_enable = true;
|
x110_24_enable = true;
|
||||||
if (x104_particleSystem)
|
if (x104_particleSystem) {
|
||||||
x104_particleSystem->SetParticleEmission(GetActive());
|
x104_particleSystem->SetParticleEmission(GetActive());
|
||||||
if (xf4_electric)
|
}
|
||||||
|
if (xf4_electric) {
|
||||||
xf4_electric->SetParticleEmission(GetActive());
|
xf4_electric->SetParticleEmission(GetActive());
|
||||||
|
}
|
||||||
|
|
||||||
if (GetActive())
|
if (GetActive()) {
|
||||||
x12c_remTime = zeus::max(x12c_remTime, x130_duration);
|
x12c_remTime = zeus::max(x12c_remTime, x130_duration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,24 +193,27 @@ void CScriptEffect::PreRender(CStateManager& mgr, const zeus::CFrustum&) {
|
||||||
if (x110_27_useRateInverseCamDist || x111_24_useRateCamDistRange) {
|
if (x110_27_useRateInverseCamDist || x111_24_useRateCamDistRange) {
|
||||||
float genRate = 1.f;
|
float genRate = 1.f;
|
||||||
const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
|
const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
|
||||||
float camMagSq = (cam->GetTranslation() - GetTranslation()).magSquared();
|
const float camMagSq = (cam->GetTranslation() - GetTranslation()).magSquared();
|
||||||
|
|
||||||
float camMag = 0.f;
|
float camMag = 0.f;
|
||||||
if (camMagSq > 0.001f)
|
if (camMagSq > 0.001f) {
|
||||||
camMag = std::sqrt(camMagSq);
|
camMag = std::sqrt(camMagSq);
|
||||||
if (x110_27_useRateInverseCamDist && camMagSq < x118_rateInverseCamDistSq)
|
}
|
||||||
|
if (x110_27_useRateInverseCamDist && camMagSq < x118_rateInverseCamDistSq) {
|
||||||
genRate = (1.f - x11c_rateInverseCamDistRate) * (camMag / x114_rateInverseCamDist) + x11c_rateInverseCamDistRate;
|
genRate = (1.f - x11c_rateInverseCamDistRate) * (camMag / x114_rateInverseCamDist) + x11c_rateInverseCamDistRate;
|
||||||
|
}
|
||||||
if (x111_24_useRateCamDistRange) {
|
if (x111_24_useRateCamDistRange) {
|
||||||
float t = zeus::min(1.f, zeus::max(0.f, camMag - x120_rateCamDistRangeMin) /
|
const float t = zeus::min(1.f, zeus::max(0.f, camMag - x120_rateCamDistRangeMin) /
|
||||||
(x124_rateCamDistRangeMax - x120_rateCamDistRangeMin));
|
(x124_rateCamDistRangeMax - x120_rateCamDistRangeMin));
|
||||||
genRate = (1.f - t) * genRate + t * x128_rateCamDistRangeFarRate;
|
genRate = (1.f - t) * genRate + t * x128_rateCamDistRangeFarRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
x104_particleSystem->SetGeneratorRate(genRate);
|
x104_particleSystem->SetGeneratorRate(genRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mgr.GetObjectById(x13c_triggerId))
|
if (!mgr.GetObjectById(x13c_triggerId)) {
|
||||||
x13c_triggerId = kInvalidUniqueId;
|
x13c_triggerId = kInvalidUniqueId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptEffect::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) {
|
void CScriptEffect::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) {
|
||||||
|
@ -271,21 +279,23 @@ void CScriptEffect::Think(float dt, CStateManager& mgr) {
|
||||||
xf4_electric->SetGlobalTranslation(x34_transform.origin);
|
xf4_electric->SetGlobalTranslation(x34_transform.origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TCastToPtr<CActor> act = mgr.ObjectById(x108_lightId))
|
if (const TCastToPtr<CActor> act = mgr.ObjectById(x108_lightId)) {
|
||||||
act->SetTransform(GetTransform());
|
act->SetTransform(GetTransform());
|
||||||
|
}
|
||||||
|
|
||||||
xe4_28_transformDirty = false;
|
xe4_28_transformDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x110_25_noTimerUnlessAreaOccluded) {
|
if (x110_25_noTimerUnlessAreaOccluded) {
|
||||||
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways());
|
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways());
|
||||||
CGameArea::EOcclusionState visible =
|
const auto visible = area->IsPostConstructed() ? area->GetOcclusionState() : CGameArea::EOcclusionState::Occluded;
|
||||||
area->IsPostConstructed() ? area->GetOcclusionState() : CGameArea::EOcclusionState::Occluded;
|
|
||||||
|
|
||||||
if (visible == CGameArea::EOcclusionState::Occluded && x12c_remTime <= 0.f)
|
if (visible == CGameArea::EOcclusionState::Occluded && x12c_remTime <= 0.f) {
|
||||||
return;
|
return;
|
||||||
} else if (x12c_remTime <= 0.f)
|
}
|
||||||
|
} else if (x12c_remTime <= 0.f) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
x12c_remTime -= dt;
|
x12c_remTime -= dt;
|
||||||
|
|
||||||
|
@ -301,9 +311,10 @@ void CScriptEffect::Think(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x108_lightId != kInvalidUniqueId) {
|
if (x108_lightId != kInvalidUniqueId) {
|
||||||
if (TCastToPtr<CGameLight> light = mgr.ObjectById(x108_lightId)) {
|
if (const TCastToPtr<CGameLight> light = mgr.ObjectById(x108_lightId)) {
|
||||||
if (x30_24_active)
|
if (x30_24_active) {
|
||||||
light->SetLight(x104_particleSystem->GetLight());
|
light->SetLight(x104_particleSystem->GetLight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,21 +328,24 @@ void CScriptEffect::Think(float dt, CStateManager& mgr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (x104_particleSystem) {
|
if (x104_particleSystem) {
|
||||||
if (xb4_drawFlags.x0_blendMode != 0)
|
if (xb4_drawFlags.x0_blendMode != 0) {
|
||||||
x104_particleSystem->SetModulationColor(xb4_drawFlags.x4_color);
|
x104_particleSystem->SetModulationColor(xb4_drawFlags.x4_color);
|
||||||
else
|
} else {
|
||||||
x104_particleSystem->SetModulationColor(zeus::skWhite);
|
x104_particleSystem->SetModulationColor(zeus::skWhite);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CScriptEffect::CalculateRenderBounds() {
|
void CScriptEffect::CalculateRenderBounds() {
|
||||||
std::optional<zeus::CAABox> particleBounds;
|
std::optional<zeus::CAABox> particleBounds;
|
||||||
if (x104_particleSystem)
|
if (x104_particleSystem) {
|
||||||
particleBounds = x104_particleSystem->GetBounds();
|
particleBounds = x104_particleSystem->GetBounds();
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<zeus::CAABox> electricBounds;
|
std::optional<zeus::CAABox> electricBounds;
|
||||||
if (xf4_electric)
|
if (xf4_electric) {
|
||||||
electricBounds = xf4_electric->GetBounds();
|
electricBounds = xf4_electric->GetBounds();
|
||||||
|
}
|
||||||
|
|
||||||
if (particleBounds || electricBounds) {
|
if (particleBounds || electricBounds) {
|
||||||
zeus::CAABox renderBounds = zeus::CAABox();
|
zeus::CAABox renderBounds = zeus::CAABox();
|
||||||
|
@ -352,20 +366,22 @@ void CScriptEffect::CalculateRenderBounds() {
|
||||||
}
|
}
|
||||||
|
|
||||||
zeus::CAABox CScriptEffect::GetSortingBounds(const CStateManager& mgr) const {
|
zeus::CAABox CScriptEffect::GetSortingBounds(const CStateManager& mgr) const {
|
||||||
if (x13c_triggerId == kInvalidUniqueId)
|
if (x13c_triggerId == kInvalidUniqueId) {
|
||||||
return x9c_renderBounds;
|
return x9c_renderBounds;
|
||||||
else
|
}
|
||||||
return static_cast<const CScriptTrigger*>(mgr.GetObjectById(x13c_triggerId))->GetTriggerBoundsWR();
|
|
||||||
|
return static_cast<const CScriptTrigger*>(mgr.GetObjectById(x13c_triggerId))->GetTriggerBoundsWR();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScriptEffect::AreBothSystemsDeleteable() const {
|
bool CScriptEffect::AreBothSystemsDeleteable() const {
|
||||||
bool ret = true;
|
if (x104_particleSystem && !x104_particleSystem->IsSystemDeletable()) {
|
||||||
if (x104_particleSystem && !x104_particleSystem->IsSystemDeletable())
|
return false;
|
||||||
ret = false;
|
}
|
||||||
|
|
||||||
if (xf4_electric && !xf4_electric->IsSystemDeletable())
|
if (xf4_electric && !xf4_electric->IsSystemDeletable()) {
|
||||||
ret = false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return true;
|
||||||
}
|
}
|
||||||
} // namespace urde
|
} // namespace urde
|
||||||
|
|
Loading…
Reference in New Issue