2019-12-22 20:04:07 +00:00
|
|
|
#include "Runtime/Weapon/CGunMotion.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/CStateManager.hpp"
|
|
|
|
#include "Runtime/Character/CPASAnimParmData.hpp"
|
|
|
|
#include "Runtime/Weapon/WeaponCommon.hpp"
|
2017-08-21 05:46:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2017-08-21 05:46:59 +00:00
|
|
|
|
2017-08-26 04:36:25 +00:00
|
|
|
CGunMotion::CGunMotion(CAssetId ancsId, const zeus::CVector3f& scale)
|
2018-12-08 05:30:43 +00:00
|
|
|
: x0_modelData(CAnimRes(ancsId, 0, scale, 0, false), 1), x4c_gunController(x0_modelData) {
|
|
|
|
LoadAnimations();
|
2017-08-26 04:36:25 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGunMotion::LoadAnimations() {
|
2019-08-14 14:58:54 +00:00
|
|
|
NWeaponTypes::get_token_vector(*x0_modelData.GetAnimationData(), 0, 14, xa8_anims, true);
|
2017-08-26 04:36:25 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CGunMotion::PlayPasAnim(SamusGun::EAnimationState state, CStateManager& mgr, float angle, bool bigStrike) {
|
|
|
|
const CPASDatabase& pas = x0_modelData.GetAnimationData()->GetCharacterInfo().GetPASDatabase();
|
2017-08-26 04:36:25 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
s32 animId = -1;
|
|
|
|
bool loop = true;
|
|
|
|
switch (state) {
|
|
|
|
case SamusGun::EAnimationState::Wander: {
|
|
|
|
CPASAnimParmData parms((s32(state)));
|
|
|
|
auto anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
|
|
|
|
animId = anim.second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SamusGun::EAnimationState::Idle: {
|
|
|
|
CPASAnimParmData parms(s32(state), CPASAnimParm::FromEnum(0));
|
|
|
|
auto anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
|
|
|
|
animId = anim.second;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SamusGun::EAnimationState::Struck: {
|
|
|
|
CPASAnimParmData parms(s32(state), CPASAnimParm::FromInt32(0), CPASAnimParm::FromReal32(angle),
|
|
|
|
CPASAnimParm::FromBool(bigStrike), CPASAnimParm::FromBool(false));
|
|
|
|
auto anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
|
|
|
|
animId = anim.second;
|
|
|
|
loop = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SamusGun::EAnimationState::FreeLook:
|
|
|
|
x4c_gunController.EnterFreeLook(mgr, 0, -1);
|
|
|
|
break;
|
|
|
|
case SamusGun::EAnimationState::ComboFire:
|
|
|
|
x4c_gunController.EnterComboFire(mgr, 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-08-26 04:36:25 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (animId != -1) {
|
2019-08-14 14:58:54 +00:00
|
|
|
x0_modelData.GetAnimationData()->EnableLooping(loop);
|
2018-12-08 05:30:43 +00:00
|
|
|
CAnimPlaybackParms aparms(animId, -1, 1.f, true);
|
2019-08-14 14:58:54 +00:00
|
|
|
x0_modelData.GetAnimationData()->SetAnimation(aparms, false);
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-08-21 05:46:59 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
return loop;
|
2017-08-21 05:46:59 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGunMotion::ReturnToDefault(CStateManager& mgr, bool setState) {
|
|
|
|
x4c_gunController.ReturnToDefault(mgr, 0.f, setState);
|
2017-08-26 04:36:25 +00:00
|
|
|
}
|
2017-08-25 06:18:09 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGunMotion::BasePosition(bool bigStrikeReset) {
|
2019-08-14 14:58:54 +00:00
|
|
|
x0_modelData.GetAnimationData()->EnableLooping(false);
|
2018-12-08 05:30:43 +00:00
|
|
|
CAnimPlaybackParms aparms(bigStrikeReset ? 6 : 0, -1, 1.f, true);
|
2019-08-14 14:58:54 +00:00
|
|
|
x0_modelData.GetAnimationData()->SetAnimation(aparms, false);
|
2017-08-26 04:36:25 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGunMotion::EnterFidget(CStateManager& mgr, SamusGun::EFidgetType type, s32 parm2) {
|
|
|
|
xb8_24_animPlaying = true;
|
|
|
|
x4c_gunController.EnterFidget(mgr, s32(type), 0, parm2);
|
2017-08-26 04:36:25 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CGunMotion::Update(float dt, CStateManager& mgr) {
|
|
|
|
x0_modelData.AdvanceAnimation(dt, mgr, kInvalidAreaId, true);
|
|
|
|
if (x4c_gunController.Update(dt, mgr))
|
|
|
|
xb8_24_animPlaying = false;
|
2017-08-26 04:36:25 +00:00
|
|
|
}
|
|
|
|
|
2020-08-02 03:45:47 +00:00
|
|
|
void CGunMotion::Draw(const CStateManager& mgr, const zeus::CTransform& xf) {
|
2020-04-11 20:53:59 +00:00
|
|
|
constexpr CModelFlags flags(0, 0, 3, zeus::skWhite);
|
2018-12-08 05:30:43 +00:00
|
|
|
x0_modelData.Render(mgr, xf, nullptr, flags);
|
2017-08-25 06:18:09 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|