2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-04-17 02:50:45 +00:00
|
|
|
|
2019-09-23 19:00:23 +00:00
|
|
|
#include <list>
|
|
|
|
#include <memory>
|
|
|
|
#include <optional>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/World/CFluidPlaneCPU.hpp"
|
|
|
|
#include "Runtime/World/CScriptTrigger.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CColor.hpp>
|
|
|
|
#include <zeus/CFrustum.hpp>
|
|
|
|
#include <zeus/CVector3f.hpp>
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-04-17 02:50:45 +00:00
|
|
|
|
2016-04-20 05:44:08 +00:00
|
|
|
class CDamageInfo;
|
|
|
|
class CFluidUVMotion;
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CScriptWater : public CScriptTrigger {
|
|
|
|
zeus::CFrustum x150_frustum;
|
|
|
|
std::unique_ptr<CFluidPlaneCPU> x1b4_fluidPlane;
|
|
|
|
zeus::CVector3f x1b8_positionMorphed;
|
|
|
|
zeus::CVector3f x1c4_extentMorphed;
|
|
|
|
float x1d0_morphInTime;
|
|
|
|
zeus::CVector3f x1d4_positionOrig;
|
|
|
|
zeus::CVector3f x1e0_extentOrig;
|
|
|
|
float x1ec_damageOrig;
|
|
|
|
float x1f0_damageMorphed;
|
|
|
|
float x1f4_morphOutTime;
|
|
|
|
float x1f8_morphFactor = 0.f;
|
|
|
|
std::list<std::pair<TUniqueId, bool>> x1fc_waterInhabitants;
|
|
|
|
float x214_fogBias;
|
|
|
|
float x218_fogMagnitude;
|
|
|
|
float x21c_origFogBias;
|
|
|
|
float x220_origFogMagnitude;
|
|
|
|
float x224_fogSpeed;
|
|
|
|
zeus::CColor x228_fogColor;
|
|
|
|
CAssetId x22c_splashParticle1Id;
|
|
|
|
CAssetId x230_splashParticle2Id;
|
|
|
|
CAssetId x234_splashParticle3Id;
|
|
|
|
CAssetId x238_visorRunoffParticleId;
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<TLockedToken<CGenDescription>> x23c_visorRunoffEffect;
|
2018-12-08 05:30:43 +00:00
|
|
|
CAssetId x24c_unmorphVisorRunoffParticleId;
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<TLockedToken<CGenDescription>> x250_unmorphVisorRunoffEffect;
|
2018-12-08 05:30:43 +00:00
|
|
|
u16 x260_visorRunoffSfx;
|
|
|
|
u16 x262_unmorphVisorRunoffSfx;
|
2019-06-12 02:05:17 +00:00
|
|
|
rstl::reserved_vector<std::optional<TLockedToken<CGenDescription>>, 3> x264_splashEffects;
|
2018-12-08 05:30:43 +00:00
|
|
|
rstl::reserved_vector<u16, 3> x298_splashSounds;
|
|
|
|
zeus::CColor x2a4_splashColor;
|
|
|
|
zeus::CColor x2a8_insideFogColor;
|
|
|
|
float x2ac_alphaInTime;
|
|
|
|
float x2b0_alphaOutTime;
|
|
|
|
float x2b4_alphaInRecip;
|
|
|
|
float x2b8_alphaOutRecip;
|
|
|
|
float x2bc_alpha;
|
|
|
|
float x2c0_tileSize;
|
|
|
|
int x2c4_gridDimX = 0;
|
|
|
|
int x2c8_gridDimY = 0;
|
|
|
|
int x2cc_gridCellCount = 0;
|
|
|
|
int x2d0_patchDimX = 0;
|
|
|
|
int x2d4_patchDimY = 0;
|
|
|
|
std::unique_ptr<bool[]> x2d8_tileIntersects;
|
|
|
|
std::unique_ptr<bool[]> x2dc_vertIntersects;
|
|
|
|
std::unique_ptr<u8[]> x2e0_patchIntersects; // 0: all clear, 1: all intersect, 2: partial intersect
|
|
|
|
int x2e4_computedGridCellCount = 0;
|
2020-04-11 05:50:10 +00:00
|
|
|
bool x2e8_24_b4 : 1;
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x2e8_25_morphIn : 1 = false;
|
|
|
|
bool x2e8_26_morphing : 1 = false;
|
2020-04-11 05:50:10 +00:00
|
|
|
bool x2e8_27_allowRender : 1;
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x2e8_28_recomputeClipping : 1 = true;
|
|
|
|
bool x2e8_29_alphaIn : 1 = false;
|
|
|
|
bool x2e8_30_alphaOut : 1 = false;
|
2020-04-11 05:50:10 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void SetupGrid(bool recomputeClipping);
|
|
|
|
void SetupGridClipping(CStateManager& mgr, int computeVerts);
|
|
|
|
void UpdateSplashInhabitants(CStateManager& mgr);
|
|
|
|
|
2016-04-20 05:44:08 +00:00
|
|
|
public:
|
2021-05-26 14:00:57 +00:00
|
|
|
DEFINE_ENTITY
|
2018-12-08 05:30:43 +00:00
|
|
|
CScriptWater(CStateManager& mgr, TUniqueId uid, std::string_view name, const CEntityInfo& info,
|
2021-04-10 08:42:06 +00:00
|
|
|
const zeus::CVector3f& pos, const zeus::CAABox& box, const metaforce::CDamageInfo& dInfo,
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f& orientedForce, ETriggerFlags triggerFlags, bool thermalCold, bool allowRender,
|
|
|
|
CAssetId patternMap1, CAssetId patternMap2, CAssetId colorMap, CAssetId bumpMap, CAssetId envMap,
|
|
|
|
CAssetId envBumpMap, CAssetId unusedMap, const zeus::CVector3f& bumpLightDir, float bumpScale,
|
|
|
|
float morphInTime, float morphOutTime, bool active, EFluidType fluidType, bool b4, float alpha,
|
|
|
|
const CFluidUVMotion& uvMot, float turbSpeed, float turbDistance, float turbFreqMax, float turbFreqMin,
|
|
|
|
float turbPhaseMax, float turbPhaseMin, float turbAmplitudeMax, float turbAmplitudeMin,
|
|
|
|
const zeus::CColor& splashColor, const zeus::CColor& insideFogColor, CAssetId splashParticle1,
|
|
|
|
CAssetId splashParticle2, CAssetId splashParticle3, CAssetId visorRunoffParticle,
|
|
|
|
CAssetId unmorphVisorRunoffparticle, s32 visorRunoffSfx, s32 unmorphVisorRunoffSfx, s32 splashSfx1,
|
|
|
|
s32 splashSfx2, s32 splashSfx3, float tileSize, u32 tileSubdivisions, float specularMin,
|
|
|
|
float specularMax, float reflectionSize, float rippleIntensity, float reflectionBlend, float fogBias,
|
|
|
|
float fogMagnitude, float fogSpeed, const zeus::CColor& fogColor, CAssetId lightmapId,
|
|
|
|
float unitsPerLightmapTexel, float alphaInTime, float alphaOutTime, u32, u32, bool, s32, s32,
|
|
|
|
std::unique_ptr<u32[]>&& u32Arr);
|
2016-04-17 02:50:45 +00:00
|
|
|
|
2019-08-09 12:45:18 +00:00
|
|
|
void Accept(IVisitor& visitor) override;
|
|
|
|
void Think(float, CStateManager&) override;
|
|
|
|
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&) override;
|
|
|
|
void PreRender(CStateManager&, const zeus::CFrustum&) override;
|
2020-04-05 11:54:02 +00:00
|
|
|
void AddToRenderer(const zeus::CFrustum&, CStateManager&) override;
|
2020-04-09 17:28:20 +00:00
|
|
|
void Render(CStateManager&) override;
|
2019-08-09 12:45:18 +00:00
|
|
|
void Touch(CActor&, CStateManager&) override;
|
|
|
|
void CalculateRenderBounds() override;
|
|
|
|
zeus::CAABox GetSortingBounds(const CStateManager&) const override;
|
2018-12-08 05:30:43 +00:00
|
|
|
EWeaponCollisionResponseTypes GetCollisionResponseType(const zeus::CVector3f&, const zeus::CVector3f&,
|
2019-08-09 12:45:18 +00:00
|
|
|
const CWeaponMode&, EProjectileAttrib) const override;
|
2016-11-20 21:53:15 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
u16 GetSplashSound(float) const;
|
2019-06-12 02:05:17 +00:00
|
|
|
const std::optional<TLockedToken<CGenDescription>>& GetSplashEffect(float) const;
|
2018-12-08 05:30:43 +00:00
|
|
|
float GetSplashEffectScale(float) const;
|
|
|
|
u32 GetSplashIndex(float) const;
|
|
|
|
CFluidPlaneCPU& FluidPlane() { return *x1b4_fluidPlane; }
|
|
|
|
zeus::CPlane GetWRSurfacePlane() const;
|
|
|
|
float GetSurfaceZ() const;
|
|
|
|
bool IsMorphing() const { return x2e8_26_morphing; }
|
|
|
|
void SetMorphing(bool);
|
|
|
|
float GetMorphFactor() const { return x1f8_morphFactor; }
|
|
|
|
zeus::CColor GetSplashColor() const { return x2a4_splashColor; }
|
|
|
|
void SetFrustumPlanes(const zeus::CFrustum& frustum) { x150_frustum = frustum; }
|
|
|
|
const zeus::CFrustum& GetFrustumPlanes() const { return x150_frustum; }
|
|
|
|
CFluidPlaneCPU& GetFluidPlane() const { return *x1b4_fluidPlane; }
|
2019-06-12 02:05:17 +00:00
|
|
|
const std::optional<TLockedToken<CGenDescription>>& GetVisorRunoffEffect() const {
|
2018-12-08 05:30:43 +00:00
|
|
|
return x23c_visorRunoffEffect;
|
|
|
|
}
|
|
|
|
u16 GetVisorRunoffSfx() const { return x260_visorRunoffSfx; }
|
2019-06-12 02:05:17 +00:00
|
|
|
const std::optional<TLockedToken<CGenDescription>>& GetUnmorphVisorRunoffEffect() const {
|
2018-12-08 05:30:43 +00:00
|
|
|
return x250_unmorphVisorRunoffEffect;
|
|
|
|
}
|
|
|
|
u16 GetUnmorphVisorRunoffSfx() const { return x262_unmorphVisorRunoffSfx; }
|
|
|
|
const CScriptWater* GetNextConnectedWater(const CStateManager& mgr) const;
|
|
|
|
u8 GetPatchRenderFlags(int x, int y) const { return x2e0_patchIntersects[y * x2d0_patchDimX + x]; }
|
|
|
|
int GetPatchDimensionX() const { return x2d0_patchDimX; }
|
|
|
|
int GetPatchDimensionY() const { return x2d4_patchDimY; }
|
|
|
|
bool CanRippleAtPoint(const zeus::CVector3f& point) const;
|
|
|
|
const zeus::CColor& GetInsideFogColor() const { return x2a8_insideFogColor; }
|
2016-11-20 21:53:15 +00:00
|
|
|
};
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|