/// <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 + "."); }
/// <summary> /// Loops through all the Option Seeds of the item wielder. The action has 4 useful parameters to use. /// The first parameter refers to the Option Seed itself. It is a GameObject. /// The second parameter refers to the SeedBehavior component of the Option Seed. /// The third parameter refers to the SeedTracker component of the item wielder. /// The last parameter is the computed damage multiplier based on configuration and item count of the owner. /// </summary> /// <param name="optionSeedOwner">The owner of the Option Seed.</param> /// <param name="actionToRun">An action to execute for each Option. The inputs are as follows: /// GameObject seed, SeedBehavior behavior, SeedTracker tracker, float multiplier.</param> public void FireForSeeds(CharacterBody optionSeedOwner, Action <GameObject, SeedBehavior, SeedTracker, float> actionToRun) { if (!optionSeedOwner) { return; } SeedTracker seedTracker = optionSeedOwner.GetComponent <SeedTracker>(); if (!seedTracker) { return; } InputBankTest inputBankTest = seedTracker.inputBankTest; if (!inputBankTest) { return; } float multiplier = ComputeMultiplier(optionSeedOwner); actionToRun(seedTracker.leftSeed, seedTracker.leftBehavior, seedTracker, multiplier); actionToRun(seedTracker.rightSeed, seedTracker.rightBehavior, seedTracker, multiplier); }