diff --git a/include/MetroidPrime/CFluidPlaneManager.hpp b/include/MetroidPrime/CFluidPlaneManager.hpp index 10e77485..4e5de3f0 100644 --- a/include/MetroidPrime/CFluidPlaneManager.hpp +++ b/include/MetroidPrime/CFluidPlaneManager.hpp @@ -9,6 +9,12 @@ #include "rstl/reserved_vector.hpp" class CFluidPlaneManager { +public: + // TODO + + void CreateSplash(TUniqueId splasher, CStateManager& mgr, const CScriptWater& water, + const CVector3f& pos, float factor, bool sfx); + private: class CSplashRecord { float x0_time; diff --git a/include/MetroidPrime/CStateManager.hpp b/include/MetroidPrime/CStateManager.hpp index 6e1e9daf..9cc1fda0 100644 --- a/include/MetroidPrime/CStateManager.hpp +++ b/include/MetroidPrime/CStateManager.hpp @@ -154,6 +154,8 @@ public: CEnvFxManager* EnvFxManager() { return x880_envFxManager; } const CEnvFxManager* GetEnvFxManager() const { return x880_envFxManager; } CRumbleManager* GetRumbleManager() { return x88c_rumbleManager; } + CFluidPlaneManager* FluidPlaneManager() { return x87c_fluidPlaneManager; } + const CFluidPlaneManager* GetFluidPlaneManager() const { return x87c_fluidPlaneManager; } CRandom16* Random() const { return x900_random; } diff --git a/include/MetroidPrime/ScriptObjects/CScriptWater.hpp b/include/MetroidPrime/ScriptObjects/CScriptWater.hpp index e114fcd4..fe04b308 100644 --- a/include/MetroidPrime/ScriptObjects/CScriptWater.hpp +++ b/include/MetroidPrime/ScriptObjects/CScriptWater.hpp @@ -3,17 +3,84 @@ #include "types.h" +#include "MetroidPrime/ScriptObjects/CScriptTrigger.hpp" + +#include "Kyoto/Math/CFrustumPlanes.hpp" +#include "Kyoto/TToken.hpp" + +#include "rstl/list.hpp" +#include "rstl/optional_object.hpp" +#include "rstl/pair.hpp" #include "rstl/single_ptr.hpp" class CFluidPlaneCPU; +class CGenDescription; -class CScriptWater { +class CScriptWater : public CScriptTrigger { public: + // TODO + + bool CanRippleAtPoint(const CVector3f&) const; + CFluidPlaneCPU& FluidPlane() { return *x1b4_fluidPlane; } + float GetSurfaceZ() const { return GetTriggerBoundsWR().GetMaxPoint().GetZ(); } private: - uchar x0_pad[0x1b4]; + CFrustumPlanes x150_frustum; rstl::single_ptr< CFluidPlaneCPU > x1b4_fluidPlane; + CVector3f x1b8_positionMorphed; + CVector3f x1c4_extentMorphed; + float x1d0_morphInTime; + CVector3f x1d4_positionOrig; + CVector3f x1e0_extentOrig; + float x1ec_damageOrig; + float x1f0_damageMorphed; + float x1f4_morphOutTime; + float x1f8_morphFactor; + rstl::list< rstl::pair< TUniqueId, bool > > x1fc_waterInhabitants; + float x214_fogBias; + float x218_fogMagnitude; + float x21c_origFogBias; + float x220_origFogMagnitude; + float x224_fogSpeed; + CColor x228_fogColor; + CAssetId x22c_splashParticle1Id; + CAssetId x230_splashParticle2Id; + CAssetId x234_splashParticle3Id; + CAssetId x238_visorRunoffParticleId; + rstl::optional_object< TLockedToken< CGenDescription > > x23c_visorRunoffEffect; + CAssetId x24c_unmorphVisorRunoffParticleId; + rstl::optional_object< TLockedToken< CGenDescription > > x250_unmorphVisorRunoffEffect; + ushort x260_visorRunoffSfx; + ushort x262_unmorphVisorRunoffSfx; + rstl::reserved_vector< rstl::optional_object< TLockedToken< CGenDescription > >, 3 > + x264_splashEffects; + rstl::reserved_vector< ushort, 3 > x298_splashSounds; + CColor x2a4_splashColor; + CColor x2a8_insideFogColor; + float x2ac_alphaInTime; + float x2b0_alphaOutTime; + float x2b4_alphaInRecip; + float x2b8_alphaOutRecip; + float x2bc_alpha; + float x2c0_tileSize; + int x2c4_gridDimX; + int x2c8_gridDimY; + int x2cc_gridCellCount; + int x2d0_patchDimX; + int x2d4_patchDimY; + rstl::single_ptr< bool[] > x2d8_tileIntersects; + rstl::single_ptr< bool[] > x2dc_vertIntersects; + // 0: all clear, 1: all intersect, 2: partial intersect + rstl::single_ptr< uchar[] > x2e0_patchIntersects; + int x2e4_computedGridCellCount; + bool x2e8_24_b4 : 1; + bool x2e8_25_morphIn : 1; + bool x2e8_26_morphing : 1; + bool x2e8_27_allowRender : 1; + bool x2e8_28_recomputeClipping : 1; + bool x2e8_29_alphaIn : 1; + bool x2e8_30_alphaOut : 1; }; #endif // _CSCRIPTWATER diff --git a/include/MetroidPrime/Weapons/WeaponTypes.hpp b/include/MetroidPrime/Weapons/WeaponTypes.hpp index 67ddc76d..e650e8a2 100644 --- a/include/MetroidPrime/Weapons/WeaponTypes.hpp +++ b/include/MetroidPrime/Weapons/WeaponTypes.hpp @@ -28,8 +28,8 @@ class CWeaponMode { bool x4_26_instantKill : 1; public: - explicit CWeaponMode(EWeaponType type = kWT_None, bool charged = false, bool comboed = false, - bool instaKill = false) + CWeaponMode(EWeaponType type = kWT_None, bool charged = false, bool comboed = false, + bool instaKill = false) : x0_weaponType(type) , x4_24_charged(charged) , x4_25_comboed(comboed) diff --git a/src/MetroidPrime/Weapons/CWeapon.cpp b/src/MetroidPrime/Weapons/CWeapon.cpp index 2cae8f65..6aa96f3f 100644 --- a/src/MetroidPrime/Weapons/CWeapon.cpp +++ b/src/MetroidPrime/Weapons/CWeapon.cpp @@ -1,6 +1,8 @@ #include "MetroidPrime/Weapons/CWeapon.hpp" #include "MetroidPrime/CActorParameters.hpp" +#include "MetroidPrime/CFluidPlaneCPU.hpp" +#include "MetroidPrime/CFluidPlaneManager.hpp" #include "MetroidPrime/ScriptObjects/CScriptWater.hpp" #include @@ -33,10 +35,13 @@ void CWeapon::SetDamageFalloffSpeed(float speed) { void CWeapon::Think(float dt, CStateManager& mgr) { x148_curTime += dt; if ((xe8_projectileAttribs & kPA_DamageFalloff) == kPA_DamageFalloff) { - float damMul = CMath::Max(0.f, 1.f - x148_curTime * x14c_damageFalloffSpeed); - x12c_curDamageInfo = CDamageInfo( - x110_origDamageInfo.GetWeaponMode(), damMul * x110_origDamageInfo.GetDamage(), - damMul * x110_origDamageInfo.GetRadius(), damMul * x110_origDamageInfo.GetKnockBackPower()); + float max = 1.f - x148_curTime * x14c_damageFalloffSpeed; + float scale = CMath::Max(0.f, max); + float damage = scale * x110_origDamageInfo.GetDamage(); + float radius = scale * x110_origDamageInfo.GetRadius(); + float knockback = scale * x110_origDamageInfo.GetKnockBackPower(); + x12c_curDamageInfo = + CDamageInfo(x110_origDamageInfo.GetWeaponMode(), damage, radius, knockback); } else { x12c_curDamageInfo = x110_origDamageInfo; } @@ -57,6 +62,7 @@ void CWeapon::FluidFXThink(EFluidState state, CScriptWater& water, CStateManager mag = 0.1f; break; case kWT_Plasma: + mag = 0.f; break; case kWT_Missile: mag = 0.5f; @@ -80,26 +86,23 @@ void CWeapon::FluidFXThink(EFluidState state, CScriptWater& water, CStateManager if (mag > 1.f) { mag = 1.f; } -#if 0 + if (doRipple) { - CVector3f pos = GetTranslation(); - pos.SetZ(water.GetSurfaceZ()); // <- GetTriggerBoundsWR().GetMax().GetZ() - if (True(xe8_projectileAttribs & EProjectileAttrib::ComboShot)) { + CVector3f pos(GetTranslation().GetX(), GetTranslation().GetY(), water.GetSurfaceZ()); + if ((xe8_projectileAttribs & kPA_ComboShot) != 0) { if (!water.CanRippleAtPoint(pos)) { doRipple = false; } - } else if (state == EFluidState::InFluid) { + } else if (state == kFS_InFluid) { doRipple = false; } if (doRipple) { - water.FluidPlane().AddRipple(mag, x8_uid, pos, water, mgr); - mgr.FluidPlaneManager()->CreateSplash(x8_uid, mgr, water, pos, mag, - state == EFluidState::EnteredFluid || - state == EFluidState::LeftFluid); + bool sfx = state == kFS_EnteredFluid || state == kFS_LeftFluid; + water.FluidPlane().AddRipple(mag, GetUniqueId(), pos, water, mgr); + mgr.FluidPlaneManager()->CreateSplash(GetUniqueId(), mgr, water, pos, mag, sfx); } } -#endif } void CWeapon::Render(const CStateManager& mgr) const {}