#ifndef __URDE_CGUNWEAPON_HPP__ #define __URDE_CGUNWEAPON_HPP__ #include "RetroTypes.hpp" #include "CWeaponMgr.hpp" #include "Collision/CMaterialList.hpp" #include "zeus/CVector3f.hpp" #include "CPlayerState.hpp" #include "Character/CAnimCharacterSet.hpp" #include "Particle/CElementGen.hpp" #include "CToken.hpp" #include "CStateManager.hpp" #include "CGunController.hpp" #include "WeaponCommon.hpp" #include "CGunMotion.hpp" #include "World/CDamageInfo.hpp" namespace urde { class CActorLights; struct CModelFlags; class CWeaponDescription; enum class EChargeState { Normal, Charged }; using SWeaponInfo = DataSpec::SWeaponInfo; using SShotParam = DataSpec::SShotParam; using SChargedShotParam = DataSpec::SChargedShotParam; class CVelocityInfo { friend class CGunWeapon; rstl::reserved_vector x0_vel; rstl::reserved_vector x1c_targetHoming; rstl::reserved_vector x24_trat; public: 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(); } }; class CGunWeapon { public: enum class ESecondaryFxType { None, Charge, ToCombo, CancelCharge }; enum class EFrozenFxType { None, Frozen, Thawed }; protected: static const s32 skShootAnim[2]; zeus::CVector3f x4_scale; std::experimental::optional x10_solidModelData; std::experimental::optional x60_holoModelData; std::experimental::optional xb0_suitArmModelData; std::unique_ptr x100_gunController; TToken x104_gunCharacter; std::vector x10c_anims; std::vector x12c_deps; TToken x13c_armCharacter; rstl::reserved_vector, 2> x144_weapons; TCachedToken x160_xferEffect; rstl::reserved_vector, 2> x16c_muzzleEffects; rstl::reserved_vector, 2> x188_frozenEffects; rstl::reserved_vector, 2> x1a4_muzzleGenerators; std::unique_ptr 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; u32 x210_ = 0; CAssetId x214_ancsId; union { struct { bool x218_24 : 1; bool x218_25_enableCharge : 1; bool x218_26_loaded : 1; // Initialize in selected beam's pose, rather than power beam's pose bool x218_27_subtypeBasePose : 1; bool x218_28_suitArmLocked : 1; bool x218_29_drawHologram : 1; }; u32 _dummy = 0; }; void AllocResPools(CPlayerState::EBeamId beam); void FreeResPools(); void FillTokenVector(const std::vector& tags, std::vector& 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(); static void PointGenerator(void* ctx, const std::vector>& vn); public: CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId playerId, EMaterialTypes playerMaterial, const zeus::CVector3f& scale); 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, const CActorLights* lights) const; 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; void DrawHologram(const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags) const; 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& 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; } static CDamageInfo GetShotDamageInfo(const SShotParam& shotParam, CStateManager& mgr); }; } #endif // __URDE_CGUNWEAPON_HPP__