dont quickly switch between drive-by and sitting states

This commit is contained in:
in0finite 2021-10-17 19:36:15 +02:00
parent 184f1fabc3
commit 197b0d58ff

View file

@ -47,7 +47,17 @@ namespace SanAndreasUnity.Behaviours.Peds.States
}
}
private float m_lastTimeWhenDeactivated = 0f;
public float timeUntilAbleToSwitchState = 0.3f;
public override void OnBecameInactive()
{
m_lastTimeWhenDeactivated = Time.time;
base.OnBecameInactive();
}
protected override void EnterVehicleInternal()
{
@ -65,6 +75,9 @@ namespace SanAndreasUnity.Behaviours.Peds.States
public bool CanEnterState(Vehicle vehicle, Vehicle.SeatAlignment seatAlignment)
{
if (Time.time - m_lastTimeWhenDeactivated > this.timeUntilAbleToSwitchState)
return false;
var w = m_ped.CurrentWeapon;
return null != w && w.IsGun;
}