/// <summary> /// Warps to the current seed. /// </summary> public static void Warp(bool processActions, string theSeed, bool savePersistence = true) { Debugger.Log("Beginning warp to " + theSeed); // Replace any newline or tab characters. theSeed = Regex.Replace(theSeed, "[^ -~]+", string.Empty, RegexOptions.Multiline); // Make sure the seed is valid if (string.IsNullOrEmpty(theSeed)) { ScreenMessages.PostScreenMessage("Invalid coordinates.", 3.0f, ScreenMessageStyle.UPPER_CENTER); return; } // Set the seeds lastSeed = seedString; seedString = theSeed; try { // Create the RNG Randomizers.WarpRNG.ReSeed(seedString); // Create and randomize the system SolarData.CreateSystem(seedString); // Write the current seed to file SeedTracker.Jump(); } catch (System.Exception e) { // Catch all exceptions so users know if something goes wrong ScreenMessages.PostScreenMessage("Warp Drive failed due to " + e.GetType() + "."); Debugger.LogException("Unable to jump to system!", e); return; } if (seedString != AstroUtils.KERBIN_SYSTEM_COORDS) { // We've left Kerbol, so we need to purge the Kerbol vessels needsPurge = true; } if (processActions) { // Call each post-warp action foreach (OnWarpDelegate onWarp in nextWarpActions) { onWarp(); } // Clear the list of methods nextWarpActions.Clear(); } if (savePersistence) { PersistenceGenerator.SavePersistence(); } if (hasInit) { instance.Invoke("PostWarp", Time.deltaTime); } Debugger.LogWarning("Created system " + currentSystem.name + " from string " + seedString + "."); }