exit drive-by state if ped doesn't have gun weapon

This commit is contained in:
in0finite 2021-02-22 23:20:01 +01:00
parent eb937dd512
commit 9e7378d1ca
2 changed files with 26 additions and 1 deletions

View file

@ -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<VehicleSittingState>().EnterVehicle(this.CurrentVehicle, this.CurrentVehicleSeatAlignment);
return;
}
}
base.UpdateState();
}
protected override void UpdateAnimsInternal()
{
this.UpdateAnimsInternal(true);

View file

@ -115,7 +115,10 @@ namespace SanAndreasUnity.Behaviours.Peds.States
public override void OnAimButtonPressed()
{
if (m_isServer)
{
if (m_ped.GetStateOrLogError<DriveByState>().CanEnterState(this.CurrentVehicle, this.CurrentVehicleSeatAlignment))
m_ped.GetStateOrLogError<DriveByState>().EnterVehicle(this.CurrentVehicle, this.CurrentVehicleSeatAlignment);
}
else
base.OnAimButtonPressed();
}