Some CGameArea state imps

This commit is contained in:
Jack Andersen 2016-07-22 17:07:07 -10:00
parent 804081a11a
commit 8c9198ce1c
4 changed files with 96 additions and 7 deletions

View File

@ -15,6 +15,8 @@
#include "World/CPlayer.hpp" #include "World/CPlayer.hpp"
#include "World/CMorphBall.hpp" #include "World/CMorphBall.hpp"
#include <cmath>
namespace urde namespace urde
{ {
@ -178,8 +180,54 @@ void CStateManager::UpdateThermalVisor()
{ {
std::unique_ptr<CGameArea>& area = x850_world->GetGameAreas()[x8cc_nextAreaId]; std::unique_ptr<CGameArea>& area = x850_world->GetGameAreas()[x8cc_nextAreaId];
const zeus::CTransform& playerXf = x84c_player->GetTransform(); const zeus::CTransform& playerXf = x84c_player->GetTransform();
float f30 = playerXf.origin.x; zeus::CVector3f playerXYPos(playerXf.origin.x, playerXf.origin.y, 0.f);
float f29 = playerXf.origin.y; CGameArea* lastArea = nullptr;
float closestDist = FLT_MAX;
for (const CGameArea::Dock& dock : area->GetDocks())
{
zeus::CVector3f dockCenter = (dock.GetPlaneVertices()[0] + dock.GetPlaneVertices()[1] +
dock.GetPlaneVertices()[2] + dock.GetPlaneVertices()[3]) * 0.25f;
dockCenter.z = 0.f;
float dist = (playerXYPos - dockCenter).magSquared();
if (dist < closestDist)
{
TAreaId connAreaId = dock.GetConnectedAreaId(0);
if (connAreaId != kInvalidAreaId)
{
std::unique_ptr<CGameArea>& connArea = x850_world->GetGameAreas()[x8cc_nextAreaId];
if (connArea->IsPostConstructed())
{
u32 something = connArea->GetPostConstructed()->x10dc_;
if (something == 1)
{
closestDist = dist;
lastArea = connArea.get();
}
}
}
}
}
if (lastArea != nullptr)
{
if (closestDist != 0.f)
closestDist /= std::sqrt(closestDist);
closestDist -= 2.f;
if (closestDist < 8.f)
{
if (closestDist > 0.f)
closestDist = (closestDist / 8.f) * 0.5f + 0.5f;
else
closestDist = 0.5f;
xf24_thermColdScale1 =
(1.f - closestDist) * lastArea->GetPostConstructed()->x111c_thermalCurrent +
closestDist * area->GetPostConstructed()->x111c_thermalCurrent;
return;
}
}
xf24_thermColdScale1 = area->GetPostConstructed()->x111c_thermalCurrent;
} }
} }

View File

@ -162,8 +162,37 @@ void CGameArea::PreRender()
{ {
} }
void CGameArea::UpdateThermalVisor(float dt)
{
if (x12c_postConstructed->x1120_thermalSpeed == 0.f)
return;
float influence = x12c_postConstructed->x111c_thermalCurrent;
float delta = x12c_postConstructed->x1120_thermalSpeed * dt;
if (std::fabs(x12c_postConstructed->x1124_thermalTarget -
x12c_postConstructed->x111c_thermalCurrent) < delta)
{
influence = x12c_postConstructed->x1124_thermalTarget;
x12c_postConstructed->x1120_thermalSpeed = 0.f;
}
else if (x12c_postConstructed->x1124_thermalTarget < influence)
influence -= delta;
else
influence += delta;
x12c_postConstructed->x111c_thermalCurrent = influence;
}
void CGameArea::AliveUpdate(float dt) void CGameArea::AliveUpdate(float dt)
{ {
if (!x12c_postConstructed->x10dc_)
x12c_postConstructed->x10e4_ += dt;
else
x12c_postConstructed->x10e4_ = 0.f;
UpdateFog(dt);
UpdateThermalVisor(dt);
} }
void CGameArea::SetOcclusionState(EOcclusionState state) void CGameArea::SetOcclusionState(EOcclusionState state)

View File

@ -57,7 +57,7 @@ class CGameArea : public IGameArea
{ {
struct struct
{ {
bool xf0_24_ : 1; bool xf0_24_postConstructed : 1;
bool xf0_25_active : 1; bool xf0_25_active : 1;
bool xf0_26_ : 1; bool xf0_26_ : 1;
bool xf0_27_ : 1; bool xf0_27_ : 1;
@ -120,9 +120,9 @@ public:
u8 _dummy = 0; u8 _dummy = 0;
}; };
// std::vector<Something 8 bytes> x110c_; // std::vector<Something 8 bytes> x110c_;
float x111c_ = 0.f; float x111c_thermalCurrent = 0.f;
float x1120_ = 0.f; float x1120_thermalSpeed = 0.f;
float x1124_ = 0.f; float x1124_thermalTarget = 0.f;
float x1128_ = 1.f; float x1128_ = 1.f;
float x112c_ = 0.f; float x112c_ = 0.f;
float x1130_ = 1.f; float x1130_ = 1.f;
@ -130,6 +130,13 @@ public:
float x1138_ = 1.f; float x1138_ = 1.f;
u32 x113c_ = 0; u32 x113c_ = 0;
}; };
private:
std::unique_ptr<CPostConstructed> x12c_postConstructed;
void UpdateFog(float dt);
void UpdateThermalVisor(float dt);
public:
struct CAreaObjectList : public IAreaObjectList struct CAreaObjectList : public IAreaObjectList
{ {
@ -175,7 +182,6 @@ public:
bool DoesAreaNeedEnvFx() const; bool DoesAreaNeedEnvFx() const;
bool DoesAreaNeedSkyNow() const; bool DoesAreaNeedSkyNow() const;
void UpdateFog(float dt);
bool OtherAreaOcclusionChanged(); bool OtherAreaOcclusionChanged();
void PingOcclusionState(); void PingOcclusionState();
void PreRender(); void PreRender();
@ -206,6 +212,11 @@ public:
const zeus::CTransform& GetInverseTransform() const {return x3c_invTransform;} const zeus::CTransform& GetInverseTransform() const {return x3c_invTransform;}
const zeus::CAABox& GetAABB() const {return x6c_aabb;} const zeus::CAABox& GetAABB() const {return x6c_aabb;}
const std::vector<Dock> GetDocks() const {return xcc_docks;}
bool IsPostConstructed() const {return xf0_24_postConstructed;}
const CPostConstructed* GetPostConstructed() const {return x12c_postConstructed.get();}
}; };
} }

View File

@ -35,6 +35,7 @@ public:
bool x48_; bool x48_;
public: public:
const rstl::reserved_vector<zeus::CVector3f, 4>& GetPlaneVertices() const {return x14_planeVertices;}
u32 GetReferenceCount() const { return x0_; } u32 GetReferenceCount() const { return x0_; }
Dock(CInputStream& in, const zeus::CTransform& xf); Dock(CInputStream& in, const zeus::CTransform& xf);
TAreaId GetConnectedAreaId(s32 other) const; TAreaId GetConnectedAreaId(s32 other) const;