2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-08-14 21:11:44 +00:00
|
|
|
|
2019-10-19 04:06:25 +00:00
|
|
|
#include <array>
|
2019-09-22 21:52:05 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "Runtime/RetroTypes.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CPlayerState.hpp"
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/CToken.hpp"
|
|
|
|
#include "Runtime/rstl.hpp"
|
|
|
|
#include "Runtime/Character/CAnimCharacterSet.hpp"
|
|
|
|
#include "Runtime/Collision/CMaterialList.hpp"
|
|
|
|
#include "Runtime/Particle/CElementGen.hpp"
|
2020-04-20 01:09:30 +00:00
|
|
|
#include "Runtime/Particle/CWeaponDescription.hpp"
|
2019-09-22 21:52:05 +00:00
|
|
|
#include "Runtime/Weapon/CGunController.hpp"
|
|
|
|
#include "Runtime/Weapon/CGunMotion.hpp"
|
|
|
|
#include "Runtime/Weapon/CWeaponMgr.hpp"
|
|
|
|
#include "Runtime/Weapon/WeaponCommon.hpp"
|
|
|
|
#include "Runtime/World/CDamageInfo.hpp"
|
|
|
|
|
|
|
|
#include <zeus/CVector3f.hpp>
|
2016-08-14 21:11:44 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
2016-08-14 21:11:44 +00:00
|
|
|
|
2016-12-10 02:35:20 +00:00
|
|
|
class CActorLights;
|
2016-12-11 01:54:08 +00:00
|
|
|
struct CModelFlags;
|
2017-07-23 23:45:04 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class EChargeState { Normal, Charged };
|
2017-08-27 03:02:18 +00:00
|
|
|
|
2017-08-26 04:36:25 +00:00
|
|
|
using SWeaponInfo = DataSpec::SWeaponInfo;
|
2017-09-05 03:00:19 +00:00
|
|
|
using SShotParam = DataSpec::SShotParam;
|
|
|
|
using SChargedShotParam = DataSpec::SChargedShotParam;
|
2017-08-26 04:36:25 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CVelocityInfo {
|
|
|
|
friend class CGunWeapon;
|
|
|
|
rstl::reserved_vector<zeus::CVector3f, 2> x0_vel;
|
|
|
|
rstl::reserved_vector<bool, 2> x1c_targetHoming;
|
|
|
|
rstl::reserved_vector<float, 2> x24_trat;
|
|
|
|
|
2017-07-23 23:45:04 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
const zeus::CVector3f& GetVelocity(int i) const { return x0_vel[i]; }
|
|
|
|
bool GetTargetHoming(int i) const { return x1c_targetHoming[i]; }
|
|
|
|
void Clear() {
|
|
|
|
x0_vel.clear();
|
|
|
|
x1c_targetHoming.clear();
|
|
|
|
x24_trat.clear();
|
|
|
|
}
|
2017-07-23 23:45:04 +00:00
|
|
|
};
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
class CGunWeapon {
|
2016-08-14 21:11:44 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
enum class ESecondaryFxType { None, Charge, ToCombo, CancelCharge };
|
|
|
|
enum class EFrozenFxType { None, Frozen, Thawed };
|
|
|
|
|
2016-12-10 02:35:20 +00:00
|
|
|
protected:
|
2019-10-19 04:06:25 +00:00
|
|
|
static const std::array<s32, 2> skShootAnim;
|
2018-12-08 05:30:43 +00:00
|
|
|
zeus::CVector3f x4_scale;
|
2019-06-12 02:05:17 +00:00
|
|
|
std::optional<CModelData> x10_solidModelData;
|
|
|
|
std::optional<CModelData> x60_holoModelData;
|
|
|
|
std::optional<CModelData> xb0_suitArmModelData;
|
2018-12-08 05:30:43 +00:00
|
|
|
std::unique_ptr<CGunController> x100_gunController;
|
|
|
|
TToken<CAnimCharacterSet> x104_gunCharacter;
|
|
|
|
std::vector<CToken> x10c_anims;
|
|
|
|
std::vector<CToken> x12c_deps;
|
|
|
|
TToken<CAnimCharacterSet> x13c_armCharacter;
|
|
|
|
rstl::reserved_vector<TCachedToken<CWeaponDescription>, 2> x144_weapons;
|
|
|
|
TCachedToken<CGenDescription> x160_xferEffect;
|
|
|
|
rstl::reserved_vector<TCachedToken<CGenDescription>, 2> x16c_muzzleEffects;
|
|
|
|
rstl::reserved_vector<TCachedToken<CGenDescription>, 2> x188_frozenEffects;
|
|
|
|
rstl::reserved_vector<std::unique_ptr<CElementGen>, 2> x1a4_muzzleGenerators;
|
|
|
|
std::unique_ptr<CElementGen> x1b8_frozenGenerator;
|
|
|
|
CRainSplashGenerator* x1bc_rainSplashGenerator = nullptr;
|
|
|
|
EWeaponType x1c0_weaponType;
|
|
|
|
TUniqueId x1c4_playerId;
|
|
|
|
EMaterialTypes x1c8_playerMaterial;
|
|
|
|
ESecondaryFxType x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
|
|
|
|
CVelocityInfo x1d0_velInfo;
|
|
|
|
CPlayerState::EBeamId x200_beamId;
|
|
|
|
EFrozenFxType x204_frozenEffect = EFrozenFxType::None;
|
|
|
|
u32 x208_muzzleEffectIdx = 0;
|
|
|
|
u32 x20c_shaderIdx;
|
|
|
|
// 0x1: load request, 0x2: muzzle fx, 0x4: projectile data, 0x8: anims, 0x10: everything else
|
|
|
|
u32 x210_loadFlags = 0;
|
|
|
|
CAssetId x214_ancsId;
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x218_24 : 1 = false;
|
|
|
|
bool x218_25_enableCharge : 1 = false;
|
|
|
|
bool x218_26_loaded : 1 = false;
|
2020-04-11 04:49:02 +00:00
|
|
|
// Initialize in selected beam's pose, rather than power beam's pose
|
2020-04-20 04:57:50 +00:00
|
|
|
bool x218_27_subtypeBasePose : 1 = false;
|
|
|
|
bool x218_28_suitArmLocked : 1 = false;
|
|
|
|
bool x218_29_drawHologram : 1 = false;
|
2017-08-26 04:36:25 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void AllocResPools(CPlayerState::EBeamId beam);
|
|
|
|
void FreeResPools();
|
|
|
|
void FillTokenVector(const std::vector<SObjectTag>& tags, std::vector<CToken>& objects);
|
|
|
|
void BuildDependencyList(CPlayerState::EBeamId beam);
|
|
|
|
void LoadSuitArm(CStateManager& mgr);
|
|
|
|
void LoadGunModels(CStateManager& mgr);
|
|
|
|
void LoadAnimations();
|
|
|
|
bool IsAnimsLoaded() const;
|
|
|
|
void LoadMuzzleFx(float dt);
|
|
|
|
void LoadProjectileData(CStateManager& mgr);
|
|
|
|
void LoadFxIdle(float dt, CStateManager& mgr);
|
|
|
|
void LockTokens(CStateManager& mgr);
|
|
|
|
void UnlockTokens();
|
2017-09-05 03:00:19 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static void PointGenerator(void* ctx, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn);
|
2017-09-05 03:00:19 +00:00
|
|
|
|
2016-12-10 02:35:20 +00:00
|
|
|
public:
|
2018-12-08 05:30:43 +00:00
|
|
|
CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId playerId, EMaterialTypes playerMaterial,
|
|
|
|
const zeus::CVector3f& scale);
|
2020-03-12 21:19:33 +00:00
|
|
|
virtual ~CGunWeapon();
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void AsyncLoadSuitArm(CStateManager& mgr);
|
|
|
|
virtual void Reset(CStateManager& mgr);
|
|
|
|
virtual void PlayAnim(NWeaponTypes::EGunAnimType type, bool loop);
|
|
|
|
virtual void PreRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
|
|
|
|
virtual void PostRenderGunFx(const CStateManager& mgr, const zeus::CTransform& xf);
|
|
|
|
virtual void UpdateGunFx(bool shotSmoke, float dt, const CStateManager& mgr, const zeus::CTransform& xf);
|
|
|
|
virtual void Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf, CStateManager& mgr,
|
|
|
|
TUniqueId homingTarget, float chargeFactor1, float chargeFactor2);
|
|
|
|
virtual void EnableFx(bool enable);
|
|
|
|
virtual void EnableSecondaryFx(ESecondaryFxType type);
|
|
|
|
void EnableFrozenEffect(EFrozenFxType type);
|
|
|
|
void ActivateCharge(bool enable, bool resetEffect);
|
|
|
|
void Touch(const CStateManager& mgr);
|
|
|
|
void TouchHolo(const CStateManager& mgr);
|
|
|
|
virtual void Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags,
|
2020-04-05 12:29:43 +00:00
|
|
|
const CActorLights* lights);
|
2018-12-08 05:30:43 +00:00
|
|
|
virtual void DrawMuzzleFx(const CStateManager& mgr) const;
|
|
|
|
virtual void Update(float dt, CStateManager& mgr);
|
|
|
|
virtual void Load(CStateManager& mgr, bool subtypeBasePose);
|
|
|
|
virtual void Unload(CStateManager& mgr);
|
|
|
|
virtual bool IsLoaded() const;
|
2020-04-05 12:29:43 +00:00
|
|
|
void DrawHologram(const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags);
|
2018-12-08 05:30:43 +00:00
|
|
|
void UpdateMuzzleFx(float dt, const zeus::CVector3f& scale, const zeus::CVector3f& pos, bool emitting);
|
|
|
|
const CVelocityInfo& GetVelocityInfo() const { return x1d0_velInfo; }
|
|
|
|
void SetRainSplashGenerator(CRainSplashGenerator* g) { x1bc_rainSplashGenerator = g; }
|
|
|
|
CElementGen* GetChargeMuzzleFx() const { return x1a4_muzzleGenerators[1].get(); }
|
|
|
|
const TToken<CGenDescription>& GetComboXferDescr() const { return x160_xferEffect; }
|
|
|
|
void ReturnToDefault(CStateManager& mgr);
|
|
|
|
bool PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr, float angle);
|
|
|
|
void UnLoadFidget();
|
|
|
|
bool IsFidgetLoaded() const;
|
|
|
|
void AsyncLoadFidget(CStateManager& mgr, SamusGun::EFidgetType type, s32 animSet);
|
|
|
|
void EnterFidget(CStateManager& mgr, SamusGun::EFidgetType type, s32 parm2);
|
|
|
|
bool HasSolidModelData() const { return x10_solidModelData.operator bool(); }
|
|
|
|
CModelData& GetSolidModelData() { return *x10_solidModelData; }
|
|
|
|
const SWeaponInfo& GetWeaponInfo() const;
|
|
|
|
CDamageInfo GetDamageInfo(CStateManager& mgr, EChargeState chargeState, float chargeFactor) const;
|
|
|
|
EWeaponType GetWeaponType() const { return x1c0_weaponType; }
|
|
|
|
zeus::CAABox GetBounds() const;
|
|
|
|
zeus::CAABox GetBounds(const zeus::CTransform& xf) const;
|
|
|
|
bool ComboFireOver() const { return x100_gunController->IsComboOver(); }
|
|
|
|
bool IsChargeAnimOver() const;
|
|
|
|
void SetDrawHologram(bool d) { x218_29_drawHologram = d; }
|
|
|
|
void EnableCharge(bool c) { x218_25_enableCharge = c; }
|
2017-09-10 00:36:21 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
static CDamageInfo GetShotDamageInfo(const SShotParam& shotParam, CStateManager& mgr);
|
2016-12-10 02:35:20 +00:00
|
|
|
};
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|