2020-03-26 07:30:54 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Runtime/Character/CModelData.hpp"
|
|
|
|
#include "Runtime/Collision/CCollidableSphere.hpp"
|
2020-03-30 07:05:16 +00:00
|
|
|
#include "Runtime/MP1/World/CBouncyGrenade.hpp"
|
2020-03-26 07:30:54 +00:00
|
|
|
#include "Runtime/Particle/CGenDescription.hpp"
|
|
|
|
#include "Runtime/World/CActorParameters.hpp"
|
|
|
|
#include "Runtime/World/CDamageInfo.hpp"
|
|
|
|
#include "Runtime/World/CDamageVulnerability.hpp"
|
|
|
|
#include "Runtime/World/CEntityInfo.hpp"
|
|
|
|
#include "Runtime/World/CHealthInfo.hpp"
|
|
|
|
#include "Runtime/World/CPhysicsActor.hpp"
|
|
|
|
|
|
|
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <string_view>
|
|
|
|
#include <zeus/CColor.hpp>
|
|
|
|
#include <zeus/CTransform.hpp>
|
|
|
|
#include <zeus/CQuaternion.hpp>
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce::MP1 {
|
2020-03-29 07:28:14 +00:00
|
|
|
struct SGrenadeTrajectoryInfo {
|
2020-03-31 00:40:38 +00:00
|
|
|
private:
|
|
|
|
float x0_velocityMin;
|
|
|
|
float x4_velocityMax;
|
2020-03-29 07:28:14 +00:00
|
|
|
float x8_angleMin;
|
|
|
|
float xc_angleMax;
|
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
public:
|
2020-03-30 23:31:14 +00:00
|
|
|
explicit SGrenadeTrajectoryInfo(CInputStream& in)
|
2022-02-18 07:37:54 +00:00
|
|
|
: x0_velocityMin(in.ReadFloat())
|
|
|
|
, x4_velocityMax(in.ReadFloat())
|
|
|
|
, x8_angleMin(zeus::degToRad(in.ReadFloat()))
|
|
|
|
, xc_angleMax(zeus::degToRad(in.ReadFloat())) {}
|
2020-03-31 00:40:38 +00:00
|
|
|
|
|
|
|
[[nodiscard]] float GetVelocityMin() const { return x0_velocityMin; }
|
|
|
|
[[nodiscard]] float GetVelocityMax() const { return x4_velocityMax; }
|
|
|
|
[[nodiscard]] float GetAngleMin() const { return x8_angleMin; }
|
|
|
|
[[nodiscard]] float GetAngleMax() const { return xc_angleMax; }
|
2020-03-29 07:28:14 +00:00
|
|
|
};
|
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
struct SGrenadeLauncherData {
|
|
|
|
private:
|
2020-03-30 07:05:16 +00:00
|
|
|
SBouncyGrenadeData x0_grenadeData;
|
2020-05-07 23:13:43 +00:00
|
|
|
CAssetId x3c_grenadeModelId;
|
|
|
|
CAssetId x40_shootParticleGenDescId;
|
|
|
|
u16 x44_shootSfxId;
|
|
|
|
SGrenadeTrajectoryInfo x48_grenadeTrajectoryInfo;
|
2020-03-26 07:30:54 +00:00
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
public:
|
2020-05-07 23:13:43 +00:00
|
|
|
SGrenadeLauncherData(const SBouncyGrenadeData& data, CAssetId grenadeModelId, CAssetId shootParticleGenDescId,
|
|
|
|
u16 shootSfxId, const SGrenadeTrajectoryInfo& grenadeTrajectoryInfo)
|
2020-03-30 07:05:16 +00:00
|
|
|
: x0_grenadeData(data)
|
2020-05-07 23:13:43 +00:00
|
|
|
, x3c_grenadeModelId(grenadeModelId)
|
|
|
|
, x40_shootParticleGenDescId(shootParticleGenDescId)
|
|
|
|
, x44_shootSfxId(shootSfxId)
|
2020-08-23 19:03:33 +00:00
|
|
|
, x48_grenadeTrajectoryInfo(grenadeTrajectoryInfo) {}
|
2020-03-31 00:40:38 +00:00
|
|
|
|
|
|
|
[[nodiscard]] const SBouncyGrenadeData& GetGrenadeData() const { return x0_grenadeData; }
|
2020-05-07 23:13:43 +00:00
|
|
|
[[nodiscard]] CAssetId GetGrenadeModelId() const { return x3c_grenadeModelId; }
|
|
|
|
[[nodiscard]] CAssetId GetShootParticleGenDescId() const { return x40_shootParticleGenDescId; }
|
|
|
|
[[nodiscard]] u16 GetShootSfxId() const { return x44_shootSfxId; }
|
|
|
|
[[nodiscard]] const SGrenadeTrajectoryInfo& GetGrenadeTrajectoryInfo() const { return x48_grenadeTrajectoryInfo; }
|
2020-03-26 07:30:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CGrenadeLauncher : public CPhysicsActor {
|
2020-03-31 00:40:38 +00:00
|
|
|
private:
|
2020-03-30 03:45:55 +00:00
|
|
|
int x258_started = 0;
|
|
|
|
CHealthInfo x25c_healthInfo;
|
2020-03-26 07:30:54 +00:00
|
|
|
CDamageVulnerability x264_vulnerability;
|
2020-03-30 03:45:55 +00:00
|
|
|
TUniqueId x2cc_parentId;
|
2020-03-31 00:40:38 +00:00
|
|
|
SGrenadeLauncherData x2d0_data;
|
2020-03-26 07:30:54 +00:00
|
|
|
CCollidableSphere x328_cSphere;
|
2020-03-30 03:45:55 +00:00
|
|
|
float x348_shotTimer = -1.f;
|
2020-03-26 07:30:54 +00:00
|
|
|
zeus::CColor x34c_color1{1.f};
|
2020-03-30 07:05:16 +00:00
|
|
|
CActorParameters x350_grenadeActorParams;
|
2020-03-30 03:45:55 +00:00
|
|
|
std::optional<TLockedToken<CGenDescription>> x3b8_particleGenDesc;
|
2020-03-31 00:40:38 +00:00
|
|
|
std::array<s32, 4> x3c8_animIds{};
|
2020-03-26 07:30:54 +00:00
|
|
|
float x3d8_ = 0.f;
|
|
|
|
float x3dc_ = 0.f;
|
|
|
|
float x3e0_ = 0.f;
|
|
|
|
float x3e4_ = 0.f;
|
|
|
|
float x3e8_thermalMag;
|
2020-03-30 03:45:55 +00:00
|
|
|
float x3ec_damageTimer = 0.f;
|
2020-03-26 07:30:54 +00:00
|
|
|
zeus::CColor x3f0_color2{0.5f, 0.f, 0.f};
|
2020-05-07 23:13:43 +00:00
|
|
|
zeus::CColor x3f4_damageAddColor{0.f};
|
2020-03-30 07:05:16 +00:00
|
|
|
float x3f8_explodePlayerDistance;
|
2020-03-30 03:45:55 +00:00
|
|
|
bool x3fc_launchGrenade = false;
|
|
|
|
bool x3fd_visible = true;
|
2020-04-04 06:08:16 +00:00
|
|
|
bool x3fe_followPlayer = true;
|
2020-03-26 07:30:54 +00:00
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
public:
|
2021-05-26 14:00:57 +00:00
|
|
|
DEFINE_ENTITY
|
2020-03-26 07:30:54 +00:00
|
|
|
CGrenadeLauncher(TUniqueId uid, std::string_view name, const CEntityInfo& info, const zeus::CTransform& xf,
|
|
|
|
CModelData&& mData, const zeus::CAABox& bounds, const CHealthInfo& healthInfo,
|
2020-03-30 03:45:55 +00:00
|
|
|
const CDamageVulnerability& vulnerability, const CActorParameters& actParams, TUniqueId parentId,
|
2020-03-31 00:40:38 +00:00
|
|
|
const SGrenadeLauncherData& data, float f1);
|
2020-03-26 07:30:54 +00:00
|
|
|
|
|
|
|
void Accept(IVisitor& visitor) override { visitor.Visit(this); }
|
2020-03-30 03:45:55 +00:00
|
|
|
void AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr) override;
|
2020-04-05 11:54:02 +00:00
|
|
|
void AddToRenderer(const zeus::CFrustum& frustum, CStateManager& mgr) override;
|
2020-03-30 23:42:11 +00:00
|
|
|
[[nodiscard]] const CCollisionPrimitive* GetCollisionPrimitive() const override { return &x328_cSphere; }
|
|
|
|
[[nodiscard]] const CDamageVulnerability* GetDamageVulnerability() const override { return &x264_vulnerability; }
|
|
|
|
[[nodiscard]] std::optional<zeus::CAABox> GetTouchBounds() const override;
|
|
|
|
CHealthInfo* HealthInfo(CStateManager& mgr) override { return &x25c_healthInfo; }
|
2020-03-30 03:45:55 +00:00
|
|
|
void PreRender(CStateManager& mgr, const zeus::CFrustum& frustum) override;
|
2020-04-09 17:28:20 +00:00
|
|
|
void Render(CStateManager& mgr) override;
|
2020-03-30 03:45:55 +00:00
|
|
|
void Think(float dt, CStateManager& mgr) override;
|
|
|
|
void Touch(CActor& act, CStateManager& mgr) override;
|
2020-03-29 07:28:14 +00:00
|
|
|
|
2020-05-07 23:13:43 +00:00
|
|
|
void SetAddColor(const zeus::CColor& color) { x3f4_damageAddColor = color; }
|
2020-04-05 05:36:58 +00:00
|
|
|
void SetVisible(bool val) { x3fd_visible = val; }
|
2020-04-04 06:08:16 +00:00
|
|
|
void SetFollowPlayer(bool val) { x3fe_followPlayer = val; }
|
|
|
|
|
2020-03-29 07:28:14 +00:00
|
|
|
static zeus::CVector3f GrenadeTarget(const CStateManager& mgr);
|
|
|
|
static void CalculateGrenadeTrajectory(const zeus::CVector3f& target, const zeus::CVector3f& origin,
|
|
|
|
const SGrenadeTrajectoryInfo& info, float& angleOut, float& velocityOut);
|
2020-03-26 07:30:54 +00:00
|
|
|
|
2020-03-31 00:40:38 +00:00
|
|
|
private:
|
2020-03-26 07:30:54 +00:00
|
|
|
void UpdateCollision();
|
|
|
|
void UpdateColor(float arg);
|
2020-04-01 01:29:14 +00:00
|
|
|
void UpdateDamageTime(float arg);
|
2020-03-30 03:45:55 +00:00
|
|
|
void CreateExplosion(CStateManager& mgr);
|
2020-04-07 23:26:22 +00:00
|
|
|
void UpdateFollowPlayer(CStateManager& mgr, float dt);
|
2020-05-07 23:13:43 +00:00
|
|
|
void UpdateStartAnimation();
|
2020-03-30 03:45:55 +00:00
|
|
|
void LaunchGrenade(CStateManager& mgr);
|
2020-03-26 07:30:54 +00:00
|
|
|
};
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce::MP1
|