Match CWeapon::FluidFXThink

Former-commit-id: 492b31276a
This commit is contained in:
Luke Street 2022-11-01 22:57:25 -04:00
parent 5707a847da
commit b067d9b978
5 changed files with 96 additions and 18 deletions

View File

@ -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;

View File

@ -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; }

View File

@ -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

View File

@ -28,7 +28,7 @@ class CWeaponMode {
bool x4_26_instantKill : 1;
public:
explicit CWeaponMode(EWeaponType type = kWT_None, bool charged = false, bool comboed = false,
CWeaponMode(EWeaponType type = kWT_None, bool charged = false, bool comboed = false,
bool instaKill = false)
: x0_weaponType(type)
, x4_24_charged(charged)

View File

@ -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 <rstl/math.hpp>
@ -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 {}