using System.Collections.Generic;
using GTANetworkAPI;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.WeaponDeal;

namespace ReallifeGamemode.Server.Events
{
  public class EnterVehicle : Script
  {
    [ServerEvent(Event.PlayerEnterVehicle)]
    public void OnPlayerEnterVehicle(Player client, GTANetworkAPI.Vehicle vehicle, sbyte seat)
    {
      if (seat != 0)
      {
        return;
      }

      if (vehicle.HasMarkerBehind())
        vehicle.RemoveMarkerBehind();

      if (vehicle.GetServerVehicle() is FactionVehicle veh)
      {
        User u = client.GetUser();
        if (u.FactionId != null
          && veh.GetOwners().Contains(u.FactionId.Value)
          && (veh.Model == VehicleHash.Burrito3 || veh.Model == VehicleHash.Policet)
          && vehicle.HasData("weaponDeal")
          && vehicle.GetData<bool>("weaponDeal") == true
          && (!vehicle.HasData("WeaponDealLoad") || vehicle.GetData<bool>("WeaponDealLoad") == false))
        {
          List<Vector3> dealPoint = new List<Vector3>();
          dealPoint.Add(vehicle.GetData<Vector3>("weaponDealPoint"));
          CheckPointHandle.StartCheckPointRoute(client, dealPoint, 5000, 1, 7, 3, true, "loadWeaponTransport");
        }
        else if ((u.FactionId != null)
                && ((VehicleHash)vehicle.Model == VehicleHash.Burrito3 || (VehicleHash)vehicle.Model == VehicleHash.Policet)
                && vehicle.HasData("WeaponDealLoad")
                && vehicle.GetData<bool>("WeaponDealLoad") == true)
        {
          BasePoints basePoints = new BasePoints();
          basePoints.getbase(u.FactionId, client);        
        }


      }
    }
  }
}
