2020-05-31 17:07:22 +00:00
|
|
|
using UnityEngine;
|
|
|
|
using SanAndreasUnity.Utilities;
|
|
|
|
using SanAndreasUnity.Behaviours.Vehicles;
|
|
|
|
|
|
|
|
namespace SanAndreasUnity.Behaviours.Peds.States
|
|
|
|
{
|
|
|
|
|
|
|
|
public class BaseVehicleState : BaseScriptState, IVehicleState
|
|
|
|
{
|
|
|
|
private Vehicle m_currentVehicle;
|
|
|
|
public Vehicle CurrentVehicle { get { return m_currentVehicle; } protected set { m_currentVehicle = value; } }
|
|
|
|
|
|
|
|
public Vehicle.Seat CurrentVehicleSeat { get; protected set; }
|
|
|
|
public Vehicle.SeatAlignment CurrentVehicleSeatAlignment { get { return this.CurrentVehicleSeat.Alignment; } }
|
|
|
|
|
|
|
|
|
2019-04-28 23:15:24 +00:00
|
|
|
protected void Cleanup()
|
|
|
|
{
|
|
|
|
if (!m_ped.IsInVehicle)
|
|
|
|
{
|
|
|
|
m_ped.characterController.enabled = true;
|
|
|
|
m_ped.transform.SetParent(null, true);
|
|
|
|
m_model.IsInVehicle = false;
|
|
|
|
}
|
2019-04-29 00:04:45 +00:00
|
|
|
|
2019-04-29 00:06:44 +00:00
|
|
|
if (this.CurrentVehicleSeat != null && this.CurrentVehicleSeat.OccupyingPed == m_ped)
|
2019-04-29 00:04:45 +00:00
|
|
|
this.CurrentVehicleSeat.OccupyingPed = null;
|
|
|
|
|
|
|
|
this.CurrentVehicle = null;
|
|
|
|
this.CurrentVehicleSeat = null;
|
2019-04-28 23:15:24 +00:00
|
|
|
}
|
|
|
|
|
2020-05-31 17:07:22 +00:00
|
|
|
protected override void UpdateHeading()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void UpdateRotation()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void UpdateMovement()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void ConstrainRotation ()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool CanEnterVehicle (Vehicle vehicle, Vehicle.SeatAlignment seatAlignment)
|
|
|
|
{
|
|
|
|
if (m_ped.IsInVehicle)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (m_ped.IsAiming || m_ped.WeaponHolder.IsFiring)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
var seat = vehicle.GetSeat (seatAlignment);
|
|
|
|
if (null == seat)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// check if specified seat is taken
|
|
|
|
if (seat.IsTaken)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// everything is ok, we can enter vehicle
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|