Decompiled source of Random Moons v1.4.1

plugins/4902-Random_Moons.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace random_moons;

[BepInPlugin("4902.Random_Moons", "Random_Moons", "1.0.0")]
public class c : BaseUnityPlugin
{
	private readonly Harmony harmony = new Harmony("4902.Random_Moons");

	public static ManualLogSource mls;

	public static ConfigEntry<bool> cfg_ltn;

	public static ConfigEntry<bool> cfg_ltw;

	public static ConfigEntry<bool> cfg_wet;

	public static ConfigEntry<bool> cfg_rld;

	public static ConfigEntry<bool> cfg_psm;

	public static ConfigEntry<bool> cfg_mdn;

	public static ConfigEntry<bool> cfg_slm;

	public static ConfigEntry<bool> cfg_mcc;

	public static ConfigEntry<bool> cfg_mcm;

	public static ConfigEntry<bool> cfg_cmm;

	public static ConfigEntry<int> cfg_dsc;

	public static ConfigEntry<int> cfg_fl1;

	public static ConfigEntry<string> cfg_fl2;

	public static ConfigEntry<bool> cfg_key;

	public static ConfigEntry<int> cfg_kcd;

	public static ConfigEntry<int> cfg_kcr;

	public static ConfigEntry<bool> cfg_pri;

	public static ConfigEntry<bool> cfg_tst;

	public static bool chosen = false;

	public static bool chosen_moon = false;

	public static int real = -1;

	public static string moon_n = "name";

	public static string moon_c = "ffffff";

	public static string moon_d = "description";

	public static uint key = 0u;

	public static string keys = "";

	private void Awake()
	{
		cfg_ltn = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "-print", false, "[Print Moon Name]\nprints the moon name if there are <= 1 players");
		cfg_ltw = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "--print", false, "[Print Moon Weather]\nprints the moon weather if there are <= 1 players");
		cfg_wet = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "---print", true, "[Print Moon Weather]\nprints the weather at all");
		cfg_rld = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "random", true, "[Random Description]\nshould the description on the monitor display a random levels description.\ntrue, display any levels description, unrelated to the actual orbited level\nfalse, display unknown");
		cfg_psm = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "prevent", true, "[Prevent Same Moon]\nprevents routing to the same level as the currently orbited level.\nif current challenge moon is Moon-11 and its level is Adamance, rerouting would or would not be able to pick Adamance again");
		cfg_mdn = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "default", true, "[Default Moon Name]\ndisplay the levels default name instead of its challenge moon name when landing.\ndisplay 'CELESTIAL BODY: 20 Adamance' or 'CELESTIAL BODY: Moon-11'");
		cfg_slm = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "save/load", true, "[Save / Load]\nsave and load the current challenge moon being orbited and the previous 10 moons.\ntrue, when rejoining the orbited moon will be the same challenge moon as it was previously\nfalse, if challenge moon was Moon-11 and level was Adamance then when rejoining the orbited moon will be non-challenge Adamance");
		cfg_mcc = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "-color", true, "[Printed Moon Color]\nshould the moon name printed to chat have color");
		cfg_mcm = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "--color", true, "[Monitor Moon Color]\nshould the moon name on the monitor have color");
		cfg_cmm = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "modifiers", true, "[Challenge Moon Modifiers]\nshould challenge moon modifiers be enabled for challenge moons.\ntype 'randomizer modifiers' in the terminal to toggle this config in-game. it will be resynced to other players the next time the level is changed");
		cfg_dsc = ((BaseUnityPlugin)this).Config.Bind<int>("#", "option", 1, "[Seed / Route Options]\n1 = different seed each day (like vanilla gameplay)\n2 = same seed for the same challenge moon (like weekly challenge moons)\n3 = route to company when going to orbit from a challenge moon (to play a different level each day)");
		cfg_fl1 = ((BaseUnityPlugin)this).Config.Bind<int>("#", "filter", 1, "[Filtered Moons]\nchanges which moons are routable with the randomizer.\n1 = disabled, all moons are routable\n2 = blacklist, moons in the list are not routable\n3 = whitelist, only moons in the list are routable");
		cfg_fl2 = ((BaseUnityPlugin)this).Config.Bind<string>("#", "list", "[20 Adamance], [68 Artifice], [5 Embrion]", "[Filter List]\nlist of moons that are blacklisted/whitelisted.\ntype 'randomizer info' in the terminal to see all of the moons (including modded)(they will be displayed in the terminal and logged to the console), those are the exact moon names that would be put in this list. the moon names inside the brackets [] are case sensitive so the positions of the characters/numbers and uppercase/lowercase need to be exactly the same.\nGordion and Liquidation are already filtered so those don't need to be added.\nif there are no available moons it will route to gordion");
		cfg_key = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "key", true, "[Direct Routing]\nwhether direct routing should be enabled/disabled.\ntype 'randomizer key' in the terminal to enter the key/id of a moon to route to that moon. also shows the previous 10 moons with their key/name/cost.\nrouting directly to a moon will cost a random amount of credits based on the key. (default_credits +/- (random_credits * 10)). minimum cost is 100.\nif the number of levels changes (vanilla moon being added/removed or adding/removing a modded moon) then the level that a key routes to will be different than before.\nthe filtered moons/prevent same moon configs don't affect moons that are routed to directly.\nfalse will disable the key terminal command, won't show the key when routing to a random moon, won't save moons to the previous 10 moons list");
		cfg_kcd = ((BaseUnityPlugin)this).Config.Bind<int>("#", "default_credits", 1000, "[Default Credits]\nthe default starting amount of credits that a moon will cost");
		cfg_kcr = ((BaseUnityPlugin)this).Config.Bind<int>("#", "random_credits", 90, "[Random Credits]\nthe maximum amount of credits that the default cost can be raised/lowered by. (40% raise, 60% lower)\n(multiplied by 10, so a config value of 90 would be 900 credits)");
		cfg_pri = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "print", false, "[Print to Console]\nprint statements in console for debugging");
		cfg_tst = ((BaseUnityPlugin)this).Config.Bind<bool>("#", "test", false, "[test config]\ntest config");
		mls = Logger.CreateLogSource("Random Moons");
		harmony.PatchAll();
	}
}
[HarmonyPatch(typeof(Terminal))]
internal class t
{
	public static TerminalNode _node;

	public static TerminalKeyword _word;

	public static TerminalKeyword _modifier;

	public static TerminalKeyword _key;

	public static TerminalNode _key_select;

	public static TerminalNode _key_confirm;

	public static TerminalNode _error;

	public static TerminalNode _cancel;

	public static uint typed_key = 0u;

	public static string text3 = (c.cfg_cmm.Value ? " challenge " : " ");

	public static string text1 = "Route the autopilot to a random" + text3 + "moon.\n\nPlease CONFIRM or DENY.\n\n";

	public static string text2 = "Randomizer\n----------------------\n\n";

	public static string gold_key;

	public static TerminalKeyword route;

	[HarmonyPostfix]
	[HarmonyPatch("Awake")]
	private static void pst1(Terminal __instance)
	{
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Expected O, but got Unknown
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Expected O, but got Unknown
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Expected O, but got Unknown
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Expected O, but got Unknown
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Expected O, but got Unknown
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Expected O, but got Unknown
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Expected O, but got Unknown
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Expected O, but got Unknown
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Expected O, but got Unknown
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Expected O, but got Unknown
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Expected O, but got Unknown
		//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Expected O, but got Unknown
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Expected O, but got Unknown
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Expected O, but got Unknown
		//IL_033f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Expected O, but got Unknown
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Expected O, but got Unknown
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Expected O, but got Unknown
		//IL_038e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Expected O, but got Unknown
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b1: Expected O, but got Unknown
		//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d1: Expected O, but got Unknown
		//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03da: Expected O, but got Unknown
		//IL_0414: Unknown result type (might be due to invalid IL or missing references)
		//IL_041b: Expected O, but got Unknown
		//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b4: Expected O, but got Unknown
		//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04de: Expected O, but got Unknown
		//IL_057b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0582: Expected O, but got Unknown
		//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b4: Expected O, but got Unknown
		//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bd: Expected O, but got Unknown
		print("1.0");
		if (!((Object)(object)_node != (Object)null))
		{
			print("1.1");
			gold_key = __instance.terminalNodes.allKeywords.First((TerminalKeyword _) => ((Object)_).name == "Moons").specialKeywordResult.displayText;
			TerminalNode specialKeywordResult = __instance.terminalNodes.allKeywords.First((TerminalKeyword _) => ((Object)_).name == "Moons").specialKeywordResult;
			specialKeywordResult.displayText = specialKeywordResult.displayText + "* Randomizer   //   Random" + text3 + "moons\n\n";
			route = __instance.terminalNodes.allKeywords.First((TerminalKeyword _) => ((Object)_).name == "Route");
			TerminalKeyword val = __instance.terminalNodes.allKeywords.First((TerminalKeyword _) => ((Object)_).name == "Info");
			TerminalNode val2 = new TerminalNode();
			((Object)val2).name = "randomizer_select";
			val2.displayText = text1;
			val2.clearPreviousText = true;
			val2.overrideOptions = true;
			CompatibleNoun[] array = (CompatibleNoun[])(object)new CompatibleNoun[2];
			CompatibleNoun[] array2 = array;
			CompatibleNoun val3 = new CompatibleNoun();
			TerminalNode val4 = new TerminalNode();
			val4.displayText = "You have cancelled the order.\n\n";
			val3.result = val4;
			TerminalKeyword val5 = new TerminalKeyword();
			val5.word = "deny";
			val3.noun = val5;
			array2[0] = val3;
			CompatibleNoun[] array3 = array;
			CompatibleNoun val6 = new CompatibleNoun();
			TerminalNode val7 = new TerminalNode();
			((Object)val7).name = "randomizer_confirm";
			val7.displayText = "Routing autopilot to [name].\n" + (c.cfg_key.Value ? "Key is [key].\n\n" : "\n") + "Good luck.\n\n";
			val7.clearPreviousText = true;
			val6.result = val7;
			TerminalKeyword val8 = new TerminalKeyword();
			val8.word = "confirm";
			val6.noun = val8;
			array3[1] = val6;
			val2.terminalOptions = array;
			_node = val2;
			TerminalKeyword val9 = new TerminalKeyword();
			val9.word = "randomizer";
			val9.specialKeywordResult = _node;
			val9.defaultVerb = route;
			_word = val9;
			TerminalKeyword val10 = new TerminalKeyword();
			val10.word = "modifiers";
			val10.isVerb = true;
			array = (CompatibleNoun[])(object)new CompatibleNoun[1];
			CompatibleNoun[] array4 = array;
			CompatibleNoun val11 = new CompatibleNoun();
			TerminalNode val12 = new TerminalNode();
			((Object)val12).name = "randomizer_modifier";
			val12.displayText = "temp\n\n";
			val12.clearPreviousText = true;
			val11.result = val12;
			val11.noun = _word;
			array4[0] = val11;
			val10.compatibleNouns = array;
			_modifier = val10;
			TerminalKeyword val13 = new TerminalKeyword();
			val13.word = "key";
			val13.isVerb = true;
			array = (CompatibleNoun[])(object)new CompatibleNoun[1];
			CompatibleNoun[] array5 = array;
			CompatibleNoun val14 = new CompatibleNoun();
			TerminalNode val15 = new TerminalNode();
			((Object)val15).name = "randomizer_key_prompt";
			val15.displayText = "Enter an eight digit key.\n\n";
			val15.clearPreviousText = true;
			val15.maxCharactersToType = 9;
			CompatibleNoun[] array6 = (CompatibleNoun[])(object)new CompatibleNoun[1];
			CompatibleNoun val16 = new CompatibleNoun();
			TerminalNode val17 = new TerminalNode();
			((Object)val17).name = "randomizer_key_select";
			val17.displayText = "select\n\n";
			val17.clearPreviousText = true;
			val17.overrideOptions = true;
			CompatibleNoun[] array7 = (CompatibleNoun[])(object)new CompatibleNoun[2];
			CompatibleNoun val18 = new CompatibleNoun();
			TerminalNode val19 = new TerminalNode();
			val19.displayText = "You have cancelled the order.\n\n";
			val18.result = val19;
			TerminalKeyword val20 = new TerminalKeyword();
			val20.word = "deny";
			val18.noun = val20;
			array7[0] = val18;
			CompatibleNoun val21 = new CompatibleNoun();
			TerminalNode val22 = new TerminalNode();
			((Object)val22).name = "randomizer_key_confirm";
			val22.displayText = "confirm\n\n";
			val22.clearPreviousText = true;
			val22.buyRerouteToMoon = -1;
			val22.itemCost = 0;
			val21.result = val22;
			TerminalKeyword val23 = new TerminalKeyword();
			val23.word = "confirm";
			val21.noun = val23;
			array7[1] = val21;
			val17.terminalOptions = array7;
			val16.result = val17;
			array6[0] = val16;
			val15.terminalOptions = array6;
			val15.acceptAnything = true;
			val14.result = val15;
			val14.noun = _word;
			array5[0] = val14;
			val13.compatibleNouns = array;
			_key = val13;
			_key_select = _key.compatibleNouns[0].result.terminalOptions[0].result;
			_key_confirm = _key_select.terminalOptions[1].result;
			TerminalNode val24 = new TerminalNode();
			val24.displayText = "Error\n\n";
			val24.clearPreviousText = true;
			val24.playSyncedClip = 1;
			_error = val24;
			TerminalNode val25 = new TerminalNode();
			val25.displayText = "[Cancelled.]\n\n";
			val25.clearPreviousText = true;
			_cancel = val25;
			__instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, _word);
			__instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, _modifier);
			if (c.cfg_key.Value)
			{
				__instance.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(__instance.terminalNodes.allKeywords, _key);
			}
			TerminalKeyword obj = route;
			CompatibleNoun[] compatibleNouns = route.compatibleNouns;
			CompatibleNoun val26 = new CompatibleNoun();
			val26.result = _node;
			val26.noun = _word;
			obj.compatibleNouns = CollectionExtensions.AddToArray<CompatibleNoun>(compatibleNouns, val26);
			CompatibleNoun[] compatibleNouns2 = val.compatibleNouns;
			CompatibleNoun val27 = new CompatibleNoun();
			TerminalNode val28 = new TerminalNode();
			((Object)val28).name = "randomizer_info";
			val28.displayText = text2;
			val28.clearPreviousText = true;
			val27.result = val28;
			val27.noun = _word;
			val.compatibleNouns = CollectionExtensions.AddToArray<CompatibleNoun>(compatibleNouns2, val27);
		}
	}

	[HarmonyPatch("OnSubmit")]
	[HarmonyPrefix]
	private static void pre1(Terminal __instance)
	{
		if (!__instance.terminalInUse || !(((Object)__instance.currentNode).name == "randomizer_key_prompt"))
		{
			return;
		}
		print("2.1");
		if (__instance.textAdded != 0)
		{
			print("2.2");
			string text = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).ToLower().Replace(" ", "");
			if (text.Length <= 8 && text.All(((IEnumerable<char>)"0123456789abcdef").Contains<char>) && text.Replace("0", "") != "")
			{
				print("2.3");
				uint num = Convert.ToUInt32(text, 16);
				Shion shion = new Shion(num + 350);
				_key_confirm.itemCost = c.cfg_kcd.Value - shion.next32mm(0, c.cfg_kcr.Value + 1) * 10 * ((shion.next32mm(0, 10) >= 4) ? 1 : (-1));
				if (_key_confirm.itemCost < 100)
				{
					_key_confirm.itemCost = ((!c.cfg_tst.Value) ? 100 : 0);
				}
				gnm.k = num;
				_key_confirm.displayText = GameNetworkManager.Instance.GetNameForWeekNumber(-1);
				_key_select.displayText = ((StartOfRound.Instance.connectedPlayersAmount + 1 > 1) ? "! Ship will automatically start !\n\n" : "") + "The cost to route to " + _key_confirm.displayText + " is $" + _key_confirm.itemCost + ".\n\nPlease CONFIRM or DENY.\n\n";
				if (GameNetworkManager.Instance.isHostingGame)
				{
					print("2.4");
					Shion shion2 = new Shion(num + 11);
					int num2 = 3;
					while (num2 == 3 || num2 == 11)
					{
						num2 = shion2.next32mm(0, StartOfRound.Instance.levels.Length);
					}
					_key_confirm.buyRerouteToMoon = num2;
					typed_key = num;
				}
				else
				{
					print("2.5");
					_key_confirm.buyRerouteToMoon = -1;
					_key_confirm.itemCost = 0;
				}
			}
			else
			{
				print("2.6");
				_error.displayText = __instance.currentNode.displayText + "[Invalid hexidecimal key.]\nKey characters must be (0123456789ABCDEF), cannot be only 0's, cannot exceed eight digits.\n\n";
				__instance.LoadNewNode(_error);
				__instance.textAdded = 0;
			}
		}
		else
		{
			print("2.7");
			_cancel.displayText = __instance.currentNode.displayText + "[Cancelled.]\n\n";
			__instance.LoadNewNode(_cancel);
			__instance.textAdded = 0;
		}
	}

	[HarmonyPatch("LoadNewNodeIfAffordable")]
	[HarmonyPrefix]
	private static void pre2(Terminal __instance, ref TerminalNode node, ref int ___groupCredits)
	{
		if (!(((Object)node).name == "randomizer_key_confirm") || !GameNetworkManager.Instance.isHostingGame || __instance.useCreditsCooldown || ___groupCredits < _key_confirm.itemCost || _key_confirm.buyRerouteToMoon == -1 || node.isConfirmationNode)
		{
			return;
		}
		print("3.1");
		StartOfRound val = Object.FindObjectOfType<StartOfRound>();
		if (!val.inShipPhase || val.travellingToNewLevel || val.isChallengeFile || !((Object)(object)val.levels[_key_confirm.buyRerouteToMoon] != (Object)(object)val.currentLevel))
		{
			return;
		}
		print("3.2");
		_key_confirm.displayText = "Routing autopilot to " + _key_confirm.displayText + ".\nYour new balance is $" + (___groupCredits - _key_confirm.itemCost) + ".\n\n" + ((new Shion().next32mm(0, 2) == 1) ? "Good luck.\n\n" : "Please enjoy your flight.\n\n");
		c.key = typed_key;
		c.chosen = true;
		gnm.k = c.key;
		string nameForWeekNumber = GameNetworkManager.Instance.GetNameForWeekNumber(-1);
		if (!c.keys.Contains(nameForWeekNumber))
		{
			print("3.3");
			string text = c.key.ToString("X8");
			if (text.Length > 4)
			{
				text = text.Insert(4, " ");
			}
			c.mls.LogMessage((object)("Key " + text));
			Shion shion = new Shion(c.key + 350);
			int num = c.cfg_kcd.Value - shion.next32mm(0, c.cfg_kcr.Value + 1) * 10 * ((shion.next32mm(0, 10) >= 4) ? 1 : (-1));
			if (num < 100)
			{
				num = ((!c.cfg_tst.Value) ? 100 : 0);
			}
			c.keys = c.keys + text + " " + nameForWeekNumber.PadRight(10, ' ') + " $" + num + "\n";
			if (c.keys.Length - c.keys.Replace("\n", "").Length > 10)
			{
				c.keys = c.keys.Substring(c.keys.IndexOf("\n") + 1);
			}
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch("LoadNewNode")]
	private static void pre3(Terminal __instance, ref TerminalNode node)
	{
		if (((Object)node).name == "randomizer_select")
		{
			print("4.1");
			if (StartOfRound.Instance.connectedPlayersAmount + 1 > 1)
			{
				print("4.2");
				node.displayText = "! Ship will automatically start !\n\n" + text1;
			}
			else
			{
				print("4.3");
				node.displayText = text1;
			}
		}
		else if (((Object)node).name == "randomizer_info")
		{
			print("4.4");
			string text = "";
			for (int i = 0; i < StartOfRound.Instance.levels.Length; i++)
			{
				if (text != "")
				{
					text += ", ";
				}
				text = text + "[" + StartOfRound.Instance.levels[i].PlanetName + "]";
			}
			c.mls.LogMessage((object)text);
			node.displayText = text2 + (c.cfg_key.Value ? ">Key\nTo route directly to a moon with an entered key.\n\n" : "") + ">Modifiers\nTo toggle the challenge moon modifiers config.\n\nMoons List: " + text + "\n\n";
		}
		else if (((Object)node).name == "randomizer_modifier" && GameNetworkManager.Instance.isHostingGame)
		{
			print("4.5");
			c.cfg_cmm.Value = !c.cfg_cmm.Value;
			text3 = (c.cfg_cmm.Value ? " challenge " : " ");
			text1 = "Route the autopilot to a random" + text3 + "moon.\n\nPlease CONFIRM or DENY.\n\n";
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords.First((TerminalKeyword _) => ((Object)_).name == "Moons").specialKeywordResult.displayText = gold_key + "* Randomizer   //   Random" + text3 + "moons\n\n";
			node.displayText = "Challenge moon modifiers set from " + (!c.cfg_cmm.Value).ToString().ToLower() + " to " + c.cfg_cmm.Value.ToString().ToLower() + ".\n\n";
		}
		else if (((Object)node).name == "randomizer_key_prompt")
		{
			print("4.6");
			if (c.keys != "")
			{
				print("4.7");
				node.displayText = "Enter an eight digit key. Press enter with nothing typed to cancel.\n\nKeys of the previous 10 moons:\n" + c.keys + "\n";
			}
			else
			{
				print("4.8");
				node.displayText = "Enter an eight digit key. Press enter with nothing typed to cancel.\n\n";
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch("LoadNewNode")]
	private static void pst2(Terminal __instance, ref TerminalNode node, ref int ___groupCredits)
	{
		if (((Object)node).name == "randomizer_confirm")
		{
			print("5.1");
			if (GameNetworkManager.Instance.isHostingGame)
			{
				print("5.2");
				StartOfRound val = Object.FindObjectOfType<StartOfRound>();
				if (val.inShipPhase && !val.travellingToNewLevel)
				{
					print("5.3");
					if (!val.isChallengeFile)
					{
						print("5.4");
						c.chosen = true;
						val.ChangeLevelServerRpc(moons.list(c.cfg_psm.Value, misc: false, display_key: true), ___groupCredits);
					}
					else
					{
						print("5.5");
						__instance.LoadNewNode(__instance.terminalNodes.specialNodes[24]);
					}
				}
				else
				{
					print("5.6");
					__instance.LoadNewNode(__instance.terminalNodes.specialNodes[3]);
				}
			}
			else
			{
				print("5.7");
				_error.displayText = "[Unable to use randomizer while not host.]\n\n";
				__instance.LoadNewNode(_error);
			}
		}
		else if (((Object)node).name == "randomizer_modifier" && !GameNetworkManager.Instance.isHostingGame)
		{
			print("5.8");
			_error.displayText = "[Unable to use randomizer while not host.]\n\n";
			__instance.LoadNewNode(_error);
		}
		else if (((Object)node).name == "randomizer_key_confirm" && !GameNetworkManager.Instance.isHostingGame)
		{
			print("5.9");
			_error.displayText = "[Unable to use randomizer while not host.]\n\n";
			__instance.LoadNewNode(_error);
		}
		else if (((Object)node).name == "MoonsCatalogue")
		{
			add(__instance);
		}
	}

	private static async void add(Terminal __instance)
	{
		print("6.0");
		await Task.Delay(1);
		string text2 = __instance.currentText;
		if (text2.Contains("PREVIEW:") || text2.Contains("╔"))
		{
			print("6.1");
			string text3 = ((!text2.Contains("╔")) ? "* u___" : (text2.Contains("PREVIEW:") ? "\n\n u---" : " u---"));
			text2 = (__instance.currentText = text2.Insert((from Match _ in Regex.Matches(text2, "\n" + text3.Split(new char[1] { 'u' })[1])
				select _.Index).ToList().Last(), text3.Split(new char[1] { 'u' })[0] + "Randomizer   //   Random" + t.text3 + "moons\n"));
			__instance.screenText.text = text2;
		}
	}

	private static void print(string _)
	{
		if (c.cfg_pri.Value)
		{
			c.mls.LogInfo((object)("Terminal:" + _));
		}
	}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class sor
{
	private static string current_name = "name";

	private static string current_color = "ffffff";

	private static bool temp1 = false;

	private static bool temp2 = false;

	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	private static void pst1(StartOfRound __instance)
	{
		print("1.0");
		c.chosen = false;
		c.real = (StartOfRound.Instance.isChallengeFile ? 1 : 0);
		if (!c.cfg_slm.Value || c.real == 1 || !GameNetworkManager.Instance.isHostingGame)
		{
			return;
		}
		print("1.1");
		try
		{
			string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
			c.chosen_moon = ES3.Load<bool>("4902.Random_Moons-1", currentSaveFileName, false);
			c.key = ES3.Load<uint>("4902.Random_Moons-5", currentSaveFileName, 0u);
			c.keys = ES3.Load<string>("4902.Random_Moons-6", currentSaveFileName, "");
			if (c.chosen_moon)
			{
				print("1.2");
				c.moon_n = ES3.Load<string>("4902.Random_Moons-2", currentSaveFileName, "name");
				c.moon_c = ES3.Load<string>("4902.Random_Moons-3", currentSaveFileName, "ffffff");
				c.moon_d = ES3.Load<string>("4902.Random_Moons-4", currentSaveFileName, "description");
				current_name = c.moon_n;
				current_color = c.moon_c;
				((TMP_Text)__instance.screenLevelDescription).text = moons.create_description(c.moon_n, c.moon_c, c.moon_d, disable_video: true);
			}
		}
		catch (Exception ex)
		{
			c.mls.LogError((object)("Error while trying to load game values when connecting as host: " + ex));
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch("ChangeLevel")]
	private static void pst2()
	{
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		print("2.0");
		pcb.stars = new string[3] { "name", "ffffff", "description" };
		bool[] presets = new bool[3];
		pcb.presets = presets;
		if (c.chosen)
		{
			print("2.1");
			c.moon_n = GameNetworkManager.Instance.GetNameForWeekNumber(-1);
			c.moon_c = ColorUtility.ToHtmlStringRGB(moons.color(0f, 1f, 0.8f, 0.8f, 1f, 1f));
			c.moon_d = StartOfRound.Instance.levels[moons.list(compare_previous: false, misc: true)].LevelDescription;
			if (c.cfg_ltn.Value || StartOfRound.Instance.connectedPlayersAmount + 1 > 1)
			{
				print("2.2");
				string text = (c.cfg_mcc.Value ? c.moon_c : "FFFF00");
				string text2 = ((c.key == t.typed_key) ? "" : " random");
				HUDManager.Instance.AddTextToChatOnServer("</color><color=#FF0000>Routing to" + text2 + t.text3 + "moon:</color>\n<size=14><color=#" + text + ">" + c.moon_n + "</color></size>", -1);
				c.mls.LogMessage((object)("Routing to" + text2 + t.text3 + "moon " + c.moon_n + "(" + c.moon_c + ")"));
			}
			if (StartOfRound.Instance.connectedPlayersAmount + 1 > 1)
			{
				print("2.3");
				pcb.host_send_all();
			}
		}
		else
		{
			print("2.4");
			c.key = 0u;
		}
		c.chosen_moon = c.chosen;
	}

	[HarmonyPatch("ArriveAtLevel")]
	[HarmonyPrefix]
	private static void pre1()
	{
		print("3.0");
		if (c.chosen)
		{
			print("3.1");
			temp1 = true;
		}
		c.chosen = false;
	}

	[HarmonyPostfix]
	[HarmonyPatch("ArriveAtLevel")]
	private static void pst3(StartOfRound __instance)
	{
		arrive(__instance);
	}

	private static async void arrive(StartOfRound __instance)
	{
		print("4.0");
		if (temp1)
		{
			print("4.1");
			temp1 = false;
			((TMP_Text)__instance.screenLevelDescription).text = moons.create_description(c.moon_n, c.moon_c, c.moon_d, disable_video: true);
			if (StartOfRound.Instance.connectedPlayersAmount + 1 > 1)
			{
				print("4.2");
				StartMatchLever lever = Object.FindObjectOfType<StartMatchLever>();
				await Task.Delay(250);
				lever.PlayLeverPullEffectsServerRpc(true);
				await Task.Delay(1500);
				lever.StartGame();
			}
		}
		else if (pcb.presets[0])
		{
			print("4.3");
			((TMP_Text)__instance.screenLevelDescription).text = moons.create_description(pcb.stars[0], pcb.stars[1], pcb.stars[2], disable_video: true);
			pcb.presets[0] = false;
		}
	}

	[HarmonyPatch("StartGame")]
	[HarmonyPrefix]
	private static void pre2(StartOfRound __instance)
	{
		print("5.0");
		if (!c.chosen_moon)
		{
			return;
		}
		print("5.1");
		__instance.overrideRandomSeed = true;
		if (c.cfg_dsc.Value == 2 && c.moon_n == current_name && c.moon_c == current_color)
		{
			print("5.2");
			__instance.overrideSeedNumber = new Shion(c.key + 8).next32mm(1, 100000000);
		}
		else
		{
			print("5.3");
			if (c.key != 0)
			{
				print("5.4");
				__instance.overrideSeedNumber = new Shion(c.key + 8).next32mm(1, 100000000);
				c.key = 0u;
			}
			else
			{
				print("5.5");
				__instance.overrideSeedNumber = new Shion().next32mm(1, 100000000);
			}
		}
		current_name = c.moon_n;
		current_color = c.moon_c;
	}

	[HarmonyPostfix]
	[HarmonyPatch("StartGame")]
	private static void pst4(StartOfRound __instance)
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Invalid comparison between Unknown and I4
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		print("6.0");
		if (!c.chosen_moon)
		{
			return;
		}
		print("6.2");
		__instance.overrideRandomSeed = false;
		if (c.cfg_cmm.Value)
		{
			print("6.3");
			__instance.isChallengeFile = true;
		}
		if (c.cfg_wet.Value && (c.cfg_ltw.Value || StartOfRound.Instance.connectedPlayersAmount + 1 > 1))
		{
			print("6.4");
			string text = (((int)__instance.currentLevel.currentWeather == -1) ? "none" : ("Weather: " + __instance.currentLevel.currentWeather));
			if (text != "none")
			{
				print("6.5");
				HUDManager.Instance.AddTextToChatOnServer("</color><color=#C0C0C0>" + text + "</color>", -1);
				c.mls.LogMessage((object)text);
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch("ShipLeave")]
	private static void pre3()
	{
		print("7.0");
		if (c.cfg_cmm.Value && GameNetworkManager.Instance.isHostingGame && c.real != 1)
		{
			print("7.1");
			StartOfRound.Instance.isChallengeFile = false;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch("PassTimeToNextDay")]
	private static void pst5(StartOfRound __instance)
	{
		print("8.0");
		if (c.chosen_moon)
		{
			print("8.1");
			((TMP_Text)__instance.screenLevelDescription).text = moons.create_description(c.moon_n, c.moon_c, c.moon_d, disable_video: true);
		}
		else if (pcb.presets[2])
		{
			print("8.2");
			((TMP_Text)__instance.screenLevelDescription).text = moons.create_description(pcb.stars[0], pcb.stars[1], pcb.stars[2], disable_video: true);
			bool[] presets = new bool[3];
			pcb.presets = presets;
		}
	}

	[HarmonyPatch("SetShipReadyToLand")]
	[HarmonyPrefix]
	private static void pre4(StartOfRound __instance)
	{
		print("9.0");
		if (c.cfg_dsc.Value == 3 && c.chosen_moon && !__instance.travellingToNewLevel && c.real != 1 && GameNetworkManager.Instance.isHostingGame)
		{
			print("9.1");
			temp2 = true;
			c.chosen_moon = false;
			__instance.currentLevel = __instance.levels[3];
			__instance.currentLevelID = 3;
			TimeOfDay.Instance.currentLevel = __instance.currentLevel;
			RoundManager.Instance.currentLevel = __instance.currentLevel;
		}
	}

	[HarmonyPatch("SetShipReadyToLand")]
	[HarmonyPostfix]
	private static void pst6(StartOfRound __instance)
	{
		print("10.0");
		if (c.cfg_dsc.Value == 3 && temp2 && __instance.inShipPhase && !__instance.travellingToNewLevel && c.real != 1 && GameNetworkManager.Instance.isHostingGame)
		{
			print("10.1");
			temp2 = false;
			__instance.ChangeLevelServerRpc(3, Object.FindObjectOfType<Terminal>().groupCredits);
		}
	}

	private static void print(string _)
	{
		if (c.cfg_pri.Value)
		{
			c.mls.LogInfo((object)("StartOfRound:" + _));
		}
	}
}
[HarmonyPatch(typeof(RoundManager))]
internal class rm
{
	[HarmonyPatch("SetChallengeFileRandomModifiers")]
	private static void Postfix(RoundManager __instance)
	{
		print("1.0");
		if (c.cfg_cmm.Value && c.chosen_moon && c.real != 1 && StartOfRound.Instance.connectedPlayersAmount + 1 > 1 && GameNetworkManager.Instance.isHostingGame)
		{
			print("1.1");
			__instance.increasedMapPropSpawnRateIndex = -1;
		}
	}

	private static void print(string _)
	{
		if (c.cfg_pri.Value)
		{
			c.mls.LogInfo((object)("RoundManager:" + _));
		}
	}
}
[HarmonyPatch(typeof(OutOfBoundsTrigger))]
internal class ote
{
	[HarmonyPatch("OnTriggerEnter")]
	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		List<CodeInstruction> list = instructions.ToList();
		for (int i = 0; i < list.Count; i++)
		{
			if (list[i].opcode == OpCodes.Ldfld && list[i].operand != null && list[i].operand.ToString() == "System.Boolean isChallengeFile")
			{
				list[i - 1].opcode = OpCodes.Nop;
				list[i].opcode = OpCodes.Nop;
				list[i + 1].opcode = OpCodes.Nop;
				break;
			}
		}
		return list;
	}
}
[HarmonyPatch(typeof(Animator))]
internal class uea
{
	[HarmonyPatch("SetTrigger", new Type[] { typeof(string) })]
	private static void Postfix(ref string name)
	{
		wait(name);
	}

	private static async void wait(string name)
	{
		if (name == "introAnimation" && (c.chosen_moon || pcb.presets[1]))
		{
			print("1.1");
			await Task.Delay(10);
			string moon = (c.cfg_mdn.Value ? StartOfRound.Instance.currentLevel.PlanetName : (c.chosen_moon ? c.moon_n : pcb.stars[0]));
			((TMP_Text)HUDManager.Instance.planetInfoHeaderText).text = "CELESTIAL BODY: " + moon;
			if (pcb.presets[1])
			{
				print("1.2");
				pcb.presets = new bool[3]
				{
					false,
					false,
					pcb.presets[2]
				};
			}
		}
	}

	private static void print(string _)
	{
		if (c.cfg_pri.Value)
		{
			c.mls.LogInfo((object)("UnityEngine.Animator:" + _));
		}
	}
}
[HarmonyPatch(typeof(GameNetworkManager))]
internal class gnm
{
	public static uint k = 0u;

	[HarmonyPatch("GetWeekNumber")]
	private static bool Prefix(ref int __result)
	{
		if (k != 0)
		{
			print("1.1");
			__result = new Shion(k + 493).next32mm(0, 100000000) - 51016;
			k = 0u;
			return false;
		}
		if (c.chosen || c.chosen_moon)
		{
			print("1.2");
			__result = new Shion(c.key + 493).next32mm(0, 100000000) - 51016;
			return false;
		}
		return true;
	}

	[HarmonyPatch("SaveGame")]
	[HarmonyPostfix]
	private static void pst1(GameNetworkManager __instance)
	{
		print("2.0");
		if (!c.cfg_slm.Value || c.real == 1 || !StartOfRound.Instance.inShipPhase || !__instance.isHostingGame)
		{
			return;
		}
		try
		{
			StartOfRound val = Object.FindObjectOfType<StartOfRound>();
			if ((Object)(object)val != (Object)null)
			{
				print("2.1");
				ES3.Save<bool>("4902.Random_Moons-1", c.chosen_moon, __instance.currentSaveFileName);
				ES3.Save<uint>("4902.Random_Moons-5", c.key, __instance.currentSaveFileName);
				ES3.Save<string>("4902.Random_Moons-6", c.keys, __instance.currentSaveFileName);
				if (c.chosen_moon)
				{
					print("2.2");
					ES3.Save<string>("4902.Random_Moons-2", c.moon_n, __instance.currentSaveFileName);
					ES3.Save<string>("4902.Random_Moons-3", c.moon_c, __instance.currentSaveFileName);
					ES3.Save<string>("4902.Random_Moons-4", c.moon_d, __instance.currentSaveFileName);
				}
			}
		}
		catch (Exception ex)
		{
			c.mls.LogError((object)("Error while trying to save game values when disconnecting as host: " + ex));
		}
	}

	[HarmonyPatch("Disconnect")]
	[HarmonyPostfix]
	private static void pst2()
	{
		print("3.0");
		c.chosen = false;
		c.chosen_moon = false;
		c.real = -1;
		c.key = 0u;
		c.keys = "";
		t.typed_key = 0u;
		pcb.stars = new string[3] { "name", "ffffff", "description" };
		bool[] presets = new bool[3];
		pcb.presets = presets;
		pcb.sync = false;
		if ((Object)(object)StartOfRound.Instance != (Object)null)
		{
			print("3.1");
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler("4902.Random_Moons-Host");
			NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler("4902.Random_Moons-Client");
		}
	}

	private static void print(string _)
	{
		if (c.cfg_pri.Value)
		{
			c.mls.LogInfo((object)("GameNetworkManager:" + _));
		}
	}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class pcb
{
	public static string[] stars = new string[3] { "name", "ffffff", "description" };

	public static bool[] presets;

	public static bool sync;

	private static bool overwrite;

	[HarmonyPatch("ConnectClientToPlayerObject")]
	private static void Postfix()
	{
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Expected O, but got Unknown
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Expected O, but got Unknown
		print("1.0");
		if (overwrite)
		{
			print("1.1");
			t.text3 = (c.cfg_cmm.Value ? " challenge " : " ");
			t.text1 = "Route the autopilot to a random" + t.text3 + "moon.\n\nPlease CONFIRM or DENY.\n\n";
			Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords.First((TerminalKeyword _) => ((Object)_).name == "Moons").specialKeywordResult.displayText = t.gold_key + "* Randomizer   //   Random" + t.text3 + "moons\n\n";
			overwrite = false;
		}
		if (!sync)
		{
			print("1.2");
			if (NetworkManager.Singleton.IsHost)
			{
				print("1.3");
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("4902.Random_Moons-Host", new HandleNamedMessageDelegate(host_receive));
			}
			else
			{
				print("1.4");
				c.mls.LogInfo((object)"requesting message from host");
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("4902.Random_Moons-Client", new HandleNamedMessageDelegate(client_receive));
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(0, (Allocator)2, -1);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("4902.Random_Moons-Host", 0uL, val, (NetworkDelivery)3);
				((FastBufferWriter)(ref val)).Dispose();
			}
			sync = true;
		}
	}

	private static void host_receive(ulong id, FastBufferReader r)
	{
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		print("2.0");
		if (NetworkManager.Singleton.IsHost)
		{
			print("2.1");
			try
			{
				c.mls.LogInfo((object)"received request from client");
				string text = ((c.chosen_moon && StartOfRound.Instance.inShipPhase) ? "1^" : "0^") + c.cfg_cmm.Value.ToString().ToLower() + "^" + c.moon_n + "^" + c.moon_c + "^" + c.moon_d.Replace("^", "(caret)");
				c.mls.LogInfo((object)("sending message " + text));
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(FastBufferWriter.GetWriteSize(text, false), (Allocator)2, -1);
				((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("4902.Random_Moons-Client", id, val, (NetworkDelivery)3);
				((FastBufferWriter)(ref val)).Dispose();
			}
			catch (Exception ex)
			{
				c.mls.LogError((object)("Error writing strings while syncing: " + ex));
			}
		}
	}

	private static void client_receive(ulong id, FastBufferReader r)
	{
		print("3.0");
		if (!NetworkManager.Singleton.IsClient)
		{
			return;
		}
		print("3.1");
		try
		{
			string text = default(string);
			((FastBufferReader)(ref r)).ReadValueSafe(ref text, false);
			c.mls.LogInfo((object)("client received message: " + text));
			int num = 4;
			if (text.Length - text.Replace("^", "").Length == num)
			{
				print("3.2");
				string[] array = text.Split(new char[1] { '^' }, num + 1);
				stars = new string[3]
				{
					array[2],
					array[3],
					array[4]
				};
				if (array[0] == "1")
				{
					print("3.3");
					if (StartOfRound.Instance.travellingToNewLevel)
					{
						print("3.4");
						presets = new bool[3] { true, true, true };
					}
					else
					{
						print("3.5");
						((TMP_Text)StartOfRound.Instance.screenLevelDescription).text = moons.create_description(stars[0], stars[1], stars[2], disable_video: true);
						presets = new bool[3] { false, true, true };
					}
				}
				t.text3 = ((array[1] == "true") ? " challenge " : " ");
				t.text1 = "Route the autopilot to a random" + t.text3 + "moon.\n\nPlease CONFIRM or DENY.\n\n";
				Object.FindObjectOfType<Terminal>().terminalNodes.allKeywords.First((TerminalKeyword _) => ((Object)_).name == "Moons").specialKeywordResult.displayText = t.gold_key + "* Randomizer   //   Random" + t.text3 + "moons\n\n";
				overwrite = true;
			}
			else
			{
				print("3.6");
				c.mls.LogError((object)"received message was not what was expected. wasn't able to sync variables with host. (are the mod versions not the same?)");
				c.mls.LogError((object)("found " + (text.Length - text.Replace("^", "").Length) + "/" + num + " ^ in message " + text));
			}
		}
		catch (Exception ex)
		{
			c.mls.LogError((object)("Error reading strings while syncing: " + ex));
		}
	}

	public static void host_send_all()
	{
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		print("4.0");
		if (NetworkManager.Singleton.IsHost && c.chosen)
		{
			print("4.1");
			try
			{
				string text = "1^" + c.cfg_cmm.Value.ToString().ToLower() + "^" + c.moon_n + "^" + c.moon_c + "^" + c.moon_d;
				c.mls.LogInfo((object)("sending message to all clients " + text));
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(FastBufferWriter.GetWriteSize(text, false), (Allocator)2, -1);
				((FastBufferWriter)(ref val)).WriteValueSafe(text, false);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("4902.Random_Moons-Client", val, (NetworkDelivery)3);
				((FastBufferWriter)(ref val)).Dispose();
			}
			catch (Exception ex)
			{
				c.mls.LogError((object)("Error writing strings while syncing to all clients: " + ex));
			}
		}
	}

	private static void print(string _)
	{
		if (c.cfg_pri.Value)
		{
			c.mls.LogInfo((object)("PlayerControllerB:" + _));
		}
	}

	static pcb()
	{
		bool[] array = new bool[3];
		presets = array;
		sync = false;
		overwrite = false;
	}
}
internal class moons
{
	public static int list(bool compare_previous = false, bool misc = false, bool display_key = false)
	{
		int num = 3;
		uint num2 = 0u;
		Shion shion = new Shion(c.key + 26);
		for (int i = 1; i <= 4000; i++)
		{
			if (num != 3 && num != 11 && (!compare_previous || num != StartOfRound.Instance.currentLevelID) && (c.cfg_fl1.Value == 1 || misc || c.cfg_fl2.Value.Contains(StartOfRound.Instance.levels[num].PlanetName) != (c.cfg_fl1.Value == 2)))
			{
				break;
			}
			if (!misc)
			{
				num2 = new Shion().next48mm(1u, 4183856184u);
				num = new Shion(num2 + 11).next32mm(0, StartOfRound.Instance.levels.Length);
			}
			else
			{
				num = shion.next32mm(0, StartOfRound.Instance.levels.Length);
			}
			if (i == 4000)
			{
				c.mls.LogError((object)"couldn't find a valid level, routing to gordion");
				c.chosen = false;
				num = 3;
				num2 = 0u;
				break;
			}
		}
		if (num2 != 0 && !misc)
		{
			c.key = num2;
		}
		if (display_key && GameNetworkManager.Instance.isHostingGame)
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			gnm.k = c.key;
			string nameForWeekNumber = GameNetworkManager.Instance.GetNameForWeekNumber(-1);
			string text = val.screenText.text.Replace("[name]", nameForWeekNumber);
			if (c.cfg_key.Value)
			{
				string text2 = c.key.ToString("X8");
				if (text2.Length > 4)
				{
					text2 = text2.Insert(4, " ");
				}
				text = text.Replace("[key]", text2);
				c.mls.LogMessage((object)("Key " + text2));
				if (!c.keys.Contains(nameForWeekNumber))
				{
					Shion shion2 = new Shion(c.key + 350);
					int num3 = c.cfg_kcd.Value - shion2.next32mm(0, c.cfg_kcr.Value + 1) * 10 * ((shion2.next32mm(0, 10) >= 4) ? 1 : (-1));
					if (num3 < 100)
					{
						num3 = ((!c.cfg_tst.Value) ? 100 : 0);
					}
					c.keys = c.keys + text2 + " " + nameForWeekNumber.PadRight(10, ' ') + " $" + num3 + "\n";
					if (c.keys.Length - c.keys.Replace("\n", "").Length > 10)
					{
						c.keys = c.keys.Substring(c.keys.IndexOf("\n") + 1);
					}
				}
			}
			val.currentText = text;
			val.screenText.text = text;
		}
		return num;
	}

	public static string create_description(string _n, string _c, string _d, bool disable_video = false)
	{
		_n = (c.cfg_mcm.Value ? ("Orbiting: </color><color=#" + _c + ">" + _n + "</color>\n") : ("Orbiting: " + _n + "\n"));
		if (!c.cfg_rld.Value)
		{
			_d = "POPULATION: Unknown\nCONDITIONS: Unknown\nFAUNA: Unknown";
		}
		if (disable_video)
		{
			((Behaviour)StartOfRound.Instance.screenLevelVideoReel).enabled = false;
			((Component)StartOfRound.Instance.screenLevelVideoReel).gameObject.SetActive(false);
		}
		return _n + _d;
	}

	public static Color color(float h_min, float h_max, float s_min, float s_max, float v_min, float v_max)
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		Shion shion = new Shion(c.key + 256);
		float num = Mathf.Lerp(h_min, h_max, (float)shion.next01());
		float num2 = Mathf.Lerp(s_min, s_max, (float)shion.next01());
		float num3 = Mathf.Lerp(v_min, v_max, (float)shion.next01());
		Color result = Color.HSVToRGB(num, num2, num3, true);
		result.a = 1f;
		return result;
	}
}
public class Shion
{
	private ulong[] state;

	public Shion()
	{
		RandomNumberGenerator randomNumberGenerator = RandomNumberGenerator.Create();
		byte[] array = new byte[8];
		randomNumberGenerator.GetBytes(array, 0, 8);
		ulong seed = BitConverter.ToUInt64(array, 0);
		xorshift256_init(seed);
	}

	public Shion(ulong seed)
	{
		xorshift256_init(seed);
	}

	public int next32mm(int min, int max)
	{
		uint num = next32();
		double num2 = (double)(max - min) / 4294967295.0;
		return (int)((double)min + (double)num * num2);
	}

	public uint next48mm(uint min, uint max)
	{
		uint num = next32();
		double num2 = (double)(max - min) / 4294967295.0;
		return (uint)((double)min + (double)num * num2);
	}

	public byte[] next8()
	{
		ulong value = xoshiro256ss();
		return BitConverter.GetBytes(value);
	}

	public uint next32()
	{
		byte[] value = next8();
		return BitConverter.ToUInt32(value, 0);
	}

	public ulong next64()
	{
		return xoshiro256ss();
	}

	public double next01()
	{
		ulong num = xoshiro256ss();
		return (double)num / 1.8446744073709552E+19;
	}

	private ulong splitmix64(ulong partialstate)
	{
		partialstate += 11400714819323198485uL;
		partialstate = (partialstate ^ (partialstate >> 30)) * 13787848793156543929uL;
		partialstate = (partialstate ^ (partialstate >> 27)) * 10723151780598845931uL;
		return partialstate ^ (partialstate >> 31);
	}

	private void xorshift256_init(ulong seed)
	{
		ulong[] array = new ulong[4];
		array[0] = splitmix64(seed);
		array[1] = splitmix64(array[0]);
		array[2] = splitmix64(array[1]);
		array[3] = splitmix64(array[2]);
		state = array;
	}

	private ulong rotl64(ulong x, int k)
	{
		return (x << k) | (x >> 64 - k);
	}

	private ulong xoshiro256ss()
	{
		ulong result = rotl64(state[1] * 5, 7) * 9;
		ulong num = state[1] << 17;
		state[2] ^= state[0];
		state[3] ^= state[1];
		state[1] ^= state[2];
		state[0] ^= state[3];
		state[2] ^= num;
		state[3] = rotl64(state[3], 45);
		return result;
	}
}