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 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; } } }