2018-10-07 03:42:33 +00:00
|
|
|
#pragma once
|
2016-08-14 21:11:44 +00:00
|
|
|
|
|
|
|
#include "RetroTypes.hpp"
|
|
|
|
#include "CWeaponMgr.hpp"
|
|
|
|
#include "Collision/CMaterialList.hpp"
|
|
|
|
#include "zeus/CVector3f.hpp"
|
2016-12-10 02:35:20 +00:00
|
|
|
#include "CPlayerState.hpp"
|
|
|
|
#include "Character/CAnimCharacterSet.hpp"
|
|
|
|
#include "Particle/CElementGen.hpp"
|
|
|
|
#include "CToken.hpp"
|
2017-08-25 06:18:09 +00:00
|
|
|
#include "CStateManager.hpp"
|
2017-08-26 04:36:25 +00:00
|
|
|
#include "CGunController.hpp"
|
|
|
|
#include "WeaponCommon.hpp"
|
2017-08-27 03:02:18 +00:00
|
|
|
#include "CGunMotion.hpp"
|
2017-09-05 03:00:19 +00:00
|
|
|
#include "World/CDamageInfo.hpp"
|
2016-08-14 21:11:44 +00:00
|
|
|
|
|
|
|
namespace urde
|
|
|
|
{
|
|
|
|
|
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
|
|
|
class CWeaponDescription;
|
|
|
|
|
2017-08-27 03:02:18 +00:00
|
|
|
enum class EChargeState
|
|
|
|
{
|
|
|
|
Normal,
|
|
|
|
Charged
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2017-07-23 23:45:04 +00:00
|
|
|
class CVelocityInfo
|
|
|
|
{
|
|
|
|
friend class CGunWeapon;
|
|
|
|
rstl::reserved_vector<zeus::CVector3f, 2> x0_vel;
|
2017-08-27 03:02:18 +00:00
|
|
|
rstl::reserved_vector<bool, 2> x1c_targetHoming;
|
2017-09-05 03:00:19 +00:00
|
|
|
rstl::reserved_vector<float, 2> x24_trat;
|
2017-07-23 23:45:04 +00:00
|
|
|
public:
|
|
|
|
const zeus::CVector3f& GetVelocity(int i) const { return x0_vel[i]; }
|
2017-08-27 03:02:18 +00:00
|
|
|
bool GetTargetHoming(int i) const { return x1c_targetHoming[i]; }
|
2017-09-05 03:00:19 +00:00
|
|
|
void Clear()
|
|
|
|
{
|
|
|
|
x0_vel.clear();
|
|
|
|
x1c_targetHoming.clear();
|
|
|
|
x24_trat.clear();
|
|
|
|
}
|
2017-07-23 23:45:04 +00:00
|
|
|
};
|
|
|
|
|
2016-08-14 21:11:44 +00:00
|
|
|
class CGunWeapon
|
|
|
|
{
|
|
|
|
public:
|
2017-08-25 06:18:09 +00:00
|
|
|
enum class ESecondaryFxType
|
2016-12-10 02:35:20 +00:00
|
|
|
{
|
2017-09-07 03:55:31 +00:00
|
|
|
None,
|
|
|
|
Charge,
|
|
|
|
ToCombo,
|
|
|
|
CancelCharge
|
2016-12-10 02:35:20 +00:00
|
|
|
};
|
2017-09-05 03:00:19 +00:00
|
|
|
enum class EFrozenFxType
|
|
|
|
{
|
|
|
|
None,
|
|
|
|
Frozen,
|
|
|
|
Thawed
|
|
|
|
};
|
2016-12-10 02:35:20 +00:00
|
|
|
protected:
|
2017-09-05 03:00:19 +00:00
|
|
|
static const s32 skShootAnim[2];
|
2017-08-22 03:20:22 +00:00
|
|
|
zeus::CVector3f x4_scale;
|
2017-08-26 04:36:25 +00:00
|
|
|
std::experimental::optional<CModelData> x10_solidModelData;
|
2017-09-05 03:00:19 +00:00
|
|
|
std::experimental::optional<CModelData> x60_holoModelData;
|
|
|
|
std::experimental::optional<CModelData> xb0_suitArmModelData;
|
2017-08-26 04:36:25 +00:00
|
|
|
std::unique_ptr<CGunController> x100_gunController;
|
2016-12-10 02:35:20 +00:00
|
|
|
TToken<CAnimCharacterSet> x104_gunCharacter;
|
2017-09-05 03:00:19 +00:00
|
|
|
std::vector<CToken> x10c_anims;
|
|
|
|
std::vector<CToken> x12c_deps;
|
2016-12-10 02:35:20 +00:00
|
|
|
TToken<CAnimCharacterSet> x13c_armCharacter;
|
2017-07-23 23:45:04 +00:00
|
|
|
rstl::reserved_vector<TCachedToken<CWeaponDescription>, 2> x144_weapons;
|
2017-09-02 04:06:05 +00:00
|
|
|
TCachedToken<CGenDescription> x160_xferEffect;
|
2017-07-23 23:45:04 +00:00
|
|
|
rstl::reserved_vector<TCachedToken<CGenDescription>, 2> x16c_muzzleEffects;
|
2017-09-05 03:00:19 +00:00
|
|
|
rstl::reserved_vector<TCachedToken<CGenDescription>, 2> x188_frozenEffects;
|
2017-08-25 06:18:09 +00:00
|
|
|
rstl::reserved_vector<std::unique_ptr<CElementGen>, 2> x1a4_muzzleGenerators;
|
2017-09-05 03:00:19 +00:00
|
|
|
std::unique_ptr<CElementGen> x1b8_frozenGenerator;
|
2017-08-25 06:18:09 +00:00
|
|
|
CRainSplashGenerator* x1bc_rainSplashGenerator = nullptr;
|
2016-12-10 02:35:20 +00:00
|
|
|
EWeaponType x1c0_weaponType;
|
2017-08-22 03:20:22 +00:00
|
|
|
TUniqueId x1c4_playerId;
|
|
|
|
EMaterialTypes x1c8_playerMaterial;
|
2017-09-07 03:55:31 +00:00
|
|
|
ESecondaryFxType x1cc_enabledSecondaryEffect = ESecondaryFxType::None;
|
2017-07-23 23:45:04 +00:00
|
|
|
CVelocityInfo x1d0_velInfo;
|
2016-12-10 02:35:20 +00:00
|
|
|
CPlayerState::EBeamId x200_beamId;
|
2017-09-05 03:00:19 +00:00
|
|
|
EFrozenFxType x204_frozenEffect = EFrozenFxType::None;
|
|
|
|
u32 x208_muzzleEffectIdx = 0;
|
|
|
|
u32 x20c_shaderIdx;
|
2018-01-14 06:44:22 +00:00
|
|
|
// 0x1: load request, 0x2: muzzle fx, 0x4: projectile data, 0x8: anims, 0x10: everything else
|
|
|
|
u32 x210_loadFlags = 0;
|
2017-08-26 04:36:25 +00:00
|
|
|
CAssetId x214_ancsId;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
bool x218_24 : 1;
|
2017-09-02 04:06:05 +00:00
|
|
|
bool x218_25_enableCharge : 1;
|
2017-09-05 03:00:19 +00:00
|
|
|
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;
|
2017-08-26 04:36:25 +00:00
|
|
|
};
|
|
|
|
u32 _dummy = 0;
|
|
|
|
};
|
|
|
|
|
2017-09-05 03:00:19 +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();
|
|
|
|
|
|
|
|
static void PointGenerator(void* ctx, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn);
|
|
|
|
|
2016-12-10 02:35:20 +00:00
|
|
|
public:
|
2017-09-05 03:00:19 +00:00
|
|
|
CGunWeapon(CAssetId ancsId, EWeaponType type, TUniqueId playerId, EMaterialTypes playerMaterial,
|
|
|
|
const zeus::CVector3f& scale);
|
2016-08-15 01:19:04 +00:00
|
|
|
void AsyncLoadSuitArm(CStateManager& mgr);
|
2017-09-05 03:00:19 +00:00
|
|
|
virtual void Reset(CStateManager& mgr);
|
2017-09-02 04:06:05 +00:00
|
|
|
virtual void PlayAnim(NWeaponTypes::EGunAnimType type, bool loop);
|
2017-09-05 03:00:19 +00:00
|
|
|
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);
|
2017-08-27 03:02:18 +00:00
|
|
|
virtual void Fire(bool underwater, float dt, EChargeState chargeState, const zeus::CTransform& xf,
|
2017-09-05 03:00:19 +00:00
|
|
|
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);
|
2017-08-25 06:18:09 +00:00
|
|
|
void Touch(const CStateManager& mgr);
|
|
|
|
void TouchHolo(const CStateManager& mgr);
|
2017-09-05 03:00:19 +00:00
|
|
|
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;
|
2017-08-31 02:42:37 +00:00
|
|
|
void DrawHologram(const CStateManager& mgr, const zeus::CTransform& xf, const CModelFlags& flags) const;
|
2017-08-26 04:36:25 +00:00
|
|
|
void UpdateMuzzleFx(float dt, const zeus::CVector3f& scale, const zeus::CVector3f& pos, bool emitting);
|
2017-07-23 23:45:04 +00:00
|
|
|
const CVelocityInfo& GetVelocityInfo() const { return x1d0_velInfo; }
|
2017-08-25 06:18:09 +00:00
|
|
|
void SetRainSplashGenerator(CRainSplashGenerator* g) { x1bc_rainSplashGenerator = g; }
|
|
|
|
CElementGen* GetChargeMuzzleFx() const { return x1a4_muzzleGenerators[1].get(); }
|
2017-09-02 04:06:05 +00:00
|
|
|
const TToken<CGenDescription>& GetComboXferDescr() const { return x160_xferEffect; }
|
2017-09-05 03:00:19 +00:00
|
|
|
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);
|
2017-08-31 02:42:37 +00:00
|
|
|
bool HasSolidModelData() const { return x10_solidModelData.operator bool(); }
|
2017-08-26 04:36:25 +00:00
|
|
|
CModelData& GetSolidModelData() { return *x10_solidModelData; }
|
|
|
|
const SWeaponInfo& GetWeaponInfo() const;
|
2017-09-05 03:00:19 +00:00
|
|
|
CDamageInfo GetDamageInfo(CStateManager& mgr, EChargeState chargeState, float chargeFactor) const;
|
2017-09-02 04:06:05 +00:00
|
|
|
EWeaponType GetWeaponType() const { return x1c0_weaponType; }
|
2017-08-26 04:36:25 +00:00
|
|
|
zeus::CAABox GetBounds() const;
|
2017-08-31 02:42:37 +00:00
|
|
|
zeus::CAABox GetBounds(const zeus::CTransform& xf) const;
|
2017-09-02 04:06:05 +00:00
|
|
|
bool ComboFireOver() const { return x100_gunController->IsComboOver(); }
|
|
|
|
bool IsChargeAnimOver() const;
|
2017-09-05 03:00:19 +00:00
|
|
|
void SetDrawHologram(bool d) { x218_29_drawHologram = d; }
|
2017-09-02 04:06:05 +00:00
|
|
|
void EnableCharge(bool c) { x218_25_enableCharge = c; }
|
2017-09-10 00:36:21 +00:00
|
|
|
|
|
|
|
static CDamageInfo GetShotDamageInfo(const SShotParam& shotParam, CStateManager& mgr);
|
2016-12-10 02:35:20 +00:00
|
|
|
};
|
2016-08-14 21:11:44 +00:00
|
|
|
}
|
|
|
|
|