2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2017-03-29 02:51:12 +00:00
|
|
|
|
2019-09-23 19:00:23 +00:00
|
|
|
#include "Runtime/Collision/CCollisionSurface.hpp"
|
2020-02-21 04:27:12 +00:00
|
|
|
#include "Runtime/Particle/CElementGen.hpp"
|
2019-09-23 19:00:23 +00:00
|
|
|
#include "Runtime/World/CActor.hpp"
|
2020-02-21 04:27:12 +00:00
|
|
|
#include "Runtime/World/CDamageInfo.hpp"
|
2017-03-29 02:51:12 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2018-06-23 23:08:16 +00:00
|
|
|
class CAnimationParameters;
|
2019-09-23 19:00:23 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CSnakeWeedSwarm : public CActor {
|
2020-02-23 23:30:46 +00:00
|
|
|
public:
|
|
|
|
enum class EBoidState : u32 {
|
2020-02-24 07:55:19 +00:00
|
|
|
Raised = 0,
|
2020-03-01 07:52:17 +00:00
|
|
|
Raising = 1,
|
2020-03-17 00:07:20 +00:00
|
|
|
Lowered = 2,
|
|
|
|
Lowering = 3,
|
2020-02-23 23:30:46 +00:00
|
|
|
};
|
|
|
|
|
2020-02-24 07:55:19 +00:00
|
|
|
enum class EBoidPlacement : u32 {
|
|
|
|
None = 0,
|
|
|
|
Ready = 1,
|
|
|
|
Invalid = 2,
|
|
|
|
Placed = 3,
|
|
|
|
};
|
|
|
|
|
2020-02-23 23:30:46 +00:00
|
|
|
class CBoid {
|
|
|
|
zeus::CVector3f x0_pos;
|
|
|
|
EBoidState xc_state;
|
2020-03-17 00:07:20 +00:00
|
|
|
float x10_loweredTimer = 0.f;
|
|
|
|
float x14_zOffset;
|
|
|
|
float x18_speed;
|
|
|
|
// x1c unused
|
|
|
|
float x20_scale;
|
2020-02-23 23:30:46 +00:00
|
|
|
|
|
|
|
public:
|
2020-03-17 00:07:20 +00:00
|
|
|
constexpr CBoid(const zeus::CVector3f& pos, float zOffset, float speed, float scale)
|
|
|
|
: x0_pos(pos), xc_state(EBoidState::Raising), x14_zOffset(zOffset), x18_speed(speed), x20_scale(scale) {}
|
2020-02-23 23:30:46 +00:00
|
|
|
|
|
|
|
constexpr const zeus::CVector3f& GetPosition() const { return x0_pos; }
|
|
|
|
constexpr EBoidState GetState() const { return xc_state; }
|
2020-03-17 00:07:20 +00:00
|
|
|
constexpr float GetLoweredTimer() const { return x10_loweredTimer; }
|
|
|
|
constexpr float GetZOffset() const { return x14_zOffset; }
|
|
|
|
constexpr float GetSpeed() const { return x18_speed; }
|
|
|
|
constexpr float GetScale() const { return x20_scale; }
|
2020-03-01 08:05:16 +00:00
|
|
|
constexpr void SetState(EBoidState v) { xc_state = v; }
|
2020-03-17 00:07:20 +00:00
|
|
|
constexpr void SetLoweredTimer(float v) { x10_loweredTimer = v; }
|
|
|
|
constexpr void SetZOffset(float v) { x14_zOffset = v; }
|
|
|
|
constexpr void SetSpeed(float v) { x18_speed = v; }
|
2020-02-23 23:30:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
private:
|
2020-02-21 04:27:12 +00:00
|
|
|
zeus::CVector3f xe8_scale;
|
2020-02-24 07:55:19 +00:00
|
|
|
float xf4_boidSpacing;
|
|
|
|
float xf8_height;
|
2020-02-21 04:27:12 +00:00
|
|
|
float xfc_;
|
2020-02-24 07:55:19 +00:00
|
|
|
float x100_weaponDamageRadius;
|
2020-03-17 00:07:20 +00:00
|
|
|
float x104_maxPlayerDistance;
|
|
|
|
float x108_loweredTime;
|
|
|
|
float x10c_loweredTimeVariation;
|
|
|
|
float x110_maxZOffset;
|
|
|
|
float x114_speed;
|
|
|
|
float x118_speedVariation;
|
2020-02-21 04:27:12 +00:00
|
|
|
float x11c_;
|
2020-03-17 00:07:20 +00:00
|
|
|
float x120_scaleMin;
|
|
|
|
float x124_scaleMax;
|
|
|
|
float x128_distanceBelowGround;
|
2020-02-24 07:55:19 +00:00
|
|
|
// u32 x12c_ = 0;
|
2020-02-23 23:30:46 +00:00
|
|
|
std::vector<CBoid> x134_boids;
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x140_24_hasGround : 1 = false;
|
|
|
|
bool x140_25_modelAssetDirty : 1 = false;
|
|
|
|
bool x140_26_playerTouching : 1 = false;
|
2020-02-24 07:55:19 +00:00
|
|
|
zeus::CAABox x144_touchBounds = zeus::skInvertedBox;
|
|
|
|
CDamageInfo x15c_damageInfo;
|
2020-02-25 19:09:49 +00:00
|
|
|
// x178_ / x19c_: vectors of CSkinnedModel*, not needed
|
2020-03-17 00:07:20 +00:00
|
|
|
rstl::reserved_vector<std::unique_ptr<CModelData>, 4> x1b0_modelData;
|
2020-02-24 07:55:19 +00:00
|
|
|
CModelData::EWhichModel x1c4_which;
|
|
|
|
std::unique_ptr<std::vector<zeus::CVector3f>> x1c8_boidPositions;
|
|
|
|
std::unique_ptr<std::vector<EBoidPlacement>> x1cc_boidPlacement;
|
2020-02-21 04:27:12 +00:00
|
|
|
u16 x1d0_sfx1;
|
|
|
|
u16 x1d2_sfx2;
|
|
|
|
u16 x1d4_sfx3;
|
2020-03-28 00:11:51 +00:00
|
|
|
CSfxHandle x1d8_sfxHandle;
|
2020-02-24 07:55:19 +00:00
|
|
|
TLockedToken<CGenDescription> x1dc_particleGenDesc;
|
|
|
|
// TLockedToken<CGenDescription> x1e4_; both assign to x1dc_
|
2020-02-23 23:30:46 +00:00
|
|
|
std::unique_ptr<CElementGen> x1ec_particleGen1;
|
|
|
|
std::unique_ptr<CElementGen> x1f4_particleGen2;
|
2020-02-21 04:27:12 +00:00
|
|
|
u32 x1fc_;
|
2020-03-17 00:07:20 +00:00
|
|
|
float x200_; // unused?
|
2020-02-24 07:55:19 +00:00
|
|
|
float x204_particleTimer = 0.f;
|
2020-02-21 04:27:12 +00:00
|
|
|
|
2017-03-29 02:51:12 +00:00
|
|
|
public:
|
2020-03-17 00:07:20 +00:00
|
|
|
CSnakeWeedSwarm(TUniqueId uid, bool active, std::string_view name, const CEntityInfo& info,
|
|
|
|
const zeus::CVector3f& pos, const zeus::CVector3f& scale, const CAnimRes& animRes,
|
|
|
|
const CActorParameters& actParms, float spacing, float height, float f3, float weaponDamageRadius,
|
|
|
|
float maxPlayerDistance, float loweredTime, float loweredTimeVariation, float maxZOffset, float speed,
|
|
|
|
float speedVariation, float f11, float scaleMin, float scaleMax, float distanceBelowGround,
|
|
|
|
const CDamageInfo& dInfo, float /*f15*/, u32 sfxId1, u32 sfxId2, u32 sfxId3, CAssetId particleGenDesc1, u32 w5,
|
|
|
|
CAssetId particleGenDesc2, float f16);
|
2018-06-23 23:08:16 +00:00
|
|
|
|
2019-08-09 12:45:18 +00:00
|
|
|
void Accept(IVisitor&) override;
|
2020-02-24 05:43:20 +00:00
|
|
|
void ApplyRadiusDamage(const zeus::CVector3f& pos, const CDamageInfo& info, CStateManager& stateMgr);
|
2020-02-24 07:55:19 +00:00
|
|
|
std::optional<zeus::CAABox> GetTouchBounds() const override;
|
2020-02-23 23:30:46 +00:00
|
|
|
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-02-23 23:30:46 +00:00
|
|
|
void Touch(CActor&, CStateManager&) override;
|
|
|
|
void Think(float, CStateManager&) override;
|
2020-06-26 02:37:45 +00:00
|
|
|
void HandleRadiusDamage(float radius, CStateManager& mgr, const zeus::CVector3f& pos);
|
|
|
|
float GetWeaponDamageRadius() const { return x100_weaponDamageRadius; }
|
2020-02-23 23:30:46 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void AllocateSkinnedModels(CStateManager& mgr, CModelData::EWhichModel which);
|
2020-02-24 07:55:19 +00:00
|
|
|
void FindGround(const CStateManager& mgr);
|
2020-03-26 05:02:14 +00:00
|
|
|
zeus::CAABox GetBoidBox() const;
|
|
|
|
int GetNumBoidsY() const;
|
|
|
|
int GetNumBoidsX() const;
|
2020-02-24 07:55:19 +00:00
|
|
|
void CreateBoids(CStateManager& mgr, int num);
|
2020-03-26 05:02:14 +00:00
|
|
|
zeus::CVector2i GetBoidIndex(const zeus::CVector3f& pos) const;
|
2020-02-23 23:30:46 +00:00
|
|
|
bool CreateBoid(const zeus::CVector3f& vec, CStateManager& mgr);
|
2020-03-26 05:02:14 +00:00
|
|
|
float GetBoidOffsetY(const zeus::CVector3f& pos) const;
|
|
|
|
float GetBoidOffsetX(const zeus::CVector3f& pos) const;
|
2020-02-24 07:55:19 +00:00
|
|
|
void AddBoidPosition(const zeus::CVector3f& pos);
|
|
|
|
void CalculateTouchBounds();
|
2020-02-23 23:30:46 +00:00
|
|
|
void EmitParticles1(const zeus::CVector3f& pos);
|
|
|
|
void EmitParticles2(const zeus::CVector3f& pos);
|
2020-02-25 19:09:49 +00:00
|
|
|
void RenderBoid(u32 idx, const CBoid& boid, u32& posesToBuild) const;
|
2017-03-29 02:51:12 +00:00
|
|
|
};
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|