Match CGunMotion::Draw/GetFreeLookSetId

Former-commit-id: 77ad228fdb
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-07 02:28:42 +03:00
parent 02fc116666
commit f4b3f5b872
5 changed files with 57 additions and 14 deletions

View File

@ -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

View File

@ -3,6 +3,8 @@
#include "types.h" #include "types.h"
#include "MetroidPrime/Weapons/GunController/CGSFreeLook.hpp"
class CModelData; class CModelData;
enum EGunState { enum EGunState {
@ -20,10 +22,10 @@ class CStateManager;
class CGunController { class CGunController {
CModelData& x0_modelData; CModelData& x0_modelData;
// CGSFreeLook x4_freeLook; CGSFreeLook x4_freeLook;
// CGSComboFire x1c_comboFire; // CGSComboFire x1c_comboFire;
// CGSFidget x30_fidget; // CGSFidget x30_fidget;
u8 x4_pad[0x4C]; u8 x1c_pad[0x34];
EGunState x50_gunState; EGunState x50_gunState;
int x54_curAnimId; int x54_curAnimId;
bool x58_24_animDone : 1; bool x58_24_animDone : 1;
@ -43,6 +45,9 @@ public:
void ReturnToDefault(CStateManager&, float); void ReturnToDefault(CStateManager&, float);
void Reset(); void Reset();
void ReturnToBasePosition(CStateManager&); void ReturnToBasePosition(CStateManager&);
int GetFreeLookSetId() const { return x4_freeLook.GetSetId(); }
}; };
CHECK_SIZEOF(CGunController, 0x5C) CHECK_SIZEOF(CGunController, 0x5C)

View File

@ -38,7 +38,7 @@ public:
void Update(float, CStateManager&); void Update(float, CStateManager&);
void Draw(const CStateManager&, const CTransform4f&) const; void Draw(const CStateManager&, const CTransform4f&) const;
void ReturnToDefault(CStateManager& mgr); void ReturnToDefault(CStateManager& mgr);
void GetFreeLookSetId() const; int GetFreeLookSetId() const;
void BasePosition(bool bigStrikeReset); void BasePosition(bool bigStrikeReset);
void EnterFidget(CStateManager&, SamusGun::EFidgetType, int); void EnterFidget(CStateManager&, SamusGun::EFidgetType, int);
void LoadAnimations(); void LoadAnimations();

View File

@ -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) {}

View File

@ -1,12 +1,12 @@
#include "MetroidPrime/Weapons/GunController/CGunMotion.hpp" #include "MetroidPrime/Weapons/GunController/CGunMotion.hpp"
#include "MetroidPrime/CAnimRes.hpp"
#include "MetroidPrime/CAnimData.hpp" #include "MetroidPrime/CAnimData.hpp"
#include "MetroidPrime/CAnimRes.hpp"
#include "MetroidPrime/CStateManager.hpp" #include "MetroidPrime/CStateManager.hpp"
#include "Kyoto/Animation/CPASDatabase.hpp"
#include "Kyoto/Animation/CPASAnimParmData.hpp" #include "Kyoto/Animation/CPASAnimParmData.hpp"
#include "Kyoto/Animation/CPASDatabase.hpp"
#include "Kyoto/Graphics/CModelFlags.hpp"
CGunMotion::CGunMotion(CAssetId ancsId, const CVector3f& scale) CGunMotion::CGunMotion(CAssetId ancsId, const CVector3f& scale)
: x0_modelData(CAnimRes(ancsId, 0, scale, 0, false)) : x0_modelData(CAnimRes(ancsId, 0, scale, 0, false))
@ -25,13 +25,13 @@ bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr
switch (state) { switch (state) {
case SamusGun::kAS_Wander: { case SamusGun::kAS_Wander: {
CPASAnimParmData parms((pas::EAnimationState(state))); CPASAnimParmData parms((pas::EAnimationState(state)));
rstl::pair<float, int> anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1); rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
animId = anim.second; animId = anim.second;
break; break;
} }
case SamusGun::kAS_Idle: { case SamusGun::kAS_Idle: {
CPASAnimParmData parms(pas::EAnimationState(state), CPASAnimParm::FromEnum(0)); CPASAnimParmData parms(pas::EAnimationState(state), CPASAnimParm::FromEnum(0));
rstl::pair<float, int> anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1); rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
animId = anim.second; animId = anim.second;
break; break;
} }
@ -39,7 +39,7 @@ bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr
CPASAnimParmData parms(pas::EAnimationState(state), CPASAnimParm::FromInt32(0), CPASAnimParmData parms(pas::EAnimationState(state), CPASAnimParm::FromInt32(0),
CPASAnimParm::FromReal32(angle), CPASAnimParm::FromBool(bigStrike), CPASAnimParm::FromReal32(angle), CPASAnimParm::FromBool(bigStrike),
CPASAnimParm::FromBool(false)); CPASAnimParm::FromBool(false));
rstl::pair<float, int> anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1); rstl::pair< float, int > anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
animId = anim.second; animId = anim.second;
loop = false; loop = false;
break; break;
@ -66,18 +66,22 @@ bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr
void CGunMotion::Update(float dt, CStateManager& mgr) { void CGunMotion::Update(float dt, CStateManager& mgr) {
x0_modelData.AdvanceAnimation(dt, mgr, kInvalidAreaId, true); x0_modelData.AdvanceAnimation(dt, mgr, kInvalidAreaId, true);
switch (x4c_gunController.Update(dt, mgr)) { switch (x4c_gunController.Update(dt, mgr)) {
case 1: case 1:
xb8_24_animPlaying = false; 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) { void CGunMotion::ReturnToDefault(CStateManager& mgr) {
x4c_gunController.ReturnToDefault(mgr, 0.f); x4c_gunController.ReturnToDefault(mgr, 0.f);
} }
void CGunMotion::GetFreeLookSetId() const {} int CGunMotion::GetFreeLookSetId() const {
return x4c_gunController.GetFreeLookSetId();
}
void CGunMotion::BasePosition(bool bigStrikeReset) {} void CGunMotion::BasePosition(bool bigStrikeReset) {}