metaforce/Runtime/Character/CBodyStateCmdMgr.cpp

91 lines
3.0 KiB
C++
Raw Permalink Normal View History

#include "Runtime/Character/CBodyStateCmdMgr.hpp"
#include <cfloat>
2021-04-10 08:42:06 +00:00
namespace metaforce {
2018-12-08 05:30:43 +00:00
CBodyStateCmdMgr::CBodyStateCmdMgr() {
x40_commandTable.push_back(&xb8_getup);
x40_commandTable.push_back(&xc4_step);
2018-12-13 07:39:16 +00:00
x40_commandTable.push_back(&xd4_die);
2018-12-08 05:30:43 +00:00
x40_commandTable.push_back(&xdc_knockDown);
x40_commandTable.push_back(&xf4_knockBack);
x40_commandTable.push_back(&x10c_meleeAttack);
x40_commandTable.push_back(&x128_projectileAttack);
x40_commandTable.push_back(&x144_loopAttack);
x40_commandTable.push_back(&x154_loopReaction);
x40_commandTable.push_back(&x160_loopHitReaction);
2018-12-13 07:39:16 +00:00
x40_commandTable.push_back(&x16c_exitState);
x40_commandTable.push_back(&x174_leanFromCover);
x40_commandTable.push_back(&x17c_nextState);
x40_commandTable.push_back(&x184_maintainVelocity);
2018-12-08 05:30:43 +00:00
x40_commandTable.push_back(&x18c_generate);
x40_commandTable.push_back(&x1ac_hurled);
x40_commandTable.push_back(&x1d0_jump);
x40_commandTable.push_back(&x1f8_slide);
x40_commandTable.push_back(&x210_taunt);
x40_commandTable.push_back(&x21c_scripted);
x40_commandTable.push_back(&x230_cover);
x40_commandTable.push_back(&x254_wallHang);
2018-12-13 07:39:16 +00:00
x40_commandTable.push_back(&x260_locomotion);
x40_commandTable.push_back(&x268_additiveIdle);
2018-12-08 05:30:43 +00:00
x40_commandTable.push_back(&x270_additiveAim);
x40_commandTable.push_back(&x278_additiveFlinch);
x40_commandTable.push_back(&x284_additiveReaction);
2018-12-13 07:39:16 +00:00
x40_commandTable.push_back(&x298_stopReaction);
}
2018-12-08 05:30:43 +00:00
void CBodyStateCmdMgr::DeliverCmd(const CBCLocomotionCmd& cmd) {
if (cmd.GetWeight() <= FLT_EPSILON)
return;
x3c_steeringSpeed += cmd.GetWeight();
x0_move += cmd.GetMoveVector() * cmd.GetWeight();
xc_face += cmd.GetFaceVector() * cmd.GetWeight();
2017-07-10 04:55:51 +00:00
}
2018-12-08 05:30:43 +00:00
void CBodyStateCmdMgr::BlendSteeringCmds() {
if (x3c_steeringSpeed > FLT_EPSILON) {
float stepMul = 1.f / x3c_steeringSpeed;
xc_face *= zeus::CVector3f(stepMul);
2017-07-10 04:55:51 +00:00
2018-12-08 05:30:43 +00:00
switch (x30_steeringMode) {
case ESteeringBlendMode::Normal:
x0_move *= zeus::CVector3f(stepMul);
break;
case ESteeringBlendMode::FullSpeed:
if (!zeus::close_enough(x0_move, zeus::skZero3f, 0.0001f)) {
2018-12-08 05:30:43 +00:00
x0_move.normalize();
x0_move *= zeus::CVector3f(x38_steeringSpeedMax);
}
break;
case ESteeringBlendMode::Clamped:
x0_move *= zeus::CVector3f(stepMul);
if (!zeus::close_enough(x0_move, zeus::skZero3f, 0.0001f)) {
2018-12-08 05:30:43 +00:00
if (x0_move.magnitude() < x34_steeringSpeedMin)
x0_move = x0_move.normalized() * x34_steeringSpeedMin;
else if (x0_move.magnitude() > x38_steeringSpeedMax)
x0_move = x0_move.normalized() * x38_steeringSpeedMax;
}
break;
default:
break;
2017-07-10 04:55:51 +00:00
}
2018-12-08 05:30:43 +00:00
}
2017-07-10 04:55:51 +00:00
}
2018-12-08 05:30:43 +00:00
void CBodyStateCmdMgr::Reset() {
x0_move = zeus::skZero3f;
xc_face = zeus::skZero3f;
x18_target = zeus::skZero3f;
2018-12-08 05:30:43 +00:00
x3c_steeringSpeed = 0.f;
xb4_deliveredCmdMask = 0;
2017-07-10 04:55:51 +00:00
}
2018-12-08 05:30:43 +00:00
void CBodyStateCmdMgr::ClearLocomotionCmds() {
x0_move = zeus::skZero3f;
xc_face = zeus::skZero3f;
2018-12-08 05:30:43 +00:00
x3c_steeringSpeed = 0.f;
2017-07-10 04:55:51 +00:00
}
2021-04-10 08:42:06 +00:00
} // namespace metaforce