diff --git a/include/MetroidPrime/Weapons/GunController/CGSFreeLook.hpp b/include/MetroidPrime/Weapons/GunController/CGSFreeLook.hpp new file mode 100644 index 00000000..b220ea15 --- /dev/null +++ b/include/MetroidPrime/Weapons/GunController/CGSFreeLook.hpp @@ -0,0 +1,30 @@ +#ifndef _CGSFREELOOK_HPP +#define _CGSFREELOOK_HPP + +#include "types.h" + +class CAnimData; +class CStateManager; + +class CGSFreeLook { + float x0_delay; + int x4_cueAnimId; + int x8_loopState; // In, loop, out + int xc_gunId; + int x10_setId; + bool x14_idle; + +public: + CGSFreeLook(); + + int GetSetId() const { return x10_setId; } + void SetLoopState(int l) { x8_loopState = l; } + int GetLoopState() const { return x8_loopState; } + void SetIdle(bool l) { x14_idle = l; } + int GetGunId() const { return xc_gunId; } + bool Update(CAnimData& data, float dt, CStateManager& mgr); + int SetAnim(CAnimData& data, int gunId, int setId, int loopState, CStateManager& mgr, float delay); +}; +CHECK_SIZEOF(CGSFreeLook, 0x18) + +#endif // _CGSFREELOOK_HPP diff --git a/include/MetroidPrime/Weapons/GunController/CGunController.hpp b/include/MetroidPrime/Weapons/GunController/CGunController.hpp index 97d71646..13b07dc3 100644 --- a/include/MetroidPrime/Weapons/GunController/CGunController.hpp +++ b/include/MetroidPrime/Weapons/GunController/CGunController.hpp @@ -3,6 +3,8 @@ #include "types.h" +#include "MetroidPrime/Weapons/GunController/CGSFreeLook.hpp" + class CModelData; enum EGunState { @@ -20,10 +22,10 @@ class CStateManager; class CGunController { CModelData& x0_modelData; - // CGSFreeLook x4_freeLook; + CGSFreeLook x4_freeLook; // CGSComboFire x1c_comboFire; // CGSFidget x30_fidget; - u8 x4_pad[0x4C]; + u8 x1c_pad[0x34]; EGunState x50_gunState; int x54_curAnimId; bool x58_24_animDone : 1; @@ -43,6 +45,9 @@ public: void ReturnToDefault(CStateManager&, float); void Reset(); void ReturnToBasePosition(CStateManager&); + + int GetFreeLookSetId() const { return x4_freeLook.GetSetId(); } + }; CHECK_SIZEOF(CGunController, 0x5C) diff --git a/include/MetroidPrime/Weapons/GunController/CGunMotion.hpp b/include/MetroidPrime/Weapons/GunController/CGunMotion.hpp index 90fcf372..d11c225a 100644 --- a/include/MetroidPrime/Weapons/GunController/CGunMotion.hpp +++ b/include/MetroidPrime/Weapons/GunController/CGunMotion.hpp @@ -38,7 +38,7 @@ public: void Update(float, CStateManager&); void Draw(const CStateManager&, const CTransform4f&) const; void ReturnToDefault(CStateManager& mgr); - void GetFreeLookSetId() const; + int GetFreeLookSetId() const; void BasePosition(bool bigStrikeReset); void EnterFidget(CStateManager&, SamusGun::EFidgetType, int); void LoadAnimations(); diff --git a/src/MetroidPrime/Weapons/GunController/CGSFreeLook.cpp b/src/MetroidPrime/Weapons/GunController/CGSFreeLook.cpp new file mode 100644 index 00000000..6883453c --- /dev/null +++ b/src/MetroidPrime/Weapons/GunController/CGSFreeLook.cpp @@ -0,0 +1,4 @@ +#include "MetroidPrime/Weapons/GunController/CGSFreeLook.hpp" + +CGSFreeLook::CGSFreeLook() +: x0_delay(0.f), x4_cueAnimId(-1), x8_loopState(-1), xc_gunId(0), x10_setId(-1), x14_idle(false) {} diff --git a/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp b/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp index e1de1934..ed2fed08 100644 --- a/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp +++ b/src/MetroidPrime/Weapons/GunController/CGunMotion.cpp @@ -1,12 +1,12 @@ #include "MetroidPrime/Weapons/GunController/CGunMotion.hpp" -#include "MetroidPrime/CAnimRes.hpp" #include "MetroidPrime/CAnimData.hpp" +#include "MetroidPrime/CAnimRes.hpp" #include "MetroidPrime/CStateManager.hpp" -#include "Kyoto/Animation/CPASDatabase.hpp" #include "Kyoto/Animation/CPASAnimParmData.hpp" - +#include "Kyoto/Animation/CPASDatabase.hpp" +#include "Kyoto/Graphics/CModelFlags.hpp" CGunMotion::CGunMotion(CAssetId ancsId, const CVector3f& scale) : x0_modelData(CAnimRes(ancsId, 0, scale, 0, false)) @@ -25,13 +25,13 @@ bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr switch (state) { case SamusGun::kAS_Wander: { CPASAnimParmData parms((pas::EAnimationState(state))); - rstl::pair anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1); + rstl::pair< float, int > 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); + rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1); animId = anim.second; break; } @@ -39,7 +39,7 @@ bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr 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); + rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1); animId = anim.second; loop = false; break; @@ -66,18 +66,22 @@ bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr void CGunMotion::Update(float dt, CStateManager& mgr) { x0_modelData.AdvanceAnimation(dt, mgr, kInvalidAreaId, true); switch (x4c_gunController.Update(dt, mgr)) { - case 1: - xb8_24_animPlaying = false; - } + case 1: + xb8_24_animPlaying = false; + } } -void CGunMotion::Draw(const CStateManager&, const CTransform4f&) const {} +void CGunMotion::Draw(const CStateManager& mgr, const CTransform4f& xf) const { + x0_modelData.Render(mgr, xf, nullptr, CModelFlags::Normal()); +} void CGunMotion::ReturnToDefault(CStateManager& mgr) { x4c_gunController.ReturnToDefault(mgr, 0.f); } -void CGunMotion::GetFreeLookSetId() const {} +int CGunMotion::GetFreeLookSetId() const { + return x4c_gunController.GetFreeLookSetId(); +} void CGunMotion::BasePosition(bool bigStrikeReset) {}