From 77d8b75d2f7b5604e87a36f416f0521bbcad6e9a Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Sat, 1 Oct 2016 20:06:20 -0700 Subject: [PATCH] CScriptAreaAttributes imps, update hecl --- Runtime/CStateManager.hpp | 1 + Runtime/World/CEnvFxManager.cpp | 12 +++++++ Runtime/World/CEnvFxManager.hpp | 24 +++++++++++++ Runtime/World/CGameArea.cpp | 11 ++++++ Runtime/World/CGameArea.hpp | 8 +++-- Runtime/World/CScriptAreaAttributes.cpp | 46 +++++++++++++++++++++++++ Runtime/World/CScriptAreaAttributes.hpp | 7 ++++ hecl | 2 +- 8 files changed, 107 insertions(+), 4 deletions(-) diff --git a/Runtime/CStateManager.hpp b/Runtime/CStateManager.hpp index a6498b04b..12fb2e341 100644 --- a/Runtime/CStateManager.hpp +++ b/Runtime/CStateManager.hpp @@ -281,6 +281,7 @@ public: CRumbleManager& GetRumbleManager() {return *x88c_rumbleManager;} CCameraFilterPass& GetCameraFilterPass(int idx) {return xb84_camFilterPasses[idx];} + CEnvFxManager* GetEnvFxManager() { return x880_envFxManager; } CWorld* GetWorld() {return x850_world.get();} CRelayTracker* GetRelayTracker() { return x8bc_relayTracker.get(); } CCameraManager* GetCameraManager() const { return x870_cameraManager; } diff --git a/Runtime/World/CEnvFxManager.cpp b/Runtime/World/CEnvFxManager.cpp index 83cb825a1..48a5c3f56 100644 --- a/Runtime/World/CEnvFxManager.cpp +++ b/Runtime/World/CEnvFxManager.cpp @@ -1,10 +1,22 @@ #include "CEnvFxManager.hpp" +#include "Graphics/CTexture.hpp" namespace urde { +CEnvFxManager::CEnvFxManager() +{ + +} + void CEnvFxManager::AsyncLoadResources(CStateManager& mgr) { } +void CEnvFxManager::SetFxDensity(s32 val, float density) +{ + x34_fxDensity = density; + x38_ = val; +} + } diff --git a/Runtime/World/CEnvFxManager.hpp b/Runtime/World/CEnvFxManager.hpp index 42e3b33fb..7f782d54f 100644 --- a/Runtime/World/CEnvFxManager.hpp +++ b/Runtime/World/CEnvFxManager.hpp @@ -1,9 +1,14 @@ #ifndef __URDE_CENVFXMANAGER_HPP__ #define __URDE_CENVFXMANAGER_HPP__ +#include "RetroTypes.hpp" +#include "CToken.hpp" +#include "zeus/CAABox.hpp" + namespace urde { class CStateManager; +class CTexture; enum class EEnvFxType { @@ -21,8 +26,27 @@ enum class EPhazonType class CEnvFxManager { + zeus::CAABox x0_ = zeus::CAABox(-63.5, 63.5); + zeus::CVector3f x18_ = zeus::CVector3f::skZero; + u8 x24_ = 0; + float x28_ = 0.f; + u32 x2c_ = -1; + float x30_ = 0.f; + float x34_fxDensity = 0.f; + float x38_ = 0.f; + u8 x3c = 0; + + void SetupSnowTevs(); + void SetupRainTevs(); public: + CEnvFxManager(); void AsyncLoadResources(CStateManager& mgr); + + void Update(float, float, EEnvFxType, const CStateManager&); + void SetFxDensity(s32, float); + void MoveWrapCells(s32, s32); + void GetParticleBoundsToWorldScale() const; + }; } diff --git a/Runtime/World/CGameArea.cpp b/Runtime/World/CGameArea.cpp index 74da3f413..a8fbedeb7 100644 --- a/Runtime/World/CGameArea.cpp +++ b/Runtime/World/CGameArea.cpp @@ -3,6 +3,7 @@ #include "Graphics/CBooRenderer.hpp" #include "CSimplePool.hpp" #include "CStateManager.hpp" +#include "World/CScriptAreaAttributes.hpp" namespace urde { @@ -903,4 +904,14 @@ CGameArea::MREAHeader CGameArea::VerifyHeader() const return header; } +void CGameArea::SetAreaAttributes(const CScriptAreaAttributes* areaAttributes) +{ + x12c_postConstructed->x10d8_areaAttributes = areaAttributes; + if (areaAttributes == nullptr) + return; + + x12c_postConstructed->x111c_thermalCurrent = areaAttributes->GetThermalHeat(); + x12c_postConstructed->x1128_worldLightingLevel = areaAttributes->GetWorldLightingLevel(); +} + } diff --git a/Runtime/World/CGameArea.hpp b/Runtime/World/CGameArea.hpp index da537791b..930221a6f 100644 --- a/Runtime/World/CGameArea.hpp +++ b/Runtime/World/CGameArea.hpp @@ -20,7 +20,7 @@ namespace urde { class CStateManager; - +class CScriptAreaAttributes; class CDummyGameArea : public IGameArea { friend class CDummyWorld; @@ -175,7 +175,7 @@ public: std::unique_ptr x10c8_sclyBuf; u32 x10d0_sclySize = 0; u32 x10d4_ = 0; - u32 x10d8_ = 0; + const CScriptAreaAttributes* x10d8_areaAttributes = nullptr; EOcclusionState x10dc_occlusionState = EOcclusionState::NotOccluded; u32 x10e0_ = 0; float x10e4_ = 5.f; @@ -202,7 +202,7 @@ public: float x111c_thermalCurrent = 0.f; float x1120_thermalSpeed = 0.f; float x1124_thermalTarget = 0.f; - float x1128_ = 1.f; + float x1128_worldLightingLevel = 1.f; float x112c_xraySpeed = 0.f; float x1130_xrayTarget = 1.f; float x1134_ = 0.f; @@ -305,6 +305,8 @@ public: bool IsPostConstructed() const {return xf0_24_postConstructed;} const CPostConstructed* GetPostConstructed() const {return x12c_postConstructed.get();} + void SetAreaAttributes(const CScriptAreaAttributes* areaAttributes); + }; } diff --git a/Runtime/World/CScriptAreaAttributes.cpp b/Runtime/World/CScriptAreaAttributes.cpp index 6ccaebfa6..8c9e993cb 100644 --- a/Runtime/World/CScriptAreaAttributes.cpp +++ b/Runtime/World/CScriptAreaAttributes.cpp @@ -1,4 +1,7 @@ #include "CScriptAreaAttributes.hpp" +#include "CEnvFxManager.hpp" +#include "CStateManager.hpp" +#include "CWorld.hpp" namespace urde { @@ -18,4 +21,47 @@ CScriptAreaAttributes::CScriptAreaAttributes(TUniqueId uid, const CEntityInfo& i { } +void CScriptAreaAttributes::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr) +{ + AcceptScriptMsg(msg, objId, stateMgr); + if (x4_areaId == kInvalidAreaId) + return; + + if (msg == EScriptObjectMessage::InternalMessage13) + { + CGameArea* area = stateMgr.GetWorld()->GetArea(x4_areaId); + area->SetAreaAttributes(this); + stateMgr.GetEnvFxManager()->SetFxDensity(500, x3c_envFxDensity); + } + else if (msg >= EScriptObjectMessage::InternalMessage12) + { + CGameArea* area = stateMgr.GetWorld()->GetArea(x4_areaId); + + if (!area->IsPostConstructed()) + return; + + area->SetAreaAttributes(nullptr); + } +} + +bool CScriptAreaAttributes::GetNeedsSky() const +{ + return x34_24_showSkybox; +} + +bool CScriptAreaAttributes::GetNeedsEnvFx() const +{ + return x38_envFx != EEnvFxType::None; +} + +float CScriptAreaAttributes::GetThermalHeat() const +{ + return x40_thermalHeat; +} + +float CScriptAreaAttributes::GetWorldLightingLevel() const +{ + return x48_worldLightingLevel; +} + } diff --git a/Runtime/World/CScriptAreaAttributes.hpp b/Runtime/World/CScriptAreaAttributes.hpp index 7df0ed78d..5dd420739 100644 --- a/Runtime/World/CScriptAreaAttributes.hpp +++ b/Runtime/World/CScriptAreaAttributes.hpp @@ -21,6 +21,13 @@ public: float envFxDensity, float thermalHeat, float xrayFogDistance, float worldLightingLevel, ResId skybox, EPhazonType phazonType); + void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId objId, CStateManager& stateMgr); + + bool GetNeedsSky() const; + bool GetNeedsEnvFx() const; + float GetEnvFxDensity() const; + float GetThermalHeat() const; + float GetWorldLightingLevel() const; }; } diff --git a/hecl b/hecl index 471385dd4..8e3b35cf8 160000 --- a/hecl +++ b/hecl @@ -1 +1 @@ -Subproject commit 471385dd4a8cad60bd65211f7b17f118d961ef94 +Subproject commit 8e3b35cf8952762b1421dbda154cbd1ad27301d6