diff --git a/Assets/Scripts/Behaviours/Ped/States/DriveByState.cs b/Assets/Scripts/Behaviours/Ped/States/DriveByState.cs index 8f1c4320..c1101f25 100644 --- a/Assets/Scripts/Behaviours/Ped/States/DriveByState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/DriveByState.cs @@ -63,6 +63,28 @@ namespace SanAndreasUnity.Behaviours.Peds.States } + public bool CanEnterState(Vehicle vehicle, Vehicle.SeatAlignment seatAlignment) + { + var w = m_ped.CurrentWeapon; + return null != w && w.IsGun; + } + + public override void UpdateState() + { + // exit drive-by state if ped doesn't have gun weapon + if (m_isServer) + { + var w = m_ped.CurrentWeapon; + if (null == w || !w.IsGun) + { + m_ped.GetStateOrLogError().EnterVehicle(this.CurrentVehicle, this.CurrentVehicleSeatAlignment); + return; + } + } + + base.UpdateState(); + } + protected override void UpdateAnimsInternal() { this.UpdateAnimsInternal(true); diff --git a/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs b/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs index fcd430d9..12f3e477 100644 --- a/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs +++ b/Assets/Scripts/Behaviours/Ped/States/VehicleSittingState.cs @@ -115,7 +115,10 @@ namespace SanAndreasUnity.Behaviours.Peds.States public override void OnAimButtonPressed() { if (m_isServer) - m_ped.GetStateOrLogError().EnterVehicle(this.CurrentVehicle, this.CurrentVehicleSeatAlignment); + { + if (m_ped.GetStateOrLogError().CanEnterState(this.CurrentVehicle, this.CurrentVehicleSeatAlignment)) + m_ped.GetStateOrLogError().EnterVehicle(this.CurrentVehicle, this.CurrentVehicleSeatAlignment); + } else base.OnAimButtonPressed(); }