using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using ReallifeGamemode.Server.Managers;
using System.Linq;

namespace ReallifeGamemode.Server.Extensions
{
  public static class VehicleExtension
  {
    public static ServerVehicle GetServerVehicle(this Vehicle veh, DatabaseContext context = null)
    {
      return VehicleManager.GetServerVehicleFromVehicle(veh, context);
    }

    public static Player GetDriver(this Vehicle veh)
    {
      return NAPI.Pools.GetAllPlayers().Where(p => p.Vehicle.Handle == veh.Handle && p.VehicleSeat == 0).FirstOrDefault();
    }
  }
}
