mirror of https://github.com/AxioDL/metaforce.git
Some CGameArea state imps
This commit is contained in:
parent
804081a11a
commit
8c9198ce1c
|
@ -15,6 +15,8 @@
|
|||
#include "World/CPlayer.hpp"
|
||||
#include "World/CMorphBall.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace urde
|
||||
{
|
||||
|
||||
|
@ -178,8 +180,54 @@ void CStateManager::UpdateThermalVisor()
|
|||
{
|
||||
std::unique_ptr<CGameArea>& area = x850_world->GetGameAreas()[x8cc_nextAreaId];
|
||||
const zeus::CTransform& playerXf = x84c_player->GetTransform();
|
||||
float f30 = playerXf.origin.x;
|
||||
float f29 = playerXf.origin.y;
|
||||
zeus::CVector3f playerXYPos(playerXf.origin.x, playerXf.origin.y, 0.f);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
if (!x12c_postConstructed->x10dc_)
|
||||
x12c_postConstructed->x10e4_ += dt;
|
||||
else
|
||||
x12c_postConstructed->x10e4_ = 0.f;
|
||||
UpdateFog(dt);
|
||||
UpdateThermalVisor(dt);
|
||||
|
||||
}
|
||||
|
||||
void CGameArea::SetOcclusionState(EOcclusionState state)
|
||||
|
|
|
@ -57,7 +57,7 @@ class CGameArea : public IGameArea
|
|||
{
|
||||
struct
|
||||
{
|
||||
bool xf0_24_ : 1;
|
||||
bool xf0_24_postConstructed : 1;
|
||||
bool xf0_25_active : 1;
|
||||
bool xf0_26_ : 1;
|
||||
bool xf0_27_ : 1;
|
||||
|
@ -120,9 +120,9 @@ public:
|
|||
u8 _dummy = 0;
|
||||
};
|
||||
// std::vector<Something 8 bytes> x110c_;
|
||||
float x111c_ = 0.f;
|
||||
float x1120_ = 0.f;
|
||||
float x1124_ = 0.f;
|
||||
float x111c_thermalCurrent = 0.f;
|
||||
float x1120_thermalSpeed = 0.f;
|
||||
float x1124_thermalTarget = 0.f;
|
||||
float x1128_ = 1.f;
|
||||
float x112c_ = 0.f;
|
||||
float x1130_ = 1.f;
|
||||
|
@ -130,6 +130,13 @@ public:
|
|||
float x1138_ = 1.f;
|
||||
u32 x113c_ = 0;
|
||||
};
|
||||
private:
|
||||
std::unique_ptr<CPostConstructed> x12c_postConstructed;
|
||||
|
||||
void UpdateFog(float dt);
|
||||
void UpdateThermalVisor(float dt);
|
||||
|
||||
public:
|
||||
|
||||
struct CAreaObjectList : public IAreaObjectList
|
||||
{
|
||||
|
@ -175,7 +182,6 @@ public:
|
|||
|
||||
bool DoesAreaNeedEnvFx() const;
|
||||
bool DoesAreaNeedSkyNow() const;
|
||||
void UpdateFog(float dt);
|
||||
bool OtherAreaOcclusionChanged();
|
||||
void PingOcclusionState();
|
||||
void PreRender();
|
||||
|
@ -206,6 +212,11 @@ public:
|
|||
const zeus::CTransform& GetInverseTransform() const {return x3c_invTransform;}
|
||||
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();}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ public:
|
|||
bool x48_;
|
||||
public:
|
||||
|
||||
const rstl::reserved_vector<zeus::CVector3f, 4>& GetPlaneVertices() const {return x14_planeVertices;}
|
||||
u32 GetReferenceCount() const { return x0_; }
|
||||
Dock(CInputStream& in, const zeus::CTransform& xf);
|
||||
TAreaId GetConnectedAreaId(s32 other) const;
|
||||
|
|
Loading…
Reference in New Issue