CKnockBackController: Make use of const references where applicable

In many cases the CPatterned& parameter is only used for read-only
querying. We can make this explicit in the interface.
This commit is contained in:
Lioncash 2020-04-17 01:03:10 -04:00
parent 49cc019699
commit b55d1e4c77
2 changed files with 15 additions and 12 deletions

View File

@ -407,7 +407,7 @@ EKnockBackCharacterState CKnockBackController::GetKnockBackCharacterState(const
return parent.IsAlive() ? EKnockBackCharacterState::Alive : EKnockBackCharacterState::Dead; return parent.IsAlive() ? EKnockBackCharacterState::Alive : EKnockBackCharacterState::Dead;
} }
void CKnockBackController::ValidateState(CPatterned& parent) { void CKnockBackController::ValidateState(const CPatterned& parent) {
if (x4_activeParms.x0_animState < x18_minAnimState) if (x4_activeParms.x0_animState < x18_minAnimState)
x4_activeParms.x0_animState = x18_minAnimState; x4_activeParms.x0_animState = x18_minAnimState;
else if (x4_activeParms.x0_animState > x1c_maxAnimState) else if (x4_activeParms.x0_animState > x1c_maxAnimState)
@ -518,7 +518,8 @@ void CKnockBackController::DoKnockBackAnimation(const zeus::CVector3f& backVec,
} }
} }
void CKnockBackController::ResetKnockBackImpulse(CPatterned& parent, const zeus::CVector3f& backVec, float magnitude) { void CKnockBackController::ResetKnockBackImpulse(const CPatterned& parent, const zeus::CVector3f& backVec,
float magnitude) {
if (x81_24_autoResetImpulse && x4_activeParms.x0_animState == EKnockBackAnimationState::KnockBack && if (x81_24_autoResetImpulse && x4_activeParms.x0_animState == EKnockBackAnimationState::KnockBack &&
x4_activeParms.x4_animFollowup != EKnockBackAnimationFollowUp::Freeze) { x4_activeParms.x4_animFollowup != EKnockBackAnimationFollowUp::Freeze) {
x50_impulseDir = backVec.canBeNormalized() ? backVec.normalized() : -parent.GetTransform().basis[1]; x50_impulseDir = backVec.canBeNormalized() ? backVec.normalized() : -parent.GetTransform().basis[1];
@ -609,17 +610,19 @@ EKnockBackWeaponType CKnockBackController::GetKnockBackWeaponType(const CDamageI
} }
} }
void CKnockBackController::SelectDamageState(CPatterned& parent, const CDamageInfo& info, EWeaponType wType, void CKnockBackController::SelectDamageState(const CPatterned& parent, const CDamageInfo& info, EWeaponType wType,
EKnockBackType type) { EKnockBackType type) {
x4_activeParms = KnockBackParms(); x4_activeParms = KnockBackParms();
EKnockBackWeaponType weaponType = GetKnockBackWeaponType(info, wType, type);
if (weaponType != EKnockBackWeaponType::Invalid) { const EKnockBackWeaponType weaponType = GetKnockBackWeaponType(info, wType, type);
if (weaponType == EKnockBackWeaponType::Invalid) {
return;
}
x4_activeParms = x4_activeParms =
KnockBackParmsTable[size_t(x0_variant)][size_t(weaponType)][size_t(GetKnockBackCharacterState(parent))]; KnockBackParmsTable[size_t(x0_variant)][size_t(weaponType)][size_t(GetKnockBackCharacterState(parent))];
ValidateState(parent); ValidateState(parent);
} }
}
void CKnockBackController::KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, CPatterned& parent, void CKnockBackController::KnockBack(const zeus::CVector3f& backVec, CStateManager& mgr, CPatterned& parent,
const CDamageInfo& info, EKnockBackType type, float magnitude) { const CDamageInfo& info, EKnockBackType type, float magnitude) {

View File

@ -100,13 +100,13 @@ private:
void ApplyImpulse(float dt, CPatterned& parent); void ApplyImpulse(float dt, CPatterned& parent);
bool TickDeferredTimer(float dt); bool TickDeferredTimer(float dt);
EKnockBackCharacterState GetKnockBackCharacterState(const CPatterned& parent) const; EKnockBackCharacterState GetKnockBackCharacterState(const CPatterned& parent) const;
void ValidateState(CPatterned& parent); void ValidateState(const CPatterned& parent);
float CalculateExtraHurlVelocity(CStateManager& mgr, float magnitude, float kbResistance); float CalculateExtraHurlVelocity(CStateManager& mgr, float magnitude, float kbResistance);
void DoKnockBackAnimation(const zeus::CVector3f& backVec, CStateManager& mgr, CPatterned& parent, float magnitude); void DoKnockBackAnimation(const zeus::CVector3f& backVec, CStateManager& mgr, CPatterned& parent, float magnitude);
void ResetKnockBackImpulse(CPatterned& parent, const zeus::CVector3f& backVec, float magnitude); void ResetKnockBackImpulse(const CPatterned& parent, const zeus::CVector3f& backVec, float magnitude);
void DoDeferredKnockBack(CStateManager& mgr, CPatterned& parent); void DoDeferredKnockBack(CStateManager& mgr, CPatterned& parent);
EKnockBackWeaponType GetKnockBackWeaponType(const CDamageInfo& info, EWeaponType wType, EKnockBackType type); EKnockBackWeaponType GetKnockBackWeaponType(const CDamageInfo& info, EWeaponType wType, EKnockBackType type);
void SelectDamageState(CPatterned& parent, const CDamageInfo& info, EWeaponType wType, EKnockBackType type); void SelectDamageState(const CPatterned& parent, const CDamageInfo& info, EWeaponType wType, EKnockBackType type);
public: public:
explicit CKnockBackController(EKnockBackVariant variant); explicit CKnockBackController(EKnockBackVariant variant);