metaforce/Runtime/Weapon/CGrappleArm.hpp

144 lines
5.6 KiB
C++
Raw Normal View History

2018-10-07 03:42:33 +00:00
#pragma once
#include "RetroTypes.hpp"
#include "zeus/CVector3f.hpp"
#include "Character/CModelData.hpp"
2017-09-04 02:22:46 +00:00
#include "Character/CAnimCharacterSet.hpp"
2017-08-25 06:18:09 +00:00
#include "CStateManager.hpp"
2017-08-26 04:36:25 +00:00
#include "CGunController.hpp"
#include "CGunMotion.hpp"
namespace urde
{
2017-08-31 02:42:37 +00:00
class CStateManager;
2017-09-04 02:22:46 +00:00
struct CModelFlags;
2017-08-31 02:42:37 +00:00
class CActorLights;
class CGrappleArm
{
2017-07-17 03:04:14 +00:00
public:
enum class EArmState
{
2017-09-04 02:22:46 +00:00
IntoGrapple,
IntoGrappleIdle,
FireGrapple,
2017-07-17 03:04:14 +00:00
Three,
2017-09-04 02:22:46 +00:00
ConnectGrapple,
2017-07-17 03:04:14 +00:00
Five,
2017-09-04 02:22:46 +00:00
Connected,
2017-07-17 03:04:14 +00:00
Seven,
2017-09-04 02:22:46 +00:00
OutOfGrapple,
GunControllerAnimation,
Done
2017-07-17 03:04:14 +00:00
};
private:
2017-09-04 02:22:46 +00:00
std::experimental::optional<CModelData> x0_grappleArmModel;
std::experimental::optional<CModelData> x50_grappleArmSkeletonModel;
CModelData xa0_grappleGearModel;
CModelData xec_grapNoz1Model;
CModelData x138_grapNoz2Model;
TCachedToken<CAnimCharacterSet> x184_grappleArm;
std::vector<CToken> x18c_anims;
rstl::reserved_vector<std::vector<CToken>, 8> x19c_suitDeps;
2017-07-23 23:45:04 +00:00
zeus::CTransform x220_xf;
2017-09-04 02:22:46 +00:00
zeus::CTransform x250_grapLocatorXf;
zeus::CTransform x280_grapNozLoc1Xf;
zeus::CTransform x2b0_grapNozLoc2Xf;
2017-08-31 02:42:37 +00:00
zeus::CTransform x2e0_auxXf;
2017-09-04 02:22:46 +00:00
zeus::CVector3f x310_grapplePointPos;
zeus::CVector3f x31c_scale;
2017-08-26 04:36:25 +00:00
std::unique_ptr<CGunController> x328_gunController;
2017-09-04 02:22:46 +00:00
CSfxHandle x32c_grappleLoopSfx;
CSfxHandle x330_swooshSfx;
EArmState x334_animState = EArmState::Done;
float x338_beamT = 0.f;
float x33c_beamDist = 0.f;
float x340_anglePhase = 0.f;
float x344_xAmplitude = 0.f;
float x348_zAmplitude = 0.f;
std::pair<u16, CSfxHandle> x34c_animSfx = {0xffff, {}};
TCachedToken<CGenDescription> x354_grappleSegmentDesc;
TCachedToken<CGenDescription> x360_grappleClawDesc;
TCachedToken<CGenDescription> x36c_grappleHitDesc;
TCachedToken<CGenDescription> x378_grappleMuzzleDesc;
TCachedToken<CSwooshDescription> x384_grappleSwooshDesc;
std::unique_ptr<CElementGen> x390_grappleSegmentGen;
std::unique_ptr<CElementGen> x394_grappleClawGen;
std::unique_ptr<CElementGen> x398_grappleHitGen;
std::unique_ptr<CElementGen> x39c_grappleMuzzleGen;
std::unique_ptr<CParticleSwoosh> x3a0_grappleSwooshGen;
std::unique_ptr<CRainSplashGenerator> x3a4_rainSplashGenerator;
CPlayerState::EPlayerSuit x3a8_loadedSuit = CPlayerState::EPlayerSuit::Invalid;
float x3ac_pitchBend = 0.f;
s16 x3b0_rumbleHandle = -1;
2017-07-18 06:11:37 +00:00
union
{
struct
{
2017-08-26 04:36:25 +00:00
bool x3b2_24_active : 1;
2017-07-18 06:11:37 +00:00
bool x3b2_25_beamActive : 1;
2017-09-04 02:22:46 +00:00
bool x3b2_26_grappleHit : 1;
2017-07-19 17:47:57 +00:00
bool x3b2_27_armMoving : 1;
2017-08-26 04:36:25 +00:00
bool x3b2_28_isGrappling : 1;
bool x3b2_29_suitLoading : 1;
2017-07-18 06:11:37 +00:00
};
u32 _dummy = 0;
};
2017-09-04 02:22:46 +00:00
static float g_GrappleBeamAnglePhaseDelta;
static float g_GrappleBeamXWaveAmplitude;
static float g_GrappleBeamZWaveAmplitude;
static float g_GrappleBeamSpeed;
void FillTokenVector(const std::vector<SObjectTag>& tags, std::vector<CToken>& objects);
void BuildSuitDependencyList();
void LoadAnimations();
void ResetAuxParams(bool resetGunController);
void DisconnectGrappleBeam();
void LoadSuitPoll();
void BuildXRayModel();
void DoUserAnimEvent(CStateManager& mgr, const CInt32POINode& node, EUserEventType type);
void DoUserAnimEvents(CStateManager& mgr);
void UpdateArmMovement(float dt, CStateManager& mgr);
void UpdateGrappleBeamFx(const zeus::CVector3f& beamGunPos, const zeus::CVector3f& beamAirPos, CStateManager& mgr);
bool UpdateGrappleBeam(float dt, const zeus::CTransform& beamLoc, CStateManager& mgr);
void UpdateSwingAction(float grappleSwingT, float dt, CStateManager& mgr);
void RenderXRayModel(const CStateManager& mgr, const zeus::CTransform& modelXf, const CModelFlags& flags) const;
static void PointGenerator(void* ctx, const std::vector<std::pair<zeus::CVector3f, zeus::CVector3f>>& vn);
public:
2017-09-04 02:22:46 +00:00
explicit CGrappleArm(const zeus::CVector3f& scale);
void AsyncLoadSuit(CStateManager& mgr);
2017-07-23 23:45:04 +00:00
void SetTransform(const zeus::CTransform& xf) { x220_xf = xf; }
const zeus::CTransform& GetTransform() const { return x220_xf; }
2017-08-31 02:42:37 +00:00
zeus::CTransform& AuxTransform() { return x2e0_auxXf; }
2017-07-17 03:04:14 +00:00
void SetAnimState(EArmState state);
2017-07-18 06:11:37 +00:00
EArmState GetAnimState() const { return x334_animState; }
2017-08-26 04:36:25 +00:00
bool GetActive() const { return x3b2_24_active; }
2017-07-18 06:11:37 +00:00
bool BeamActive() const { return x3b2_25_beamActive; }
2017-07-19 17:47:57 +00:00
bool IsArmMoving() const { return x3b2_27_armMoving; }
2017-08-26 04:36:25 +00:00
bool IsGrappling() const { return x3b2_28_isGrappling; }
bool IsSuitLoading() const { return x3b2_29_suitLoading; }
2017-07-18 06:11:37 +00:00
void Activate(bool);
void GrappleBeamDisconnected();
void GrappleBeamConnected();
2017-07-31 05:19:05 +00:00
void RenderGrappleBeam(const CStateManager& mgr, const zeus::CVector3f& pos);
2017-08-25 06:18:09 +00:00
void TouchModel(const CStateManager& mgr) const;
2017-08-26 04:36:25 +00:00
void Update(float grappleSwingT, float dt, CStateManager& mgr);
2017-08-31 02:42:37 +00:00
void PreRender(const CStateManager& mgr, const zeus::CFrustum& frustum, const zeus::CVector3f& camPos);
void Render(const CStateManager& mgr, const zeus::CVector3f& pos,
const CModelFlags& flags, const CActorLights* lights) const;
2017-08-25 06:18:09 +00:00
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
2017-09-04 02:22:46 +00:00
void EnterStruck(CStateManager& mgr, float angle, bool bigStrike, bool notInFreeLook);
2017-08-25 06:18:09 +00:00
void EnterIdle(CStateManager& mgr);
2017-09-04 02:22:46 +00:00
void EnterFidget(CStateManager& mgr, SamusGun::EFidgetType type, s32 gunId, s32 animSet);
void EnterFreeLook(s32 gunId, s32 setId, CStateManager& mgr);
2017-09-02 04:06:05 +00:00
void EnterComboFire(s32 gunId, CStateManager& mgr);
2017-09-04 02:22:46 +00:00
void ReturnToDefault(CStateManager& mgr, float dt, bool setState);
2017-08-26 04:36:25 +00:00
CGunController* GunController() { return x328_gunController.get(); }
};
}