mirror of https://github.com/AxioDL/metaforce.git
CMorphBall: Collapse common code within ApplyGravity()
All that differs between the conditionals is the gravity value used, so we can collapse all of this down to simply conditionally retrieve that.
This commit is contained in:
parent
0af9b16b92
commit
c60290819e
|
@ -2168,12 +2168,13 @@ float CMorphBall::CalculateSurfaceFriction() const {
|
||||||
return friction;
|
return friction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMorphBall::ApplyGravity(CStateManager& mgr) {
|
void CMorphBall::ApplyGravity(const CStateManager& mgr) {
|
||||||
if (x0_player.CheckSubmerged() && !mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit)) {
|
const float mass = x0_player.GetMass();
|
||||||
x0_player.SetMomentumWR(zeus::CVector3f(0.f, 0.f, g_tweakBall->GetBallWaterGravity() * x0_player.GetMass()));
|
const bool hasGravitySuit = mgr.GetPlayerState()->HasPowerUp(CPlayerState::EItemType::GravitySuit);
|
||||||
} else {
|
const bool useWaterGravity = x0_player.CheckSubmerged() && !hasGravitySuit;
|
||||||
x0_player.SetMomentumWR(zeus::CVector3f(0.f, 0.f, g_tweakBall->GetBallGravity() * x0_player.GetMass()));
|
const float gravity = useWaterGravity ? g_tweakBall->GetBallWaterGravity() : g_tweakBall->GetBallGravity();
|
||||||
}
|
|
||||||
|
x0_player.SetMomentumWR(zeus::CVector3f(0.f, 0.f, gravity * mass));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMorphBall::SpinToSpeed(float holdMag, const zeus::CVector3f& torque, float mag) {
|
void CMorphBall::SpinToSpeed(float holdMag, const zeus::CVector3f& torque, float mag) {
|
||||||
|
|
|
@ -249,7 +249,7 @@ public:
|
||||||
void ComputeLiftForces(const zeus::CVector3f& controlForce, const zeus::CVector3f& velocity,
|
void ComputeLiftForces(const zeus::CVector3f& controlForce, const zeus::CVector3f& velocity,
|
||||||
const CStateManager& mgr);
|
const CStateManager& mgr);
|
||||||
float CalculateSurfaceFriction() const;
|
float CalculateSurfaceFriction() const;
|
||||||
void ApplyGravity(CStateManager& mgr);
|
void ApplyGravity(const CStateManager& mgr);
|
||||||
void SpinToSpeed(float holdMag, const zeus::CVector3f& torque, float mag);
|
void SpinToSpeed(float holdMag, const zeus::CVector3f& torque, float mag);
|
||||||
float ComputeMaxSpeed() const;
|
float ComputeMaxSpeed() const;
|
||||||
void Touch(CActor& actor, CStateManager& mgr);
|
void Touch(CActor& actor, CStateManager& mgr);
|
||||||
|
|
Loading…
Reference in New Issue