metaforce/Runtime/Weapon/CGSFidget.cpp

52 lines
1.7 KiB
C++
Raw Normal View History

#include "CGSFidget.hpp"
2017-08-26 04:36:25 +00:00
#include "WeaponCommon.hpp"
#include "Character/CPASAnimParmData.hpp"
#include "Character/CAnimData.hpp"
#include "CStateManager.hpp"
namespace urde
{
2017-08-26 04:36:25 +00:00
bool CGSFidget::Update(CAnimData& data, float dt, CStateManager& mgr)
{
2017-08-26 04:36:25 +00:00
return !data.IsAnimTimeRemaining(0.001f, "Whole Body");
}
2017-09-04 02:22:46 +00:00
s32 CGSFidget::SetAnim(CAnimData& data, s32 type, s32 gunId, s32 animSet, CStateManager& mgr)
2017-08-26 04:36:25 +00:00
{
const CPASDatabase& pas = data.GetCharacterInfo().GetPASDatabase();
CPASAnimParmData parms(1, CPASAnimParm::FromEnum(type), CPASAnimParm::FromInt32(gunId),
2017-09-04 02:22:46 +00:00
CPASAnimParm::FromInt32(animSet));
2017-08-26 04:36:25 +00:00
auto anim = pas.FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
bool loop = pas.GetAnimState(1)->GetAnimParmData(anim.second, 3).GetBoolValue();
x14_gunId = gunId;
2017-09-04 02:22:46 +00:00
x18_animSet = animSet;
2017-08-26 04:36:25 +00:00
if (anim.second != -1)
{
data.EnableLooping(loop);
CAnimPlaybackParms aParms(anim.second, -1, 1.f, true);
data.SetAnimation(aParms, false);
UnLoadAnim();
}
return anim.second;
}
2017-09-04 02:22:46 +00:00
void CGSFidget::LoadAnimAsync(CAnimData& data, s32 type, s32 gunId, s32 animSet, CStateManager& mgr)
2017-08-26 04:36:25 +00:00
{
CPASAnimParmData parms(1, CPASAnimParm::FromEnum(type), CPASAnimParm::FromInt32(gunId),
2017-09-04 02:22:46 +00:00
CPASAnimParm::FromInt32(animSet));
2017-08-26 04:36:25 +00:00
auto anim = data.GetCharacterInfo().GetPASDatabase().FindBestAnimation(parms, *mgr.GetActiveRandom(), -1);
if (anim.second != -1)
NWeaponTypes::get_token_vector(data, anim.second, x0_anims, true);
}
void CGSFidget::UnLoadAnim()
{
x0_anims.clear();
}
bool CGSFidget::IsAnimLoaded() const
{
return NWeaponTypes::are_tokens_ready(x0_anims);
}
}