diff --git a/include/MetroidPrime/CAnimData.hpp b/include/MetroidPrime/CAnimData.hpp index 93e89c48..cf359ba0 100644 --- a/include/MetroidPrime/CAnimData.hpp +++ b/include/MetroidPrime/CAnimData.hpp @@ -122,7 +122,7 @@ public: // SetPoseValid__9CAnimDataFb s16 GetDefaultAnimation() const { return x208_defaultAnim; } - // GetCharacterInfo__9CAnimDataCFv + const CCharacterInfo& GetCharacterInfo() const { return xc_charInfo; } // GetCharLayoutInfo__9CAnimDataCFv // GetDeltaRotation__9CAnimDataCFv // GetDeltaOffset__9CAnimDataCFv diff --git a/include/MetroidPrime/CCharacterInfo.hpp b/include/MetroidPrime/CCharacterInfo.hpp index 4a6da7ab..97de8de6 100644 --- a/include/MetroidPrime/CCharacterInfo.hpp +++ b/include/MetroidPrime/CCharacterInfo.hpp @@ -22,6 +22,8 @@ public: rstl::vector< CAssetId > x20_elsc; rstl::vector< CAssetId > x30_elsc; }; + + const CPASDatabase& GetPASDatabase() const { return x30_pasDatabase; } private: u16 x0_tableCount; diff --git a/include/MetroidPrime/CPASAnimState.hpp b/include/MetroidPrime/CPASAnimState.hpp index 4ed4a0ca..4ccb43ab 100644 --- a/include/MetroidPrime/CPASAnimState.hpp +++ b/include/MetroidPrime/CPASAnimState.hpp @@ -4,6 +4,7 @@ #include "types.h" #include "rstl/vector.hpp" +#include "rstl/reserved_vector.hpp" namespace pas { enum EAnimationState { diff --git a/include/MetroidPrime/CPASDatabase.hpp b/include/MetroidPrime/CPASDatabase.hpp index 5c9328f2..a0391a32 100644 --- a/include/MetroidPrime/CPASDatabase.hpp +++ b/include/MetroidPrime/CPASDatabase.hpp @@ -6,11 +6,18 @@ #include "MetroidPrime/CPASAnimState.hpp" #include "rstl/vector.hpp" +#include "rstl/pair.hpp" + +class CPASAnimParmData; +class CRandom16; class CPASDatabase { private: rstl::vector< CPASAnimState > x0_states; int x10_defaultState; + +public: + rstl::pair FindBestAnimation(const CPASAnimParmData&, CRandom16&, int) const; }; CHECK_SIZEOF(CPASDatabase, 0x14) diff --git a/include/MetroidPrime/Weapons/GunController/CGunController.hpp b/include/MetroidPrime/Weapons/GunController/CGunController.hpp index d8350c95..13017f22 100644 --- a/include/MetroidPrime/Weapons/GunController/CGunController.hpp +++ b/include/MetroidPrime/Weapons/GunController/CGunController.hpp @@ -31,6 +31,7 @@ class CGunController { public: explicit CGunController(CModelData& modelData); + ~CGunController(); void EnterFreeLook(CStateManager&, int, int); void EnterComboFire(CStateManager&, int); @@ -43,5 +44,6 @@ public: void Reset(); void ReturnToBasePosition(CStateManager&); }; +CHECK_SIZEOF(CGunController, 0x5C) #endif // _CGUNCONTROLLER_HPP diff --git a/include/MetroidPrime/Weapons/GunController/CGunMotion.hpp b/include/MetroidPrime/Weapons/GunController/CGunMotion.hpp index 1ee24cf9..90fcf372 100644 --- a/include/MetroidPrime/Weapons/GunController/CGunMotion.hpp +++ b/include/MetroidPrime/Weapons/GunController/CGunMotion.hpp @@ -2,6 +2,7 @@ #define _CGUNMOTION_HPP #include "MetroidPrime/CModelData.hpp" +#include "MetroidPrime/Weapons/GunController/CGunController.hpp" #include "Kyoto/CToken.hpp" #include "Kyoto/CObjectReference.hpp" @@ -34,8 +35,13 @@ public: ~CGunMotion(); bool PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr, float angle, bool bigStrike); + void Update(float, CStateManager&); + void Draw(const CStateManager&, const CTransform4f&) const; + void ReturnToDefault(CStateManager& mgr); + void GetFreeLookSetId() const; void BasePosition(bool bigStrikeReset); - void ReturnToDefault(CStateManager& mgr, bool setState); + void EnterFidget(CStateManager&, SamusGun::EFidgetType, int); + void LoadAnimations(); CModelData& GetModelData() { return x0_modelData; } const CModelData& GetModelData() const { return x0_modelData; } @@ -43,7 +49,7 @@ public: private: CModelData x0_modelData; - u8 x4c_pad[0x5C]; + CGunController x4c_gunController; rstl::vector xa8_anims; bool xb8_24_animPlaying : 1; }; diff --git a/src/MetroidPrime/Player/CPlayerGun.cpp b/src/MetroidPrime/Player/CPlayerGun.cpp index ae457b08..06c88114 100644 --- a/src/MetroidPrime/Player/CPlayerGun.cpp +++ b/src/MetroidPrime/Player/CPlayerGun.cpp @@ -817,7 +817,7 @@ void CPlayerGun::UpdateGunIdle(bool inStrikeCooldown, float camBobT, float dt, C } else { if (x833_31_inFreeLook) { if ((x2f8_stateFlags & 0x10) != 0x10) { - x73c_gunMotion->ReturnToDefault(mgr, x834_30_inBigStrike); + x73c_gunMotion->ReturnToDefault(mgr); x740_grappleArm->ReturnToDefault(mgr, 0.f, false); } x833_31_inFreeLook = false; diff --git a/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp b/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp index 5ed460e6..d8bdf9ae 100644 --- a/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp +++ b/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp @@ -1 +1,77 @@ #include "MetroidPrime/Weapons/GunController/CGunMotion.hpp" + +#include "MetroidPrime/CAnimRes.hpp" +#include "MetroidPrime/CAnimData.hpp" +#include "MetroidPrime/CPASDatabase.hpp" +#include "MetroidPrime/CStateManager.hpp" + +CGunMotion::CGunMotion(CAssetId ancsId, const CVector3f& scale) +: x0_modelData(CAnimRes(ancsId, 0, scale, 0, false)) +, x4c_gunController(x0_modelData) +, xb8_24_animPlaying(false) { + LoadAnimations(); +} +CGunMotion::~CGunMotion() {} + +bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr, float angle, + bool bigStrike) { + const CPASDatabase& pas = x0_modelData.GetAnimationData()->GetCharacterInfo().GetPASDatabase(); + + s32 animId = -1; + bool loop = true; + switch (state) { + case SamusGun::kAS_Wander: { + CPASAnimParmData* parms; //((pas::EAnimationState(state))); + rstl::pair anim = pas.FindBestAnimation(*parms, *mgr.GetActiveRandom(), -1); + animId = anim.second; + break; + } + case SamusGun::kAS_Idle: { + CPASAnimParmData* parms; //(pas::EAnimationState(state), CPASAnimParm::FromEnum(0)); + rstl::pair anim = pas.FindBestAnimation(*parms, *mgr.GetActiveRandom(), -1); + animId = anim.second; + break; + } + case SamusGun::kAS_Struck: { + CPASAnimParmData* parms; /*(pas::EAnimationState(state), CPASAnimParm::FromInt32(0), + CPASAnimParm::FromReal32(angle), CPASAnimParm::FromBool(bigStrike), + CPASAnimParm::FromBool(false));*/ + rstl::pair anim = pas.FindBestAnimation(*parms, *mgr.GetActiveRandom(), -1); + animId = anim.second; + loop = false; + break; + } + case SamusGun::kAS_FreeLook: + x4c_gunController.EnterFreeLook(mgr, 0, -1); + break; + case SamusGun::kAS_ComboFire: + x4c_gunController.EnterComboFire(mgr, 0); + break; + default: + break; + } + + if (animId != -1) { + x0_modelData.AnimationData()->EnableLooping(loop); + CAnimPlaybackParms aparms(animId, -1, 1.f, true); + x0_modelData.AnimationData()->SetAnimation(aparms, false); + } + + return loop; +} + +void CGunMotion::Update(float, CStateManager&) {} + +void CGunMotion::Draw(const CStateManager&, const CTransform4f&) const {} + +void CGunMotion::ReturnToDefault(CStateManager& mgr) { + x4c_gunController.ReturnToDefault(mgr, 0.f); +} + +void CGunMotion::GetFreeLookSetId() const {} + +void CGunMotion::BasePosition(bool bigStrikeReset) {} + +void CGunMotion::EnterFidget(CStateManager&, SamusGun::EFidgetType, int) {} + +void CGunMotion::LoadAnimations() {}