private void SpawnMenu_OnMenuOpen(UIMenu sender)
        {
            if (ForceNew || (Main.PlayerVehicle == null || !DeloreanHandler.IsVehicleATimeMachine(Main.PlayerVehicle)))
            {
                if (ForceNew)
                {
                    ForceNew = false;
                }

                Vector3 spawnPos = Main.PlayerPed.Position;

                if (Main.PlayerVehicle != null)
                {
                    spawnPos = Main.PlayerVehicle.Position.Around(5f);
                }

                _tempTimeMachine = (DeloreanTimeMachine)DMC12.CreateDelorean(spawnPos, Main.PlayerPed.Heading, DeloreanType.BTTF1);

                Main.PlayerPed.SetIntoVehicle(_tempTimeMachine.Vehicle, VehicleSeat.Driver);

                _tempTimeMachine.Vehicle.PlaceOnGround();

                _tempTimeMachine.MPHSpeed = 1;
            }
            else if (DeloreanHandler.IsVehicleATimeMachine(Main.PlayerVehicle))
            {
                _tempTimeMachine = DeloreanHandler.GetTimeMachineFromVehicle(Main.PlayerVehicle);
                _save            = true;

                _wheelsType.Enabled = !_tempTimeMachine.Circuits.IsFlying;
            }

            LoadVehicleType();
        }
        private static void HandleGarageExiting()
        {
            if (isExitingGarage)
            {
                if (Game.GameTime < exitGarageTimer)
                {
                    return;
                }

                switch (currentExitGarageStep)
                {
                case 0:
                    Main.MenuPool.CloseAllMenus();
                    Screen.FadeOut(1000);
                    exitGarageTimer = Game.GameTime + 1200;
                    currentExitGarageStep++;

                    break;

                case 1:
                    canEnterGarage          = false;
                    currentVehicle.Position = garageEnter;
                    currentVehicle.Rotation = garageExitRotation;
                    garageCamera            = null;
                    World.RenderingCamera   = null;
                    enterGarageTimer        = Game.GameTime + 1000;
                    currentExitGarageStep++;

                    break;

                case 2:
                    Screen.FadeIn(1000);

                    if (carChanged)
                    {
                        garageCarChanged.Play(currentVehicle);
                        carChanged = false;
                    }

                    currentExitGarageStep++;
                    break;

                case 3:
                    float dist = currentVehicle.Position.DistanceTo(garageEnter);
                    if (dist >= 10)
                    {
                        canEnterGarage        = true;
                        currentExitGarageStep = 0;
                        isExitingGarage       = false;
                        exitGarageTimer       = 0;

                        currentVehicle  = null;
                        currentDelorean = null;
                    }

                    break;
                }
            }
        }
        public static void EnterGarage(Vehicle vehicle)
        {
            var delorean = DeloreanHandler.GetDeloreanFromVehicle(vehicle);

            currentVehicle = vehicle;

            if (delorean != null)
            {
                currentDelorean = delorean;
            }

            IsInGarage       = true;
            isEnteringGarage = true;
        }
        private static void HandleSwitching()
        {
            if (isSwitching)
            {
                if (Game.GameTime < switchTimer)
                {
                    return;
                }

                switch (currentSwitchStep)
                {
                case 0:
                    Screen.FadeOut(1000);
                    if (currentDelorean != null && currentDelorean.IsTimeMachine)
                    {
                        DeloreanTimeMachine timeMachine = currentDelorean as DeloreanTimeMachine;
                        destinationTime = timeMachine.Circuits.DestinationTime;
                        previousTime    = timeMachine.Circuits.PreviousTime;
                    }
                    else
                    {
                        destinationTime = null;
                        previousTime    = null;
                    }
                    switchTimer = Game.GameTime + 1200;
                    currentSwitchStep++;

                    break;

                case 1:
                    // Do the switching here

                    // Delete old DMC12
                    if (currentDelorean != null)
                    {
                        DeloreanHandler.RemoveDelorean(currentDelorean);
                    }
                    else
                    {
                        currentVehicle?.Delete();
                    }

                    // Spawn new delorean
                    var newDelorean = DMC12.CreateDelorean(garageVehiclePosition, garageVehicleRotation.ToHeading(), switchTo, hasHook);
                    newDelorean.Vehicle.Rotation = garageVehicleRotation;

                    // Set the destination and previous time, so they're not lost
                    if (switchTo != DeloreanType.DMC12 && destinationTime != null && previousTime != null)
                    {
                        ((DeloreanTimeMachine)newDelorean).Circuits.DestinationTime = destinationTime.GetValueOrDefault();
                        ((DeloreanTimeMachine)newDelorean).Circuits.PreviousTime    = previousTime.GetValueOrDefault();
                    }

                    // Warp player inside vehicle
                    Main.PlayerPed.Task.WarpIntoVehicle(newDelorean, VehicleSeat.Driver);

                    // Update variables
                    currentVehicle  = newDelorean;
                    currentDelorean = newDelorean;

                    // Move forward
                    currentSwitchStep++;
                    switchTimer = Game.GameTime + 1000;

                    break;

                case 2:
                    Screen.FadeIn(1000);
                    UpdateGarage();
                    Main.MenuPool.CloseAllMenus();
                    garageMenu.Visible = true;
                    switchTimer        = 0;
                    currentSwitchStep  = 0;
                    isSwitching        = false;

                    break;
                }
            }
        }