Add almost matching CFaceplateDecoration

Former-commit-id: 0a0483489c
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-21 16:48:25 +03:00
parent 71fd2e5321
commit 0c3d5d2a07
7 changed files with 91 additions and 27 deletions

View File

@ -236,7 +236,7 @@ LIBS = [
["MetroidPrime/ScriptObjects/CScriptSteam", False],
["MetroidPrime/ScriptObjects/CScriptRipple", False],
"MetroidPrime/CBoneTracking",
"MetroidPrime/Player/CFaceplateDecoration",
["MetroidPrime/Player/CFaceplateDecoration", False],
"MetroidPrime/BodyState/CBSCover",
"MetroidPrime/ScriptObjects/CScriptBallTrigger",
"MetroidPrime/Weapons/CPlasmaProjectile",

View File

@ -26,6 +26,8 @@ public:
mA = a;
}
CColor(CColor rgb, float a) : mRgba((rgb.GetColor_u32() & 0xffffff00) | CCast::ToUint8(a * 255.f)) {}
void Set(float r, float g, float b, float a);
void Set(uchar r, uchar g, uchar b, uchar a = 255) {
mR = r;

View File

@ -43,6 +43,7 @@ public:
void DisableFilter(float time);
static void DrawWideScreen(const CColor& color, const CTexture* tex, float v);
static void DrawFilter(EFilterType type, EFilterShape shape, const CColor& color, const CTexture* tex, float lod);
private:
EFilterType x0_curType;

View File

@ -0,0 +1,21 @@
#ifndef _CFACEPLATEDECORATION
#define _CFACEPLATEDECORATION
#include "Kyoto/TToken.hpp"
#include "rstl/optional_object.hpp"
class CTexture;
class CStateManager;
class CFaceplateDecoration {
CAssetId x0_id;
rstl::optional_object< TToken< CTexture > > x4_tex;
public:
explicit CFaceplateDecoration(CStateManager& stateMgr);
void Update(float dt, const CStateManager& stateMgr);
void Draw(const CStateManager& stateMgr) const;
};
#endif // _CFACEPLATEDECORATION

View File

@ -29,6 +29,32 @@ enum EPlayerMovementState {
};
class CPlayer : public CPhysicsActor {
struct CVisorSteam {
float x0_curTargetAlpha;
float x4_curAlphaInDur;
float x8_curAlphaOutDur;
CAssetId xc_tex;
float x10_nextTargetAlpha;
float x14_nextAlphaInDur;
float x18_nextAlphaOutDur;
CAssetId x1c_txtr;
float x20_alpha;
float x24_delayTimer;
bool x28_affectsThermal;
public:
CVisorSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId tex)
: x0_curTargetAlpha(targetAlpha)
, x4_curAlphaInDur(alphaInDur)
, x8_curAlphaOutDur(alphaOutDur)
, xc_tex(tex) {}
CAssetId GetTextureId() const { return xc_tex; }
void SetSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId txtr,
bool affectsThermal);
void Update(float dt);
float GetAlpha() const { return x20_alpha; }
bool AffectsThermal() const { return x28_affectsThermal; }
};
public:
enum EPlayerOrbitState {
kOS_NoOrbit,
@ -188,6 +214,7 @@ public:
void Teleport(const CTransform4f& xf, CStateManager& mgr, bool resetBallCam);
void SetSpawnedMorphBallState(EPlayerMorphBallState state, CStateManager& mgr);
const CVisorSteam& GetVisorSteam() const { return x7a0_visorSteam; }
void SetVisorSteam(float targetAlpha, float alphaInDur, float alphaOutDir, CAssetId txtr, bool affectsThermal);
CVector3f GetDampedClampedVelocityWR() const;
@ -195,32 +222,6 @@ public:
float GetGravity() const;
private:
struct CVisorSteam {
float x0_curTargetAlpha;
float x4_curAlphaInDur;
float x8_curAlphaOutDur;
CAssetId xc_tex;
float x10_nextTargetAlpha;
float x14_nextAlphaInDur;
float x18_nextAlphaOutDur;
CAssetId x1c_txtr;
float x20_alpha;
float x24_delayTimer;
bool x28_affectsThermal;
public:
CVisorSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId tex)
: x0_curTargetAlpha(targetAlpha)
, x4_curAlphaInDur(alphaInDur)
, x8_curAlphaOutDur(alphaOutDur)
, xc_tex(tex) {}
CAssetId GetTextureId() const;
void SetSteam(float targetAlpha, float alphaInDur, float alphaOutDur, CAssetId txtr,
bool affectsThermal);
void Update(float dt);
float GetAlpha() const { return x20_alpha; }
bool AffectsThermal() const { return x28_affectsThermal; }
};
NPlayer::EPlayerMovementState x258_movementState;
rstl::vector< CToken > x25c_ballTransitionsRes;

View File

@ -0,0 +1,37 @@
#include "MetroidPrime/Player/CFaceplateDecoration.hpp"
#include "MetroidPrime/CStateManager.hpp"
#include "MetroidPrime/Player/CPlayer.hpp"
#include "Kyoto/Math/CloseEnough.hpp"
#include "Kyoto/SObjectTag.hpp"
CFaceplateDecoration::CFaceplateDecoration(CStateManager& stateMgr) : x0_id(kInvalidAssetId) {}
void CFaceplateDecoration::Update(float dt, const CStateManager& stateMgr) {
CAssetId txtrId = stateMgr.GetPlayer()->GetVisorSteam().GetTextureId();
if (txtrId == kInvalidAssetId && x4_tex.valid()) {
x4_tex->Unlock();
x0_id = txtrId;
}
if (txtrId != x0_id && txtrId != kInvalidAssetId) {
x0_id = txtrId;
x4_tex = gpSimplePool->GetObj(SObjectTag('TXTR', x0_id));
if (x4_tex.valid()) {
x4_tex->Lock();
}
}
}
void CFaceplateDecoration::Draw(const CStateManager& stateMgr) const {
if (x4_tex.valid() && x4_tex->IsLoaded()) {
CTexture* texture = TToken< CTexture >(*x4_tex).GetT();
float alpha = stateMgr.GetPlayer()->GetVisorSteam().GetAlpha();
if (!close_enough(alpha, 0.f)) {
CColor color(CColor::White(), alpha);
CCameraFilterPass::DrawFilter(CCameraFilterPass::kFT_Blend,
CCameraFilterPass::kFS_FullscreenQuarters, color, texture, 1.f);
}
}
}

View File

@ -5,5 +5,7 @@ path=$1
sed -i "s/std::string_view/const rstl::string\&/g" "$path"
sed -i "s/zeus::CTransform/CTransform4f/g" "$path"
sed -i "s/zeus::skPurple/CColor::Purple()/g" "$path"
sed -i "s/zeus::skWhite/CColor::White()/g" "$path"
sed -i "s/zeus:://g" "$path"
sed -i "s/visitor.Visit(this)/visitor.Visit(*this)/g" "$path"