Make LimitVel a proper function

This commit is contained in:
heinrich5991 2019-09-18 14:43:41 +02:00
parent 66ccd808aa
commit bcd1559c5e
3 changed files with 8 additions and 9 deletions

View file

@ -325,7 +325,7 @@ void CCharacter::FireWeapon()
float Strength = GetTuning(m_TuneZone)->m_HammerStrength;
vec2 Temp = pTarget->m_Core.m_Vel + normalize(Dir + vec2(0.f, -1.1f)) * 10.0f;
pTarget->Core()->LimitVel(&Temp);
Temp = pTarget->Core()->LimitVel(Temp);
Temp -= pTarget->m_Core.m_Vel;
vec2 Force = vec2(0.f, -1.0f) + Temp;
@ -649,8 +649,7 @@ void CCharacter::HandleSkippableTiles(int Index)
}
else
TempVel += Direction * Force;
m_Core.LimitVel(&TempVel);
m_Core.m_Vel = TempVel;
m_Core.m_Vel = m_Core.LimitVel(TempVel);
}
}
}

View file

@ -601,14 +601,12 @@ bool CCharacterCore::IsSwitchActiveCb(int Number, void *pUser)
return false;
}
void CCharacterCore::LimitVel(vec2 *pVel)
vec2 CCharacterCore::LimitVel(vec2 Vel)
{
*pVel = ClampVel(m_MoveRestrictions, *pVel);
return ClampVel(m_MoveRestrictions, Vel);
}
void CCharacterCore::ApplyForce(vec2 Force)
{
vec2 Temp = m_Vel + Force;
LimitVel(&Temp);
m_Vel = Temp;
m_Vel = LimitVel(m_Vel + Force);
}

View file

@ -250,7 +250,9 @@ public:
int m_FreezeEnd;
bool m_DeepFrozen;
void LimitVel(vec2 *pVel);
// Caps the given velocity according to the current set of stoppers
// that the character is affected by.
vec2 LimitVel(vec2 Vel);
void ApplyForce(vec2 Force);
private: