using System;
using Unity.VisualScripting;
using UnityEngine;

namespace Parking
{
    public class Driver
    {
        public readonly ParkingPreference ParkingPreference;
        public readonly int Number;
        public readonly Size Size;
        public DateTime[] Times;
        public Spot Spot;
        public bool Parked = false;
        public GameObject GameObject;
        public bool Rejected = false;
        public int Priority;
        public int UpdateInterval;

        public Driver(Size size, int number, ParkingPreference parkingPreference, int priority, int updateInterval)
        {
            Size = size;
            Number = number;
            ParkingPreference = parkingPreference;
            Priority = priority;
            UpdateInterval = updateInterval;
        }
        
        public void Reset()
        {
            Parked = false;
            Rejected = false;
            if(Spot != null)
                Spot.Free = true;
            Spot = null;
            if(GameObject != null)
                GameObject.Destroy(GameObject);
        }
    }

    public class Spot : IComparable<Spot>
    {
        public Size Size;
        public bool Flipped;
        public GameObject GameObject;
        public bool Free = true;
        public bool Reserved = false;
        public int ReservedPriority = 0;
        public ParkingPreference ParkingDirection = ParkingPreference.Any;
        public int Lane = 0;
        public bool Perpendicular = true;
        public bool AlignToTop = true;

        public Spot(Size size, bool flipped)
        {
            Size = size;
            Flipped = flipped;
        }

        public Spot()
        {
            
        }
        public int CompareTo(Spot obj)
        {
            return Size.CompareTo(obj.Size);
        }
    }
    
    public enum Size
    {
        A = 0,
        B = 1,
        C = 2,
        D = 3
    }

    public enum ParkingPreference
    {
        Any = 0,
        Front = 1,
        Back = 2
    }
}