Things for CGunMotion

Former-commit-id: b4e3361020
This commit is contained in:
Henrique Gemignani Passos Lima 2022-10-07 00:07:41 +03:00
parent 6bfb08fd07
commit 01c1b77b2e
8 changed files with 98 additions and 4 deletions

View File

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

View File

@ -23,6 +23,8 @@ public:
rstl::vector< CAssetId > x30_elsc;
};
const CPASDatabase& GetPASDatabase() const { return x30_pasDatabase; }
private:
u16 x0_tableCount;
rstl::string x4_name;

View File

@ -4,6 +4,7 @@
#include "types.h"
#include "rstl/vector.hpp"
#include "rstl/reserved_vector.hpp"
namespace pas {
enum EAnimationState {

View File

@ -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<float, int> FindBestAnimation(const CPASAnimParmData&, CRandom16&, int) const;
};
CHECK_SIZEOF(CPASDatabase, 0x14)

View File

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

View File

@ -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<CToken> xa8_anims;
bool xb8_24_animPlaying : 1;
};

View File

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

View File

@ -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<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<float, int> 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<float, int> 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() {}