2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/World/CScriptEffect.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CPlayerState.hpp"
|
|
|
|
#include "Runtime/CSimplePool.hpp"
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/GameGlobalObjects.hpp"
|
|
|
|
#include "Runtime/Camera/CGameCamera.hpp"
|
|
|
|
#include "Runtime/Character/CModelData.hpp"
|
|
|
|
#include "Runtime/Collision/CMaterialList.hpp"
|
|
|
|
#include "Runtime/Particle/CElementGen.hpp"
|
|
|
|
#include "Runtime/Particle/CParticleElectric.hpp"
|
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
#include "Runtime/World/CGameLight.hpp"
|
|
|
|
#include "Runtime/World/CScriptTrigger.hpp"
|
|
|
|
#include "Runtime/World/CWorld.hpp"
|
|
|
|
|
2019-09-21 13:07:13 +00:00
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
2016-04-20 21:44:18 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2016-04-20 21:44:18 +00:00
|
|
|
|
2017-03-24 05:30:16 +00:00
|
|
|
u32 CScriptEffect::g_NumParticlesUpdating = 0;
|
|
|
|
u32 CScriptEffect::g_NumParticlesRendered = 0;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CScriptEffect::CScriptEffect(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
|
|
|
const zeus::CVector3f& scale, CAssetId partId, CAssetId elscId, bool hotInThermal,
|
|
|
|
bool noTimerUnlessAreaOccluded, bool rebuildSystemsOnActivate, bool active,
|
|
|
|
bool useRateInverseCamDist, float rateInverseCamDist, float rateInverseCamDistRate,
|
|
|
|
float duration, float durationResetWhileVisible, bool useRateCamDistRange,
|
|
|
|
float rateCamDistRangeMin, float rateCamDistRangeMax, float rateCamDistRangeFarRate,
|
|
|
|
bool combatVisorVisible, bool thermalVisorVisible, bool xrayVisorVisible,
|
|
|
|
const CLightParameters& lParms, bool dieWhenSystemsDone)
|
2016-04-22 20:22:45 +00:00
|
|
|
: CActor(uid, active, name, info, xf, CModelData::CModelDataNull(), CMaterialList(),
|
2018-05-14 03:38:36 +00:00
|
|
|
CActorParameters::None().HotInThermal(hotInThermal), kInvalidUniqueId)
|
|
|
|
, x10c_partId(partId)
|
2018-05-18 04:16:33 +00:00
|
|
|
, x114_rateInverseCamDist(rateInverseCamDist)
|
|
|
|
, x118_rateInverseCamDistSq(rateInverseCamDist * rateInverseCamDist)
|
|
|
|
, x11c_rateInverseCamDistRate(rateInverseCamDistRate)
|
|
|
|
, x120_rateCamDistRangeMin(rateCamDistRangeMin)
|
|
|
|
, x124_rateCamDistRangeMax(rateCamDistRangeMax)
|
|
|
|
, x128_rateCamDistRangeFarRate(rateCamDistRangeFarRate)
|
|
|
|
, x12c_remTime(duration)
|
|
|
|
, x130_duration(duration)
|
|
|
|
, x134_durationResetWhileVisible(durationResetWhileVisible)
|
2018-12-08 05:30:43 +00:00
|
|
|
, x138_actorLights(lParms.MakeActorLights()) {
|
|
|
|
x110_24_enable = active;
|
|
|
|
x110_25_noTimerUnlessAreaOccluded = noTimerUnlessAreaOccluded;
|
|
|
|
x110_26_rebuildSystemsOnActivate = rebuildSystemsOnActivate;
|
|
|
|
x110_27_useRateInverseCamDist = useRateInverseCamDist;
|
|
|
|
x110_28_combatVisorVisible = combatVisorVisible;
|
|
|
|
x110_29_thermalVisorVisible = thermalVisorVisible;
|
|
|
|
x110_30_xrayVisorVisible = xrayVisorVisible;
|
|
|
|
x110_31_anyVisorVisible = xrayVisorVisible && thermalVisorVisible && combatVisorVisible;
|
|
|
|
x111_24_useRateCamDistRange = useRateCamDistRange;
|
|
|
|
x111_25_dieWhenSystemsDone = dieWhenSystemsDone;
|
|
|
|
x111_26_canRender = false;
|
|
|
|
|
|
|
|
if (partId.IsValid()) {
|
|
|
|
xf8_particleSystemToken = g_SimplePool->GetObj({FOURCC('PART'), partId});
|
2019-09-12 03:50:38 +00:00
|
|
|
x104_particleSystem = std::make_unique<CElementGen>(xf8_particleSystemToken);
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CTransform newXf = xf;
|
2019-02-24 07:15:54 +00:00
|
|
|
newXf.origin = zeus::skZero3f;
|
2018-12-08 05:30:43 +00:00
|
|
|
x104_particleSystem->SetOrientation(newXf);
|
|
|
|
x104_particleSystem->SetGlobalTranslation(xf.origin);
|
2019-02-08 01:08:15 +00:00
|
|
|
x104_particleSystem->SetGlobalScale(scale);
|
2018-12-08 05:30:43 +00:00
|
|
|
x104_particleSystem->SetParticleEmission(active);
|
|
|
|
x104_particleSystem->SetModulationColor(lParms.GetNoLightsAmbient());
|
|
|
|
x104_particleSystem->SetModelsUseLights(x138_actorLights != nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (elscId.IsValid()) {
|
|
|
|
xe8_electricToken = g_SimplePool->GetObj({FOURCC('ELSC'), elscId});
|
2019-09-12 03:50:38 +00:00
|
|
|
xf4_electric = std::make_unique<CParticleElectric>(xe8_electricToken);
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CTransform newXf = xf;
|
2019-02-24 07:15:54 +00:00
|
|
|
newXf.origin = zeus::skZero3f;
|
2018-12-08 05:30:43 +00:00
|
|
|
xf4_electric->SetOrientation(newXf);
|
|
|
|
xf4_electric->SetGlobalTranslation(xf.origin);
|
2019-02-08 01:08:15 +00:00
|
|
|
xf4_electric->SetGlobalScale(scale);
|
2018-12-08 05:30:43 +00:00
|
|
|
xf4_electric->SetParticleEmission(active);
|
2020-04-08 03:39:01 +00:00
|
|
|
xf4_electric->SetModulationColor(lParms.GetNoLightsAmbient());
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
xe7_29_drawEnabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CScriptEffect::Accept(IVisitor& visitor) { visitor.Visit(this); }
|
|
|
|
|
|
|
|
void CScriptEffect::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
|
|
|
|
bool oldActive = GetActive();
|
2018-05-18 04:16:33 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (msg) {
|
|
|
|
case EScriptObjectMessage::Activate:
|
|
|
|
if (x110_26_rebuildSystemsOnActivate) {
|
|
|
|
if (x104_particleSystem) {
|
2019-09-12 03:50:38 +00:00
|
|
|
const zeus::CVector3f scale = x104_particleSystem->GetGlobalScale();
|
|
|
|
const zeus::CColor color = x104_particleSystem->GetModulationColor();
|
|
|
|
x104_particleSystem = std::make_unique<CElementGen>(xf8_particleSystemToken);
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CTransform newXf = GetTransform();
|
2019-02-24 07:15:54 +00:00
|
|
|
newXf.origin = zeus::skZero3f;
|
2018-05-14 03:38:36 +00:00
|
|
|
x104_particleSystem->SetOrientation(newXf);
|
2018-12-08 05:30:43 +00:00
|
|
|
x104_particleSystem->SetGlobalTranslation(GetTranslation());
|
2019-02-08 01:08:15 +00:00
|
|
|
x104_particleSystem->SetGlobalScale(scale);
|
2018-12-08 05:30:43 +00:00
|
|
|
x104_particleSystem->SetModulationColor(color);
|
2018-05-14 03:38:36 +00:00
|
|
|
x104_particleSystem->SetModelsUseLights(x138_actorLights != nullptr);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (xf4_electric) {
|
2019-09-12 03:50:38 +00:00
|
|
|
const zeus::CVector3f scale = xf4_electric->GetGlobalScale();
|
|
|
|
const zeus::CColor color = xf4_electric->GetModulationColor();
|
|
|
|
xf4_electric = std::make_unique<CParticleElectric>(xe8_electricToken);
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CTransform newXf = GetTransform();
|
2019-02-24 07:15:54 +00:00
|
|
|
newXf.origin = zeus::skZero3f;
|
2018-05-14 03:38:36 +00:00
|
|
|
xf4_electric->SetOrientation(newXf);
|
2018-12-08 05:30:43 +00:00
|
|
|
xf4_electric->SetGlobalTranslation(GetTranslation());
|
2019-02-08 01:08:15 +00:00
|
|
|
xf4_electric->SetGlobalScale(scale);
|
2018-12-08 05:30:43 +00:00
|
|
|
xf4_electric->SetModulationColor(color);
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Registered:
|
|
|
|
if (x104_particleSystem && x104_particleSystem->SystemHasLight()) {
|
|
|
|
x108_lightId = mgr.AllocateUniqueId();
|
|
|
|
mgr.AddObject(new CGameLight(x108_lightId, GetAreaIdAlways(), GetActive(),
|
|
|
|
std::string("EffectPLight_") + GetName().data(), x34_transform, GetUniqueId(),
|
|
|
|
x104_particleSystem->GetLight(), x10c_partId.Value(), 1, 0.f));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::Deleted:
|
|
|
|
if (x108_lightId != kInvalidUniqueId) {
|
|
|
|
mgr.FreeScriptObject(x108_lightId);
|
|
|
|
x108_lightId = kInvalidUniqueId;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EScriptObjectMessage::InitializedInArea:
|
|
|
|
for (const SConnection& conn : x20_conns) {
|
|
|
|
if ((conn.x0_state == EScriptObjectState::Modify && conn.x4_msg == EScriptObjectMessage::Follow) ||
|
|
|
|
(conn.x0_state == EScriptObjectState::InheritBounds && conn.x4_msg == EScriptObjectMessage::Activate)) {
|
|
|
|
auto search = mgr.GetIdListForScript(conn.x8_objId);
|
|
|
|
for (auto it = search.first; it != search.second; ++it) {
|
|
|
|
if (TCastToConstPtr<CScriptTrigger>(mgr.GetObjectById(it->second)))
|
|
|
|
x13c_triggerId = it->second;
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CActor::AcceptScriptMsg(msg, uid, mgr);
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
TCastToPtr<CActor> light = mgr.ObjectById(x108_lightId);
|
|
|
|
mgr.SendScriptMsg(light, uid, msg);
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (oldActive != GetActive()) {
|
2020-04-08 03:39:01 +00:00
|
|
|
if (GetActive()) {
|
|
|
|
std::vector<TUniqueId> playIds;
|
|
|
|
for (const SConnection& conn : x20_conns) {
|
|
|
|
if (conn.x0_state != EScriptObjectState::Play || conn.x4_msg != EScriptObjectMessage::Activate)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
TUniqueId connId = mgr.GetIdForScript(conn.x8_objId);
|
|
|
|
if (connId != kInvalidUniqueId)
|
|
|
|
playIds.push_back(connId);
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2020-04-08 03:39:01 +00:00
|
|
|
if (!playIds.empty()) {
|
|
|
|
TCastToConstPtr<CActor> otherAct =
|
|
|
|
mgr.GetObjectById(playIds[u32(0.99f * playIds.size() * mgr.GetActiveRandom()->Float())]);
|
|
|
|
if (otherAct) {
|
2019-02-24 23:04:10 +00:00
|
|
|
SetTransform(otherAct->GetTransform());
|
2020-04-08 03:39:01 +00:00
|
|
|
if (light)
|
|
|
|
light->SetTransform(otherAct->GetTransform());
|
|
|
|
}
|
2019-02-24 23:04:10 +00:00
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2020-04-08 03:39:01 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x110_24_enable = true;
|
|
|
|
if (x104_particleSystem)
|
|
|
|
x104_particleSystem->SetParticleEmission(GetActive());
|
|
|
|
if (xf4_electric)
|
|
|
|
xf4_electric->SetParticleEmission(GetActive());
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (GetActive())
|
|
|
|
x12c_remTime = zeus::max(x12c_remTime, x130_duration);
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptEffect::PreRender(CStateManager& mgr, const zeus::CFrustum&) {
|
|
|
|
if (x110_27_useRateInverseCamDist || x111_24_useRateCamDistRange) {
|
|
|
|
float genRate = 1.f;
|
|
|
|
const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
|
|
|
|
float camMagSq = (cam->GetTranslation() - GetTranslation()).magSquared();
|
|
|
|
|
|
|
|
float camMag = 0.f;
|
|
|
|
if (camMagSq > 0.001f)
|
|
|
|
camMag = std::sqrt(camMagSq);
|
|
|
|
if (x110_27_useRateInverseCamDist && camMagSq < x118_rateInverseCamDistSq)
|
|
|
|
genRate = (1.f - x11c_rateInverseCamDistRate) * (camMag / x114_rateInverseCamDist) + x11c_rateInverseCamDistRate;
|
|
|
|
if (x111_24_useRateCamDistRange) {
|
|
|
|
float t = zeus::min(1.f, zeus::max(0.f, camMag - x120_rateCamDistRangeMin) /
|
|
|
|
(x124_rateCamDistRangeMax - x120_rateCamDistRangeMin));
|
|
|
|
genRate = (1.f - t) * genRate + t * x128_rateCamDistRangeFarRate;
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x104_particleSystem->SetGeneratorRate(genRate);
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!mgr.GetObjectById(x13c_triggerId))
|
|
|
|
x13c_triggerId = kInvalidUniqueId;
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2020-04-05 11:54:02 +00:00
|
|
|
void CScriptEffect::AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) {
|
2018-12-08 05:30:43 +00:00
|
|
|
if (!x111_26_canRender) {
|
2020-04-05 11:54:02 +00:00
|
|
|
x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible);
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-04-05 11:54:02 +00:00
|
|
|
if (!frustum.aabbFrustumTest(x9c_renderBounds)) {
|
2018-12-08 05:30:43 +00:00
|
|
|
return;
|
2020-04-05 11:54:02 +00:00
|
|
|
}
|
|
|
|
x12c_remTime = zeus::max(x12c_remTime, x134_durationResetWhileVisible);
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (x110_31_anyVisorVisible) {
|
|
|
|
bool visible = false;
|
|
|
|
const CPlayerState::EPlayerVisor visor = mgr.GetPlayerState()->GetActiveVisor(mgr);
|
2020-04-05 11:54:02 +00:00
|
|
|
if (visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan) {
|
2018-12-08 05:30:43 +00:00
|
|
|
visible = x110_28_combatVisorVisible;
|
2020-04-05 11:54:02 +00:00
|
|
|
} else if (visor == CPlayerState::EPlayerVisor::XRay) {
|
2018-12-08 05:30:43 +00:00
|
|
|
visible = x110_30_xrayVisorVisible;
|
2020-04-05 11:54:02 +00:00
|
|
|
} else if (visor == CPlayerState::EPlayerVisor::Thermal) {
|
2018-12-08 05:30:43 +00:00
|
|
|
visible = x110_29_thermalVisorVisible;
|
2020-04-05 11:54:02 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (visible && x138_actorLights) {
|
|
|
|
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways());
|
2020-04-05 11:54:02 +00:00
|
|
|
x138_actorLights->BuildAreaLightList(
|
2018-12-08 05:30:43 +00:00
|
|
|
mgr, *area, zeus::CAABox{x9c_renderBounds.center(), x9c_renderBounds.center()});
|
2020-04-05 11:54:02 +00:00
|
|
|
x138_actorLights->BuildDynamicLightList(mgr, x9c_renderBounds);
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
EnsureRendered(mgr);
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2020-04-09 17:28:20 +00:00
|
|
|
void CScriptEffect::Render(CStateManager& mgr) {
|
2018-12-08 05:30:43 +00:00
|
|
|
/* The following code is kept for reference, this is now performed in CElementGen
|
|
|
|
if (x138_actorLights)
|
|
|
|
x138_actorLights->ActivateLights();
|
|
|
|
*/
|
|
|
|
if (x104_particleSystem && x104_particleSystem->GetParticleCountAll() > 0) {
|
|
|
|
g_NumParticlesRendered += x104_particleSystem->GetParticleCountAll();
|
2019-06-10 00:09:07 +00:00
|
|
|
x104_particleSystem->Render(x138_actorLights.get());
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (xf4_electric && xf4_electric->GetParticleCount() > 0) {
|
|
|
|
g_NumParticlesRendered += xf4_electric->GetParticleCount();
|
2019-06-10 00:09:07 +00:00
|
|
|
xf4_electric->Render(x138_actorLights.get());
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptEffect::Think(float dt, CStateManager& mgr) {
|
|
|
|
if (xe4_28_transformDirty) {
|
|
|
|
if (x104_particleSystem) {
|
|
|
|
zeus::CTransform newXf = x34_transform;
|
2019-02-24 07:15:54 +00:00
|
|
|
newXf.origin = zeus::skZero3f;
|
2018-12-08 05:30:43 +00:00
|
|
|
x104_particleSystem->SetOrientation(newXf);
|
|
|
|
x104_particleSystem->SetGlobalTranslation(x34_transform.origin);
|
|
|
|
}
|
|
|
|
if (xf4_electric) {
|
|
|
|
zeus::CTransform newXf = x34_transform;
|
2019-02-24 07:15:54 +00:00
|
|
|
newXf.origin = zeus::skZero3f;
|
2018-12-08 05:30:43 +00:00
|
|
|
xf4_electric->SetOrientation(newXf);
|
|
|
|
xf4_electric->SetGlobalTranslation(x34_transform.origin);
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (TCastToPtr<CActor> act = mgr.ObjectById(x108_lightId))
|
|
|
|
act->SetTransform(GetTransform());
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
xe4_28_transformDirty = false;
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x110_25_noTimerUnlessAreaOccluded) {
|
|
|
|
const CGameArea* area = mgr.GetWorld()->GetAreaAlways(GetAreaIdAlways());
|
|
|
|
CGameArea::EOcclusionState visible =
|
|
|
|
area->IsPostConstructed() ? area->GetOcclusionState() : CGameArea::EOcclusionState::Occluded;
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (visible == CGameArea::EOcclusionState::Occluded && x12c_remTime <= 0.f)
|
|
|
|
return;
|
|
|
|
} else if (x12c_remTime <= 0.f)
|
|
|
|
return;
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
x12c_remTime -= dt;
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x110_24_enable) {
|
|
|
|
if (x104_particleSystem) {
|
|
|
|
x104_particleSystem->Update(dt);
|
|
|
|
g_NumParticlesUpdating += x104_particleSystem->GetParticleCountAll();
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (xf4_electric) {
|
|
|
|
xf4_electric->Update(dt);
|
|
|
|
g_NumParticlesUpdating += xf4_electric->GetParticleCount();
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x108_lightId != kInvalidUniqueId) {
|
|
|
|
if (TCastToPtr<CGameLight> light = mgr.ObjectById(x108_lightId)) {
|
|
|
|
if (x30_24_active)
|
|
|
|
light->SetLight(x104_particleSystem->GetLight());
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
|
|
|
|
if (x111_25_dieWhenSystemsDone) {
|
|
|
|
x140_destroyDelayTimer += dt;
|
|
|
|
if (x140_destroyDelayTimer > 15.f || AreBothSystemsDeleteable()) {
|
|
|
|
mgr.FreeScriptObject(GetUniqueId());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (x104_particleSystem) {
|
|
|
|
if (xb4_drawFlags.x0_blendMode != 0)
|
|
|
|
x104_particleSystem->SetModulationColor(xb4_drawFlags.x4_color);
|
|
|
|
else
|
2019-02-24 07:15:54 +00:00
|
|
|
x104_particleSystem->SetModulationColor(zeus::skWhite);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CScriptEffect::CalculateRenderBounds() {
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<zeus::CAABox> particleBounds;
|
2018-12-08 05:30:43 +00:00
|
|
|
if (x104_particleSystem)
|
|
|
|
particleBounds = x104_particleSystem->GetBounds();
|
2018-05-14 03:38:36 +00:00
|
|
|
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<zeus::CAABox> electricBounds;
|
2018-12-08 05:30:43 +00:00
|
|
|
if (xf4_electric)
|
|
|
|
electricBounds = xf4_electric->GetBounds();
|
|
|
|
|
|
|
|
if (particleBounds || electricBounds) {
|
2019-02-24 07:15:54 +00:00
|
|
|
zeus::CAABox renderBounds = zeus::CAABox();
|
2018-12-08 05:30:43 +00:00
|
|
|
if (particleBounds) {
|
|
|
|
renderBounds.accumulateBounds(particleBounds->min);
|
|
|
|
renderBounds.accumulateBounds(particleBounds->max);
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
if (electricBounds) {
|
|
|
|
renderBounds.accumulateBounds(electricBounds->min);
|
|
|
|
renderBounds.accumulateBounds(electricBounds->max);
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
x9c_renderBounds = renderBounds;
|
|
|
|
x111_26_canRender = true;
|
|
|
|
} else {
|
|
|
|
x9c_renderBounds = {GetTranslation(), GetTranslation()};
|
|
|
|
x111_26_canRender = false;
|
|
|
|
}
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CAABox CScriptEffect::GetSortingBounds(const CStateManager& mgr) const {
|
|
|
|
if (x13c_triggerId == kInvalidUniqueId)
|
|
|
|
return x9c_renderBounds;
|
|
|
|
else
|
|
|
|
return static_cast<const CScriptTrigger*>(mgr.GetObjectById(x13c_triggerId))->GetTriggerBoundsWR();
|
2018-05-14 03:38:36 +00:00
|
|
|
}
|
|
|
|
|
2019-08-14 10:04:11 +00:00
|
|
|
bool CScriptEffect::AreBothSystemsDeleteable() const {
|
2018-12-08 05:30:43 +00:00
|
|
|
bool ret = true;
|
|
|
|
if (x104_particleSystem && !x104_particleSystem->IsSystemDeletable())
|
|
|
|
ret = false;
|
2018-10-11 22:57:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (xf4_electric && !xf4_electric->IsSystemDeletable())
|
|
|
|
ret = false;
|
2018-10-11 22:57:05 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return ret;
|
2016-04-20 21:44:18 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|