CKnockBackController: Make CalculateExtraHurlVelocity() a const member function

This doesn't modify internal member state, so it can be marked const

While we're at it we can also invert the conditional to unindent the
main calculation.
This commit is contained in:
Lioncash 2020-04-17 01:05:47 -04:00
parent b55d1e4c77
commit 58040eb53d
2 changed files with 7 additions and 5 deletions

View File

@ -473,10 +473,12 @@ void CKnockBackController::ValidateState(const CPatterned& parent) {
} }
} }
float CKnockBackController::CalculateExtraHurlVelocity(CStateManager& mgr, float magnitude, float kbResistance) { float CKnockBackController::CalculateExtraHurlVelocity(CStateManager& mgr, float magnitude, float kbResistance) const {
if (magnitude > kbResistance) if (magnitude <= kbResistance) {
return (1.1f - 0.2f * mgr.GetActiveRandom()->Float()) * 2.f * (magnitude - kbResistance);
return 0.f; return 0.f;
}
return (1.1f - 0.2f * mgr.GetActiveRandom()->Float()) * 2.f * (magnitude - kbResistance);
} }
void CKnockBackController::DoKnockBackAnimation(const zeus::CVector3f& backVec, CStateManager& mgr, CPatterned& parent, void CKnockBackController::DoKnockBackAnimation(const zeus::CVector3f& backVec, CStateManager& mgr, CPatterned& parent,

View File

@ -101,7 +101,7 @@ private:
bool TickDeferredTimer(float dt); bool TickDeferredTimer(float dt);
EKnockBackCharacterState GetKnockBackCharacterState(const CPatterned& parent) const; EKnockBackCharacterState GetKnockBackCharacterState(const CPatterned& parent) const;
void ValidateState(const CPatterned& parent); void ValidateState(const CPatterned& parent);
float CalculateExtraHurlVelocity(CStateManager& mgr, float magnitude, float kbResistance); float CalculateExtraHurlVelocity(CStateManager& mgr, float magnitude, float kbResistance) const;
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(const 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);