fix for crouching states aswell

This commit is contained in:
in0finite 2021-12-19 20:16:03 +01:00
parent d9acfbb431
commit 3aa4175f09
2 changed files with 16 additions and 4 deletions

View file

@ -14,10 +14,16 @@ namespace SanAndreasUnity.Behaviours.Peds.States
protected override void SwitchToMovementState () protected override void SwitchToMovementState ()
{ {
if (this.TimeSinceActivated <= this.TimeUntilStateCanBeSwitchedToOtherMovementState)
return;
// can only switch to Crouch state // can only switch to Crouch state
if( m_ped.Movement.sqrMagnitude < float.Epsilon ) if ( m_ped.Movement.sqrMagnitude < float.Epsilon )
{ {
m_ped.SwitchState<CrouchState>(); var crouchState = m_ped.GetState<CrouchState>();
if (crouchState.TimeSinceDeactivated <= crouchState.TimeUntilStateCanBeEnteredFromOtherMovementState)
return;
m_ped.SwitchState(crouchState.GetType());
} }
} }

View file

@ -14,10 +14,16 @@ namespace SanAndreasUnity.Behaviours.Peds.States
protected override void SwitchToMovementState () protected override void SwitchToMovementState ()
{ {
if (this.TimeSinceActivated <= this.TimeUntilStateCanBeSwitchedToOtherMovementState)
return;
// can only switch to CrouchMove state // can only switch to CrouchMove state
if( m_ped.Movement.sqrMagnitude > float.Epsilon ) if ( m_ped.Movement.sqrMagnitude > float.Epsilon )
{ {
m_ped.SwitchState<CrouchMoveState>(); var crouchMoveState = m_ped.GetState<CrouchMoveState>();
if (crouchMoveState.TimeSinceDeactivated <= crouchMoveState.TimeUntilStateCanBeEnteredFromOtherMovementState)
return;
m_ped.SwitchState(crouchMoveState.GetType());
} }
} }