2020-01-15 12:07:48 +00:00
|
|
|
#include "Runtime/Character/CBodyStateInfo.hpp"
|
|
|
|
|
|
|
|
#include "Runtime/Character/CBodyController.hpp"
|
|
|
|
#include "Runtime/World/CActor.hpp"
|
2017-07-10 04:55:51 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
namespace urde {
|
2017-07-10 04:55:51 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CBodyStateInfo::CBodyStateInfo(CActor& actor, EBodyType type) {
|
|
|
|
x34_24_changeLocoAtEndOfAnimOnly = false;
|
|
|
|
const CPASDatabase& pasDatabase = actor.GetModelData()->GetAnimationData()->GetCharacterInfo().GetPASDatabase();
|
2020-04-06 17:21:04 +00:00
|
|
|
for (size_t i = 0; i < pasDatabase.GetNumAnimStates(); ++i) {
|
2018-12-08 05:30:43 +00:00
|
|
|
const CPASAnimState* state = pasDatabase.GetAnimStateByIndex(i);
|
|
|
|
std::unique_ptr<CBodyState> bs;
|
2017-07-10 04:55:51 +00:00
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (type) {
|
|
|
|
case EBodyType::BiPedal:
|
|
|
|
bs = SetupBiPedalBodyStates(state->GetStateId(), actor);
|
|
|
|
break;
|
|
|
|
case EBodyType::Restricted:
|
|
|
|
default:
|
|
|
|
bs = SetupRestrictedBodyStates(state->GetStateId(), actor);
|
|
|
|
break;
|
|
|
|
case EBodyType::Flyer:
|
|
|
|
bs = SetupFlyerBodyStates(state->GetStateId(), actor);
|
|
|
|
break;
|
|
|
|
case EBodyType::Pitchable:
|
|
|
|
bs = SetupPitchableBodyStates(state->GetStateId(), actor);
|
|
|
|
break;
|
|
|
|
case EBodyType::WallWalker:
|
|
|
|
bs = SetupWallWalkerBodyStates(state->GetStateId(), actor);
|
|
|
|
break;
|
|
|
|
case EBodyType::NewFlyer:
|
|
|
|
bs = SetupNewFlyerBodyStates(state->GetStateId(), actor);
|
|
|
|
break;
|
|
|
|
case EBodyType::RestrictedFlyer:
|
|
|
|
bs = SetupRestrictedFlyerBodyStates(state->GetStateId(), actor);
|
|
|
|
break;
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
if (bs)
|
|
|
|
x0_stateMap[pas::EAnimationState(state->GetStateId())] = std::move(bs);
|
|
|
|
}
|
|
|
|
|
|
|
|
x1c_additiveStates.reserve(4);
|
2020-03-31 09:32:06 +00:00
|
|
|
x1c_additiveStates.emplace_back(pas::EAnimationState::AdditiveIdle, std::make_unique<CABSIdle>());
|
|
|
|
x1c_additiveStates.emplace_back(pas::EAnimationState::AdditiveAim, std::make_unique<CABSAim>());
|
|
|
|
x1c_additiveStates.emplace_back(pas::EAnimationState::AdditiveFlinch, std::make_unique<CABSFlinch>());
|
|
|
|
x1c_additiveStates.emplace_back(pas::EAnimationState::AdditiveReaction, std::make_unique<CABSReaction>());
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 09:08:02 +00:00
|
|
|
std::unique_ptr<CBodyState> CBodyStateInfo::SetupRestrictedFlyerBodyStates(pas::EAnimationState stateId, CActor& actor) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (stateId) {
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Fall:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFall>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Getup:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGetup>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LieOnGround:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLieOnGround>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Step:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSStep>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Death:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSDie>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Locomotion:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSRestrictedFlyerLocomotion>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::KnockBack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSKnockBack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::MeleeAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::ProjectileAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSProjectileAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Turn:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTurn>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopReaction:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopReaction>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::GroundHit:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGroundHit>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Generate:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGenerate>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Jump:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSJump>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Hurled:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSHurled>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Slide:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSSlide>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Taunt:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTaunt>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Scripted:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSScripted>();
|
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 09:08:02 +00:00
|
|
|
std::unique_ptr<CBodyState> CBodyStateInfo::SetupNewFlyerBodyStates(pas::EAnimationState stateId, CActor& actor) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (stateId) {
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Fall:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFall>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Getup:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGetup>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LieOnGround:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLieOnGround>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Step:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSStep>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Death:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSDie>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Locomotion:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSNewFlyerLocomotion>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::KnockBack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSKnockBack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::MeleeAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::ProjectileAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSProjectileAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Turn:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTurn>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopReaction:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopReaction>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::GroundHit:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGroundHit>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Generate:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGenerate>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Jump:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSJump>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Hurled:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSHurled>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Slide:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSSlide>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Taunt:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTaunt>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Scripted:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSScripted>();
|
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 09:08:02 +00:00
|
|
|
std::unique_ptr<CBodyState> CBodyStateInfo::SetupWallWalkerBodyStates(pas::EAnimationState stateId, CActor& actor) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (stateId) {
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Fall:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFall>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Getup:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGetup>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LieOnGround:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLieOnGround>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Step:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSStep>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Death:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSDie>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Locomotion:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSWallWalkerLocomotion>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::KnockBack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSKnockBack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::MeleeAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::ProjectileAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSProjectileAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Turn:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFlyerTurn>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopReaction:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopReaction>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::GroundHit:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGroundHit>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Generate:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGenerate>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Jump:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSJump>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Hurled:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSHurled>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Slide:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSSlide>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Taunt:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTaunt>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Scripted:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSScripted>();
|
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 09:08:02 +00:00
|
|
|
std::unique_ptr<CBodyState> CBodyStateInfo::SetupPitchableBodyStates(pas::EAnimationState stateId, CActor& actor) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (stateId) {
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Fall:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFall>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Getup:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGetup>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LieOnGround:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLieOnGround>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Step:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSStep>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Death:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSDie>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Locomotion:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFlyerLocomotion>(actor, true);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::KnockBack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSKnockBack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::MeleeAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::ProjectileAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSProjectileAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Turn:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFlyerTurn>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopReaction:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopReaction>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::GroundHit:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGroundHit>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Generate:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGenerate>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Jump:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSJump>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Hurled:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSHurled>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Slide:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSSlide>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Taunt:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTaunt>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Scripted:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSScripted>();
|
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 09:08:02 +00:00
|
|
|
std::unique_ptr<CBodyState> CBodyStateInfo::SetupFlyerBodyStates(pas::EAnimationState stateId, CActor& actor) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (stateId) {
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Fall:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFall>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Getup:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGetup>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LieOnGround:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLieOnGround>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Step:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSStep>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Death:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSDie>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Locomotion:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFlyerLocomotion>(actor, false);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::KnockBack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSKnockBack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::MeleeAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::ProjectileAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSProjectileAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Turn:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFlyerTurn>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopReaction:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopReaction>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::GroundHit:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGroundHit>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Generate:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGenerate>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Jump:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSJump>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Hurled:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSHurled>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Slide:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSSlide>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Taunt:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTaunt>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Scripted:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSScripted>();
|
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 09:08:02 +00:00
|
|
|
std::unique_ptr<CBodyState> CBodyStateInfo::SetupRestrictedBodyStates(pas::EAnimationState stateId, CActor& actor) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (stateId) {
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Fall:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFall>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Getup:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGetup>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LieOnGround:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLieOnGround>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Step:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSStep>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Death:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSDie>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Locomotion:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSRestrictedLocomotion>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::KnockBack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSKnockBack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::MeleeAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::ProjectileAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSProjectileAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Turn:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTurn>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopReaction:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopReaction>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::GroundHit:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGroundHit>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Generate:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGenerate>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Jump:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSJump>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Hurled:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSHurled>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Slide:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSSlide>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Taunt:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTaunt>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Scripted:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSScripted>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Cover:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSCover>();
|
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2020-04-22 09:08:02 +00:00
|
|
|
std::unique_ptr<CBodyState> CBodyStateInfo::SetupBiPedalBodyStates(pas::EAnimationState stateId, CActor& actor) const {
|
2018-12-08 05:30:43 +00:00
|
|
|
switch (stateId) {
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Fall:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSFall>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Getup:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGetup>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LieOnGround:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLieOnGround>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Step:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSStep>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Death:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSDie>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Locomotion:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSBiPedLocomotion>(actor);
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::KnockBack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSKnockBack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::MeleeAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::ProjectileAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSProjectileAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopAttack:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopAttack>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Turn:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTurn>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::LoopReaction:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSLoopReaction>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::GroundHit:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGroundHit>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Generate:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSGenerate>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Jump:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSJump>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Hurled:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSHurled>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Slide:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSSlide>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Taunt:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSTaunt>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Scripted:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSScripted>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::Cover:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSCover>();
|
2020-04-22 09:08:02 +00:00
|
|
|
case pas::EAnimationState::WallHang:
|
2018-12-08 05:30:43 +00:00
|
|
|
return std::make_unique<CBSWallHang>();
|
|
|
|
default:
|
|
|
|
return {};
|
|
|
|
}
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
float CBodyStateInfo::GetLocomotionSpeed(pas::ELocomotionAnim anim) const {
|
|
|
|
auto search = x0_stateMap.find(pas::EAnimationState::Locomotion);
|
|
|
|
if (search != x0_stateMap.cend() && search->second && x18_bodyController) {
|
|
|
|
const CBSLocomotion& bs = static_cast<const CBSLocomotion&>(*search->second);
|
|
|
|
return bs.GetLocomotionSpeed(x18_bodyController->GetLocomotionType(), anim);
|
|
|
|
}
|
|
|
|
return 0.f;
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
float CBodyStateInfo::GetMaxSpeed() const {
|
|
|
|
float ret = GetLocomotionSpeed(pas::ELocomotionAnim::Run);
|
|
|
|
if (std::fabs(ret) < 0.00001f) {
|
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
|
|
float tmp = GetLocomotionSpeed(pas::ELocomotionAnim(i));
|
|
|
|
if (tmp > ret)
|
|
|
|
ret = tmp;
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
|
|
|
return ret;
|
2017-07-10 04:55:51 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CBodyState* CBodyStateInfo::GetCurrentState() {
|
|
|
|
auto search = x0_stateMap.find(x14_state);
|
|
|
|
if (search == x0_stateMap.end())
|
|
|
|
return nullptr;
|
|
|
|
return search->second.get();
|
2017-07-14 05:14:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
const CBodyState* CBodyStateInfo::GetCurrentState() const {
|
|
|
|
auto search = x0_stateMap.find(x14_state);
|
|
|
|
if (search == x0_stateMap.end())
|
|
|
|
return nullptr;
|
|
|
|
return search->second.get();
|
2017-07-14 05:14:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CBodyStateInfo::SetState(pas::EAnimationState s) {
|
|
|
|
auto search = x0_stateMap.find(s);
|
|
|
|
if (search == x0_stateMap.end())
|
|
|
|
return;
|
|
|
|
x14_state = s;
|
2017-07-14 05:14:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
CAdditiveBodyState* CBodyStateInfo::GetCurrentAdditiveState() {
|
|
|
|
for (auto& state : x1c_additiveStates) {
|
|
|
|
if (x2c_additiveState == state.first)
|
|
|
|
return state.second.get();
|
|
|
|
}
|
|
|
|
return nullptr;
|
2017-07-14 05:14:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
void CBodyStateInfo::SetAdditiveState(pas::EAnimationState s) {
|
|
|
|
for (auto& state : x1c_additiveStates) {
|
|
|
|
if (s == state.first) {
|
|
|
|
x2c_additiveState = s;
|
|
|
|
return;
|
2017-07-14 05:14:19 +00:00
|
|
|
}
|
2018-12-08 05:30:43 +00:00
|
|
|
}
|
2017-07-14 05:14:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
bool CBodyStateInfo::ApplyHeadTracking() const {
|
|
|
|
if (x14_state == pas::EAnimationState::Invalid)
|
|
|
|
return false;
|
|
|
|
return GetCurrentState()->ApplyHeadTracking();
|
2017-07-14 05:14:19 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:30:43 +00:00
|
|
|
} // namespace urde
|