Add CScriptSteam

Former-commit-id: 9234899097
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-21 15:01:25 +03:00
parent d68b8e27cc
commit e36d4654dc
7 changed files with 99 additions and 11 deletions

View File

@ -21341,7 +21341,7 @@ lbl_800D8718:
/* 800D88A0 000D5800 39 21 00 9C */ addi r9, r1, 0x9c /* 800D88A0 000D5800 39 21 00 9C */ addi r9, r1, 0x9c
/* 800D88A4 000D5804 39 41 00 38 */ addi r10, r1, 0x38 /* 800D88A4 000D5804 39 41 00 38 */ addi r10, r1, 0x38
/* 800D88A8 000D5808 93 E1 00 14 */ stw r31, 0x14(r1) /* 800D88A8 000D5808 93 E1 00 14 */ stw r31, 0x14(r1)
/* 800D88AC 000D580C 48 09 C4 E5 */ bl "__ct__12CScriptSteamF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fRC6CAABoxRC11CDamageInfoRC9CVector3fUibUiffff" /* 800D88AC 000D580C 48 09 C4 E5 */ bl "__ct__12CScriptSteamF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fRC6CAABoxRC11CDamageInfoRC9CVector3fUibUiffffb"
/* 800D88B0 000D5810 7C 7B 1B 78 */ mr r27, r3 /* 800D88B0 000D5810 7C 7B 1B 78 */ mr r27, r3
lbl_800D88B4: lbl_800D88B4:
/* 800D88B4 000D5814 38 61 00 5C */ addi r3, r1, 0x5c /* 800D88B4 000D5814 38 61 00 5C */ addi r3, r1, 0x5c

View File

@ -3,8 +3,8 @@
.section .data .section .data
.balign 8 .balign 8
.global lbl_803E3DA8 .global __vt__12CScriptSteam
lbl_803E3DA8: __vt__12CScriptSteam:
# ROM: 0x3E0DA8 # ROM: 0x3E0DA8
.4byte 0 .4byte 0
.4byte 0 .4byte 0
@ -202,9 +202,9 @@ __dt__12CScriptSteamFv:
/* 80174D44 00171CA4 93 C1 00 08 */ stw r30, 8(r1) /* 80174D44 00171CA4 93 C1 00 08 */ stw r30, 8(r1)
/* 80174D48 00171CA8 7C 7E 1B 79 */ or. r30, r3, r3 /* 80174D48 00171CA8 7C 7E 1B 79 */ or. r30, r3, r3
/* 80174D4C 00171CAC 41 82 00 28 */ beq lbl_80174D74 /* 80174D4C 00171CAC 41 82 00 28 */ beq lbl_80174D74
/* 80174D50 00171CB0 3C A0 80 3E */ lis r5, lbl_803E3DA8@ha /* 80174D50 00171CB0 3C A0 80 3E */ lis r5, __vt__12CScriptSteam@ha
/* 80174D54 00171CB4 38 80 00 00 */ li r4, 0 /* 80174D54 00171CB4 38 80 00 00 */ li r4, 0
/* 80174D58 00171CB8 38 05 3D A8 */ addi r0, r5, lbl_803E3DA8@l /* 80174D58 00171CB8 38 05 3D A8 */ addi r0, r5, __vt__12CScriptSteam@l
/* 80174D5C 00171CBC 90 1E 00 00 */ stw r0, 0(r30) /* 80174D5C 00171CBC 90 1E 00 00 */ stw r0, 0(r30)
/* 80174D60 00171CC0 4B F0 1F 21 */ bl __dt__14CScriptTriggerFv /* 80174D60 00171CC0 4B F0 1F 21 */ bl __dt__14CScriptTriggerFv
/* 80174D64 00171CC4 7F E0 07 35 */ extsh. r0, r31 /* 80174D64 00171CC4 7F E0 07 35 */ extsh. r0, r31
@ -220,8 +220,8 @@ lbl_80174D74:
/* 80174D88 00171CE8 38 21 00 10 */ addi r1, r1, 0x10 /* 80174D88 00171CE8 38 21 00 10 */ addi r1, r1, 0x10
/* 80174D8C 00171CEC 4E 80 00 20 */ blr /* 80174D8C 00171CEC 4E 80 00 20 */ blr
.global "__ct__12CScriptSteamF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fRC6CAABoxRC11CDamageInfoRC9CVector3fUibUiffff" .global "__ct__12CScriptSteamF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fRC6CAABoxRC11CDamageInfoRC9CVector3fUibUiffffb"
"__ct__12CScriptSteamF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fRC6CAABoxRC11CDamageInfoRC9CVector3fUibUiffff": "__ct__12CScriptSteamF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fRC6CAABoxRC11CDamageInfoRC9CVector3fUibUiffffb":
/* 80174D90 00171CF0 94 21 FF 90 */ stwu r1, -0x70(r1) /* 80174D90 00171CF0 94 21 FF 90 */ stwu r1, -0x70(r1)
/* 80174D94 00171CF4 7C 08 02 A6 */ mflr r0 /* 80174D94 00171CF4 7C 08 02 A6 */ mflr r0
/* 80174D98 00171CF8 90 01 00 74 */ stw r0, 0x74(r1) /* 80174D98 00171CF8 90 01 00 74 */ stw r0, 0x74(r1)
@ -255,8 +255,8 @@ lbl_80174D74:
/* 80174E08 00171D68 90 01 00 14 */ stw r0, 0x14(r1) /* 80174E08 00171D68 90 01 00 14 */ stw r0, 0x14(r1)
/* 80174E0C 00171D6C 4B F0 1F 4D */ bl "__ct__14CScriptTriggerF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fRC6CAABoxRC11CDamageInfoRC9CVector3fUibbb" /* 80174E0C 00171D6C 4B F0 1F 4D */ bl "__ct__14CScriptTriggerF9TUniqueIdRCQ24rstl66basic_string<c,Q24rstl14char_traits<c>,Q24rstl17rmemory_allocator>RC11CEntityInfoRC9CVector3fRC6CAABoxRC11CDamageInfoRC9CVector3fUibbb"
/* 80174E10 00171D70 EC 5E E8 24 */ fdivs f2, f30, f29 /* 80174E10 00171D70 EC 5E E8 24 */ fdivs f2, f30, f29
/* 80174E14 00171D74 3C 60 80 3E */ lis r3, lbl_803E3DA8@ha /* 80174E14 00171D74 3C 60 80 3E */ lis r3, __vt__12CScriptSteam@ha
/* 80174E18 00171D78 38 03 3D A8 */ addi r0, r3, lbl_803E3DA8@l /* 80174E18 00171D78 38 03 3D A8 */ addi r0, r3, __vt__12CScriptSteam@l
/* 80174E1C 00171D7C C0 02 A1 50 */ lfs f0, lbl_805ABE70@sda21(r2) /* 80174E1C 00171D7C C0 02 A1 50 */ lfs f0, lbl_805ABE70@sda21(r2)
/* 80174E20 00171D80 90 1C 00 00 */ stw r0, 0(r28) /* 80174E20 00171D80 90 1C 00 00 */ stw r0, 0(r28)
/* 80174E24 00171D84 9B FC 01 50 */ stb r31, 0x150(r28) /* 80174E24 00171D84 9B FC 01 50 */ stb r31, 0x150(r28)

View File

@ -40,6 +40,7 @@ class CEnvFxManager {
public: public:
static void Initialize(); static void Initialize();
void SetFxDensity(int, float); void SetFxDensity(int, float);
void SetSplashRate(float f) { xb54_baseSplashRate = f; }
private: private:
CAABox x0_particleBounds; CAABox x0_particleBounds;

View File

@ -32,6 +32,8 @@ public:
static float DefaultThirdPersonFov(); static float DefaultThirdPersonFov();
int GetFluidCounter() const { return x74_fluidCounter; }
private: private:
TUniqueId x0_curCameraId; TUniqueId x0_curCameraId;
rstl::vector< TUniqueId > x4_cineCameras; rstl::vector< TUniqueId > x4_cineCameras;

View File

@ -150,6 +150,7 @@ public:
virtual bool IsTransparent(); virtual bool IsTransparent();
CVector3f GetBallPosition() const; CVector3f GetBallPosition() const;
CVector3f GetEyePosition() const;
CTransform4f CreateTransformFromMovementDirection() const; CTransform4f CreateTransformFromMovementDirection() const;
EPlayerOrbitState GetOrbitState() const { return x304_orbitState; } EPlayerOrbitState GetOrbitState() const { return x304_orbitState; }
const CVector3f& GetMovementDirection() const { return x50c_moveDir; } const CVector3f& GetMovementDirection() const { return x50c_moveDir; }
@ -187,6 +188,7 @@ public:
void Teleport(const CTransform4f& xf, CStateManager& mgr, bool resetBallCam); void Teleport(const CTransform4f& xf, CStateManager& mgr, bool resetBallCam);
void SetSpawnedMorphBallState(EPlayerMorphBallState state, CStateManager& mgr); void SetSpawnedMorphBallState(EPlayerMorphBallState state, CStateManager& mgr);
void SetVisorSteam(float targetAlpha, float alphaInDur, float alphaOutDir, CAssetId txtr, bool affectsThermal);
CVector3f GetDampedClampedVelocityWR() const; CVector3f GetDampedClampedVelocityWR() const;
float GetAverageSpeed() const; float GetAverageSpeed() const;

View File

@ -4,8 +4,23 @@
#include "MetroidPrime/ScriptObjects/CScriptTrigger.hpp" #include "MetroidPrime/ScriptObjects/CScriptTrigger.hpp"
class CScriptSteam : public CScriptTrigger { class CScriptSteam : public CScriptTrigger {
bool x150_;
CAssetId x154_texture;
float x158_;
float x15c_alphaInDur;
float x160_alphaOutDur;
float x164_;
float x168_;
public: public:
CScriptSteam(TUniqueId, const rstl::string& name, const CEntityInfo& info, const CVector3f& pos,
const CAABox&, const CDamageInfo& dInfo, const CVector3f& orientedForce,
unsigned int flags, bool active, CAssetId, float, float, float, float, bool);
~CScriptSteam();
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
void Think(float, CStateManager&);
void Accept(IVisitor&);
}; };
#endif // _CSCRIPTSTEAM #endif // _CSCRIPTSTEAM

View File

@ -1 +1,69 @@
#include "MetroidPrime/ScriptObjects/CScriptSteam.hpp" #include "MetroidPrime/ScriptObjects/CScriptSteam.hpp"
#include "MetroidPrime/CEnvFxManager.hpp"
#include "MetroidPrime/CStateManager.hpp"
#include "MetroidPrime/Cameras/CCameraManager.hpp"
#include "MetroidPrime/Player/CPlayer.hpp"
#include "Kyoto/Math/CloseEnough.hpp"
CScriptSteam::CScriptSteam(TUniqueId uid, const rstl::string& name, const CEntityInfo& info,
const CVector3f& pos, const CAABox& aabb, const CDamageInfo& dInfo,
const CVector3f& orientedForce, unsigned int flags, bool active,
CAssetId texture, float f1, float f2, float f3, float f4, bool b1)
: CScriptTrigger(uid, name, info, pos, aabb, dInfo, orientedForce, flags, active, false, false)
, x150_(b1)
, x154_texture(texture)
, x158_(f1)
, x15c_alphaInDur(f2 / f1)
, x160_alphaOutDur(f3 / f1) {
float r3 = (aabb.GetMaxPoint().GetZ() < aabb.GetMaxPoint().GetY() ? aabb.GetMaxPoint().GetZ()
: aabb.GetMaxPoint().GetY());
r3 = (r3 < aabb.GetMaxPoint().GetX() ? r3 : aabb.GetMaxPoint().GetX());
if (close_enough(f4, 0.f)) {
r3 = (r3 < f2 ? r3 : f4);
}
x164_ = r3;
x168_ = 1.f / x164_;
}
CScriptSteam::~CScriptSteam() {}
void CScriptSteam::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) {
switch (msg) {
case kSM_Deactivate:
mgr.Player()->SetVisorSteam(0.f, x15c_alphaInDur, x160_alphaOutDur, kInvalidAssetId, x150_);
break;
}
CScriptTrigger::AcceptScriptMsg(msg, uid, mgr);
}
void CScriptSteam::Think(float dt, CStateManager& mgr) {
if (!GetActive()) {
return;
}
CScriptTrigger::Think(dt, mgr);
if (x148_28_playerTriggerProc && mgr.GetCameraManager()->GetFluidCounter() == 0) {
const CVector3f& eyePos = mgr.GetPlayer()->GetEyePosition();
const CVector3f& posDiff = (GetTranslation() - eyePos);
const float mag = posDiff.Magnitude();
const float distance =
(mag >= x164_ ? 0.f : x158_ * CMath::FastCosR((1.5707964f * mag) * x168_));
mgr.Player()->SetVisorSteam(distance, x15c_alphaInDur, x160_alphaOutDur, x154_texture,
x150_ == true);
if (x150_) {
mgr.EnvFxManager()->SetSplashRate(2.f * distance);
}
} else {
mgr.Player()->SetVisorSteam(0.f, x15c_alphaInDur, x160_alphaOutDur, kInvalidAssetId,
x150_ == true);
}
}
void CScriptSteam::Accept(IVisitor& visitor) { visitor.Visit(*this); }