Decompiled source of RepoSeeded v2.6.0

RepoSeeded.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.UIElements.Collections;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Larsielol")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RepoSeeded")]
[assembly: AssemblyTitle("RepoSeeded")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RepoSeeded
{
	[HarmonyPatch(typeof(EnemyDirector))]
	internal static class EnemyRNGPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("PickEnemies")]
		private static bool EnemyTypeRNGSeeder(List<EnemySetup> _enemiesList)
		{
			Random.InitState(RepoSeeded.EnemyTypeRandom.Next());
			int num = DataDirector.instance.SettingValueFetch((Setting)31);
			ListExtension.Shuffle<EnemySetup>((IList<EnemySetup>)_enemiesList);
			EnemySetup item = null;
			float num2 = -1f;
			foreach (EnemySetup _enemies in _enemiesList)
			{
				if (_enemies.levelsCompletedCondition && (RunManager.instance.levelsCompleted < _enemies.levelsCompletedMin || RunManager.instance.levelsCompleted > _enemies.levelsCompletedMax))
				{
					continue;
				}
				int num3 = 0;
				foreach (EnemySetup item2 in RunManager.instance.enemiesSpawned)
				{
					if ((Object)(object)item2 == (Object)(object)_enemies)
					{
						num3++;
					}
				}
				int num4 = 0;
				foreach (EnemySetup enemy in EnemyDirector.instance.enemyList)
				{
					if ((Object)(object)enemy == (Object)(object)_enemies)
					{
						num4++;
					}
				}
				float num5 = 100f;
				if (Object.op_Implicit((Object)(object)_enemies.rarityPreset))
				{
					num5 = _enemies.rarityPreset.chance;
				}
				float num6 = Mathf.Max(1f, num5 - 30f * (float)num3 - 10f * (float)num4);
				float num7 = Random.Range(0f, num6);
				if (num7 > num2)
				{
					item = _enemies;
					num2 = num7;
				}
			}
			EnemyDirector.instance.enemyListCurrent.Add(item);
			EnemyDirector.instance.enemyList.Add(item);
			RepoSeeded.EnemyOrbRandoms.Clear();
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static bool EnemyIdleRNGGSeeder()
		{
			Random.InitState(RepoSeeded.LevelRandom.Next());
			return true;
		}
	}
	[HarmonyPatch(typeof(SemiFunc))]
	internal static class enemyPingOnMessage
	{
		[HarmonyPrefix]
		[HarmonyPatch("UIBigMessage")]
		private static void RemoveEnemyPingOnText(ref string message, string emoji, float size, Color colorMain, Color colorFlash)
		{
			if (message == "EXTRACTION POINT ACTIVATED")
			{
				message = message.Replace("ACTIVATED", "ENABLED");
			}
		}
	}
	[HarmonyPatch(typeof(RunManager))]
	internal static class LevelAreaRNGPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SetRunLevel")]
		private static void LevelAreaRNGSeeder(ref Level ___previousRunLevel, ref Level ___levelCurrent, int ___levelsCompleted)
		{
			if (___levelsCompleted == 0)
			{
				___previousRunLevel = null;
				___levelCurrent = null;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("ChangeLevel")]
		private static void ShopLevelRNGSeeder()
		{
			if (!RepoSeeded.savedSeedToHistory)
			{
				RepoSeeded.savedSeedToHistory = true;
				SeedHistory.addSeed(RepoSeeded.currentSeed);
			}
			if (!RepoSeeded.JustHijackedTheSave)
			{
				RepoSeeded.saveRandoms();
			}
			else
			{
				RepoSeeded.JustHijackedTheSave = false;
			}
			int seed = RepoSeeded.ShopRandom.Next();
			RepoSeeded.shopTemporaryRandom = new Random(seed);
			int num = RepoSeeded.LevelRandom.Next();
			Random.InitState(num);
		}
	}
	[HarmonyPatch(typeof(LevelGenerator))]
	internal static class LevelLayoutRNGPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void LevelGenerationRNGSeederTiles()
		{
			Random.InitState(RepoSeeded.LevelRandom.Next());
			RepoSeeded.TruckTextRandom = new Random(RepoSeeded.LevelRandom.Next());
		}

		[HarmonyPrefix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void LevelGenerationRNGSeederModules()
		{
			Random.InitState(RepoSeeded.LevelRandom.Next());
		}
	}
	[HarmonyPatch(typeof(EnemyParent))]
	internal static class OrbValueRNGPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Despawn")]
		private static bool RemoveValueRNG(EnemyParent __instance)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Invalid comparison between Unknown and I4
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Invalid comparison between Unknown and I4
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			Random.InitState(RepoSeeded.EnemyOrbRandom.Next());
			if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient)
			{
				return false;
			}
			__instance.Enemy.CurrentState = (EnemyState)11;
			__instance.DespawnedTimer = Random.Range(__instance.DespawnedTimeMin, __instance.DespawnedTimeMax) * EnemyDirector.instance.despawnedDecreaseMultiplier * EnemyDirector.instance.despawnedTimeMultiplier;
			__instance.DespawnedTimer = Mathf.Max(__instance.DespawnedTimer, 1f);
			if (__instance.Enemy.HasRigidbody)
			{
				__instance.Enemy.Rigidbody.grabbed = false;
				__instance.Enemy.Rigidbody.grabStrengthTimer = 0f;
				__instance.Enemy.Rigidbody.GrabRelease(true, 0.1f);
			}
			if (GameManager.Multiplayer())
			{
				((MonoBehaviourPun)__instance).photonView.RPC("DespawnRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				__instance.DespawnRPC(default(PhotonMessageInfo));
			}
			if (!__instance.Enemy.HasHealth || __instance.Enemy.Health.healthCurrent > 0)
			{
				return false;
			}
			if (__instance.Enemy.Health.spawnValuable && __instance.valuableSpawnTimer > 0f && __instance.Enemy.Health.spawnValuableCurrent < __instance.Enemy.Health.spawnValuableMax)
			{
				GameObject val = AssetManager.instance.enemyValuableSmall;
				if ((int)__instance.difficulty == 1)
				{
					val = AssetManager.instance.enemyValuableMedium;
				}
				else if ((int)__instance.difficulty == 2)
				{
					val = AssetManager.instance.enemyValuableBig;
				}
				Transform val2 = __instance.Enemy.CustomValuableSpawnTransform;
				if (!Object.op_Implicit((Object)(object)val2))
				{
					val2 = __instance.Enemy.CenterTransform;
				}
				GameObject val3 = (SemiFunc.IsMultiplayer() ? PhotonNetwork.InstantiateRoomObject("Valuables/" + ((Object)val).name, val2.position, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(val, val2.position, Quaternion.identity));
				EnemyHealth health = __instance.Enemy.Health;
				health.spawnValuableCurrent++;
				ValuableObject component = val3.GetComponent<ValuableObject>();
				Random.InitState(RepoSeeded.EnemyOrbRandoms[__instance].Next());
				component.DollarValueSetLogic();
			}
			__instance.DespawnedTimer *= 3f;
			return false;
		}
	}
	[HarmonyPatch(typeof(LevelGenerator))]
	internal static class AddEnemiesToOrbRNG
	{
		[HarmonyPrefix]
		[HarmonyPatch("EnemySpawn")]
		private static bool getAllEnemiesIntoList(ref EnemySetup enemySetup, ref Vector3 position)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			foreach (PrefabRef spawnObject in enemySetup.spawnObjects)
			{
				GameObject val = ((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)spawnObject).ResourcePath, position, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)spawnObject).Prefab, position, Quaternion.identity));
				EnemyParent component = val.GetComponent<EnemyParent>();
				if (Object.op_Implicit((Object)(object)component))
				{
					RepoSeeded.EnemyOrbRandoms.Add(component, new Random(RepoSeeded.EnemyOrbRandom.Next()));
					component.SetupDone = true;
					val.GetComponentInChildren<Enemy>().EnemyTeleported(position);
					LevelGenerator instance = LevelGenerator.Instance;
					instance.EnemiesSpawnTarget++;
					EnemyDirector.instance.FirstSpawnPointAdd(component);
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(ItemAttributes))]
	internal class RemoveAttributeStartFunctionRNG
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static bool stopStartFunctionRNG()
		{
			if (SemiFunc.RunIsShop())
			{
				Random.InitState(RepoSeeded.ShopRandom.Next());
			}
			return true;
		}
	}
	[BepInPlugin("Larsielol.RepoSeeded", "RepoSeeded", "2.6.0")]
	public class RepoSeeded : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<string> <>9__36_6;

			public static ScrollViewBuilderDelegate <>9__36_4;

			public static ScrollViewBuilderDelegate <>9__36_5;

			public static Action <>9__36_1;

			public static BuilderDelegate <>9__36_0;

			internal void <Start>b__36_0(Transform parent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				REPOButton val = MenuAPI.CreateREPOButton("Seed menu", (Action)delegate
				{
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					//IL_003c: Expected O, but got Unknown
					//IL_0044: Unknown result type (might be due to invalid IL or missing references)
					//IL_0058: Expected O, but got Unknown
					//IL_006d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0072: Unknown result type (might be due to invalid IL or missing references)
					//IL_0078: Expected O, but got Unknown
					//IL_009c: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a7: Expected O, but got Unknown
					//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f9: Expected O, but got Unknown
					<>c__DisplayClass36_0 CS$<>8__locals0 = new <>c__DisplayClass36_0();
					REPOPopupPage val3 = MenuAPI.CreateREPOPopupPage("Seed Menu", (PresetSide)0, false, true, 1.5f);
					CS$<>8__locals0.seedInput = null;
					val3.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
					{
						//IL_003c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0042: Unknown result type (might be due to invalid IL or missing references)
						Action<string> obj4 = delegate(string newSeed)
						{
							setSeed(newSeed);
						};
						string text = (randomizeSeed ? "Random" : currentSeed);
						CS$<>8__locals0.seedInput = MenuAPI.CreateREPOInputField("Seed", obj4, scrollView, default(Vector2), false, "", text);
						return ((REPOElement)CS$<>8__locals0.seedInput).rectTransform;
					}, 0f, 0f);
					val3.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
					{
						//IL_002d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0033: Unknown result type (might be due to invalid IL or missing references)
						Action<bool> obj3 = delegate(bool randomize)
						{
							RepoSeeded.randomizeSeed = randomize;
							CS$<>8__locals0.seedInput.inputStringSystem.SetValue(RepoSeeded.randomizeSeed ? "Random" : currentSeed, false);
						};
						bool randomizeSeed = RepoSeeded.randomizeSeed;
						REPOToggle val8 = MenuAPI.CreateREPOToggle("Randomize seed", obj3, scrollView, default(Vector2), "ON", "OFF", randomizeSeed);
						return ((REPOElement)val8).rectTransform;
					}, 0f, 0f);
					object obj = <>9__36_4;
					if (obj == null)
					{
						ScrollViewBuilderDelegate val4 = delegate(Transform scrollView)
						{
							//IL_0008: Unknown result type (might be due to invalid IL or missing references)
							//IL_000e: Unknown result type (might be due to invalid IL or missing references)
							REPOLabel val7 = MenuAPI.CreateREPOLabel("Recent Seeds", scrollView, default(Vector2));
							return ((REPOElement)val7).rectTransform;
						};
						<>9__36_4 = val4;
						obj = (object)val4;
					}
					val3.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f);
					object obj2 = <>9__36_5;
					if (obj2 == null)
					{
						ScrollViewBuilderDelegate val5 = delegate(Transform scrollView)
						{
							//IL_0008: Unknown result type (might be due to invalid IL or missing references)
							//IL_000e: Unknown result type (might be due to invalid IL or missing references)
							//IL_002f: Unknown result type (might be due to invalid IL or missing references)
							REPOLabel val6 = MenuAPI.CreateREPOLabel("Click to copy", scrollView, default(Vector2));
							((Component)val6).gameObject.transform.localScale = new Vector3(0.6f, 0.6f, 0.6f);
							return ((REPOElement)val6).rectTransform;
						};
						<>9__36_5 = val5;
						obj2 = (object)val5;
					}
					val3.AddElementToScrollView((ScrollViewBuilderDelegate)obj2, 0f, 0f);
					List<string> seeds = SeedHistory.getSeeds();
					for (int num = seeds.Count - 1; num >= 0; num--)
					{
						val3.AddElementToScrollView(new ScrollViewBuilderDelegate(new <>c__DisplayClass36_1
						{
							seed = seeds[num]
						}.<Start>b__8), 0f, 0f);
					}
					val3.OpenPage(false);
				}, parent, new Vector2(50f, 95f));
				Transform val2 = parent.Find("Buttons");
				val2 = ((!((Object)(object)val != (Object)null)) ? parent.Find("Menu Button - Tutorial") : val2.Find("Menu Button - Tutorial"));
				((Component)val2).gameObject.SetActive(false);
			}

			internal void <Start>b__36_1()
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Expected O, but got Unknown
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Expected O, but got Unknown
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Expected O, but got Unknown
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Expected O, but got Unknown
				<>c__DisplayClass36_0 CS$<>8__locals0 = new <>c__DisplayClass36_0();
				REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Seed Menu", (PresetSide)0, false, true, 1.5f);
				CS$<>8__locals0.seedInput = null;
				val.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
				{
					//IL_003c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0042: Unknown result type (might be due to invalid IL or missing references)
					Action<string> obj4 = delegate(string newSeed)
					{
						setSeed(newSeed);
					};
					string text = (randomizeSeed ? "Random" : currentSeed);
					CS$<>8__locals0.seedInput = MenuAPI.CreateREPOInputField("Seed", obj4, scrollView, default(Vector2), false, "", text);
					return ((REPOElement)CS$<>8__locals0.seedInput).rectTransform;
				}, 0f, 0f);
				val.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
				{
					//IL_002d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					Action<bool> obj3 = delegate(bool randomize)
					{
						RepoSeeded.randomizeSeed = randomize;
						CS$<>8__locals0.seedInput.inputStringSystem.SetValue(RepoSeeded.randomizeSeed ? "Random" : currentSeed, false);
					};
					bool randomizeSeed = RepoSeeded.randomizeSeed;
					REPOToggle val6 = MenuAPI.CreateREPOToggle("Randomize seed", obj3, scrollView, default(Vector2), "ON", "OFF", randomizeSeed);
					return ((REPOElement)val6).rectTransform;
				}, 0f, 0f);
				object obj = <>9__36_4;
				if (obj == null)
				{
					ScrollViewBuilderDelegate val2 = delegate(Transform scrollView)
					{
						//IL_0008: Unknown result type (might be due to invalid IL or missing references)
						//IL_000e: Unknown result type (might be due to invalid IL or missing references)
						REPOLabel val5 = MenuAPI.CreateREPOLabel("Recent Seeds", scrollView, default(Vector2));
						return ((REPOElement)val5).rectTransform;
					};
					<>9__36_4 = val2;
					obj = (object)val2;
				}
				val.AddElementToScrollView((ScrollViewBuilderDelegate)obj, 0f, 0f);
				object obj2 = <>9__36_5;
				if (obj2 == null)
				{
					ScrollViewBuilderDelegate val3 = delegate(Transform scrollView)
					{
						//IL_0008: Unknown result type (might be due to invalid IL or missing references)
						//IL_000e: Unknown result type (might be due to invalid IL or missing references)
						//IL_002f: Unknown result type (might be due to invalid IL or missing references)
						REPOLabel val4 = MenuAPI.CreateREPOLabel("Click to copy", scrollView, default(Vector2));
						((Component)val4).gameObject.transform.localScale = new Vector3(0.6f, 0.6f, 0.6f);
						return ((REPOElement)val4).rectTransform;
					};
					<>9__36_5 = val3;
					obj2 = (object)val3;
				}
				val.AddElementToScrollView((ScrollViewBuilderDelegate)obj2, 0f, 0f);
				List<string> seeds = SeedHistory.getSeeds();
				for (int num = seeds.Count - 1; num >= 0; num--)
				{
					val.AddElementToScrollView(new ScrollViewBuilderDelegate(new <>c__DisplayClass36_1
					{
						seed = seeds[num]
					}.<Start>b__8), 0f, 0f);
				}
				val.OpenPage(false);
			}

			internal void <Start>b__36_6(string newSeed)
			{
				setSeed(newSeed);
			}

			internal RectTransform <Start>b__36_4(Transform scrollView)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				REPOLabel val = MenuAPI.CreateREPOLabel("Recent Seeds", scrollView, default(Vector2));
				return ((REPOElement)val).rectTransform;
			}

			internal RectTransform <Start>b__36_5(Transform scrollView)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				REPOLabel val = MenuAPI.CreateREPOLabel("Click to copy", scrollView, default(Vector2));
				((Component)val).gameObject.transform.localScale = new Vector3(0.6f, 0.6f, 0.6f);
				return ((REPOElement)val).rectTransform;
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass36_0
		{
			public REPOInputField seedInput;

			public Action<bool> <>9__7;

			internal RectTransform <Start>b__2(Transform scrollView)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				Action<string> obj = delegate(string newSeed)
				{
					setSeed(newSeed);
				};
				string text = (randomizeSeed ? "Random" : currentSeed);
				seedInput = MenuAPI.CreateREPOInputField("Seed", obj, scrollView, default(Vector2), false, "", text);
				return ((REPOElement)seedInput).rectTransform;
			}

			internal RectTransform <Start>b__3(Transform scrollView)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				Action<bool> obj = delegate(bool randomize)
				{
					RepoSeeded.randomizeSeed = randomize;
					seedInput.inputStringSystem.SetValue(RepoSeeded.randomizeSeed ? "Random" : currentSeed, false);
				};
				bool randomizeSeed = RepoSeeded.randomizeSeed;
				REPOToggle val = MenuAPI.CreateREPOToggle("Randomize seed", obj, scrollView, default(Vector2), "ON", "OFF", randomizeSeed);
				return ((REPOElement)val).rectTransform;
			}

			internal void <Start>b__7(bool randomize)
			{
				randomizeSeed = randomize;
				seedInput.inputStringSystem.SetValue(randomizeSeed ? "Random" : currentSeed, false);
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass36_1
		{
			public string seed;

			public Action <>9__9;

			internal RectTransform <Start>b__8(Transform scrollView)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				REPOButton val = MenuAPI.CreateREPOButton(seed ?? "", (Action)delegate
				{
					GUIUtility.systemCopyBuffer = seed;
				}, scrollView, default(Vector2));
				return ((REPOElement)val).rectTransform;
			}

			internal void <Start>b__9()
			{
				GUIUtility.systemCopyBuffer = seed;
			}
		}

		internal static bool JustHijackedTheSave = true;

		internal static bool savedSeedToHistory = false;

		public static bool randomizeSeed = true;

		internal static Random ValuableTypeRandom = new Random(1);

		internal static Random ValuableCostRandom = new Random(1);

		internal static Random LevelRandom = new Random(1);

		internal static Random ShopRandom = new Random(1);

		internal static Random shopTemporaryRandom = new Random(1);

		internal static Random EnemyTypeRandom = new Random(1);

		internal static Random EnemyOrbRandom = new Random(1);

		internal static Random TruckTextRandom = new Random(1);

		internal static Dictionary<EnemyParent, Random> EnemyOrbRandoms = new Dictionary<EnemyParent, Random>();

		private static string settingsPath = Path.Combine(Paths.ConfigPath, "SeededSettings.txt");

		internal static int ValuableTypeSeed = 1;

		internal static int ValuableCostSeed = 1;

		internal static int LevelSeed = 1;

		internal static int ShopSeed = 1;

		internal static int EnemyTypeSeed = 1;

		internal static int EnemyOrbSeed = 1;

		internal static int TruckTextSeed = 1;

		public static bool isLibrary = false;

		public static string currentSeed = "1";

		internal static RepoSeeded Instance { get; private set; } = null;


		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		public static void setSeed(string seed)
		{
			if (randomizeSeed)
			{
				seed = Random.Range(int.MinValue, int.MaxValue).ToString();
			}
			SHA256 sHA = SHA256.Create();
			currentSeed = seed;
			seed = seed.Replace(" ", "");
			int num = 1;
			try
			{
				num = int.Parse(seed);
			}
			catch (FormatException)
			{
				byte[] array = sHA.ComputeHash(Encoding.UTF8.GetBytes(seed));
				num = BitConverter.ToInt32(array);
			}
			ValuableTypeRandom = new Random(num);
			ValuableCostRandom = new Random(num + 1);
			LevelRandom = new Random(num + 2);
			ShopRandom = new Random(num + 3);
			EnemyTypeRandom = new Random(num + 4);
			EnemyOrbRandom = new Random(num + 5);
			TruckTextRandom = new Random(num + 6);
			if (Object.op_Implicit((Object)(object)RunManager.instance))
			{
				RunManager.instance.enemiesSpawned = new List<EnemySetup>();
			}
		}

		public static void saveRandoms()
		{
			ValuableTypeSeed = ValuableTypeRandom.Next();
			ValuableTypeRandom = new Random(ValuableTypeSeed);
			ValuableCostSeed = ValuableCostRandom.Next();
			ValuableCostRandom = new Random(ValuableCostSeed);
			LevelSeed = LevelRandom.Next();
			LevelRandom = new Random(LevelSeed);
			ShopSeed = ShopRandom.Next();
			ShopRandom = new Random(ShopSeed);
			EnemyTypeSeed = EnemyTypeRandom.Next();
			EnemyTypeRandom = new Random(EnemyTypeSeed);
			EnemyOrbSeed = EnemyOrbRandom.Next();
			EnemyOrbRandom = new Random(EnemyOrbSeed);
		}

		private void Start()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			if (isLibrary)
			{
				return;
			}
			object obj = <>c.<>9__36_0;
			if (obj == null)
			{
				BuilderDelegate val = delegate(Transform parent)
				{
					//IL_002f: Unknown result type (might be due to invalid IL or missing references)
					REPOButton val2 = MenuAPI.CreateREPOButton("Seed menu", (Action)delegate
					{
						//IL_0028: Unknown result type (might be due to invalid IL or missing references)
						//IL_003c: Expected O, but got Unknown
						//IL_0044: Unknown result type (might be due to invalid IL or missing references)
						//IL_0058: Expected O, but got Unknown
						//IL_006d: Unknown result type (might be due to invalid IL or missing references)
						//IL_0072: Unknown result type (might be due to invalid IL or missing references)
						//IL_0078: Expected O, but got Unknown
						//IL_009c: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a7: Expected O, but got Unknown
						//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
						//IL_00f9: Expected O, but got Unknown
						REPOPopupPage val4 = MenuAPI.CreateREPOPopupPage("Seed Menu", (PresetSide)0, false, true, 1.5f);
						REPOInputField seedInput = null;
						val4.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
						{
							//IL_003c: Unknown result type (might be due to invalid IL or missing references)
							//IL_0042: Unknown result type (might be due to invalid IL or missing references)
							Action<string> obj5 = delegate(string newSeed)
							{
								setSeed(newSeed);
							};
							string text = (randomizeSeed ? "Random" : currentSeed);
							seedInput = MenuAPI.CreateREPOInputField("Seed", obj5, scrollView, default(Vector2), false, "", text);
							return ((REPOElement)seedInput).rectTransform;
						}, 0f, 0f);
						val4.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
						{
							//IL_002d: Unknown result type (might be due to invalid IL or missing references)
							//IL_0033: Unknown result type (might be due to invalid IL or missing references)
							Action<bool> obj4 = delegate(bool randomize)
							{
								randomizeSeed = randomize;
								seedInput.inputStringSystem.SetValue(randomizeSeed ? "Random" : currentSeed, false);
							};
							bool flag = randomizeSeed;
							REPOToggle val10 = MenuAPI.CreateREPOToggle("Randomize seed", obj4, scrollView, default(Vector2), "ON", "OFF", flag);
							return ((REPOElement)val10).rectTransform;
						}, 0f, 0f);
						object obj2 = <>c.<>9__36_4;
						if (obj2 == null)
						{
							ScrollViewBuilderDelegate val5 = delegate(Transform scrollView)
							{
								//IL_0008: Unknown result type (might be due to invalid IL or missing references)
								//IL_000e: Unknown result type (might be due to invalid IL or missing references)
								REPOLabel val9 = MenuAPI.CreateREPOLabel("Recent Seeds", scrollView, default(Vector2));
								return ((REPOElement)val9).rectTransform;
							};
							<>c.<>9__36_4 = val5;
							obj2 = (object)val5;
						}
						val4.AddElementToScrollView((ScrollViewBuilderDelegate)obj2, 0f, 0f);
						object obj3 = <>c.<>9__36_5;
						if (obj3 == null)
						{
							ScrollViewBuilderDelegate val6 = delegate(Transform scrollView)
							{
								//IL_0008: Unknown result type (might be due to invalid IL or missing references)
								//IL_000e: Unknown result type (might be due to invalid IL or missing references)
								//IL_002f: Unknown result type (might be due to invalid IL or missing references)
								REPOLabel val8 = MenuAPI.CreateREPOLabel("Click to copy", scrollView, default(Vector2));
								((Component)val8).gameObject.transform.localScale = new Vector3(0.6f, 0.6f, 0.6f);
								return ((REPOElement)val8).rectTransform;
							};
							<>c.<>9__36_5 = val6;
							obj3 = (object)val6;
						}
						val4.AddElementToScrollView((ScrollViewBuilderDelegate)obj3, 0f, 0f);
						List<string> seeds = SeedHistory.getSeeds();
						for (int num = seeds.Count - 1; num >= 0; num--)
						{
							string seed = seeds[num];
							val4.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
							{
								//IL_0031: Unknown result type (might be due to invalid IL or missing references)
								//IL_0037: Unknown result type (might be due to invalid IL or missing references)
								REPOButton val7 = MenuAPI.CreateREPOButton(seed ?? "", (Action)delegate
								{
									GUIUtility.systemCopyBuffer = seed;
								}, scrollView, default(Vector2));
								return ((REPOElement)val7).rectTransform;
							}, 0f, 0f);
						}
						val4.OpenPage(false);
					}, parent, new Vector2(50f, 95f));
					Transform val3 = parent.Find("Buttons");
					val3 = ((!((Object)(object)val2 != (Object)null)) ? parent.Find("Menu Button - Tutorial") : val3.Find("Menu Button - Tutorial"));
					((Component)val3).gameObject.SetActive(false);
				};
				<>c.<>9__36_0 = val;
				obj = (object)val;
			}
			MenuAPI.AddElementToMainMenu((BuilderDelegate)obj);
		}

		private void Awake()
		{
			Instance = this;
			setSeed(currentSeed);
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			List<string> list = new List<string>();
			if (File.Exists(settingsPath))
			{
				list = File.ReadAllLines(settingsPath).ToList();
				if (list.Count > 0 && !bool.TryParse(list[0], out randomizeSeed))
				{
					randomizeSeed = true;
				}
				if (list.Count > 1)
				{
					setSeed(list[1]);
				}
			}
			SeedHistory.ReadSeeds();
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0025: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		internal void OnApplicationQuit()
		{
			List<string> contents = new List<string>
			{
				randomizeSeed.ToString(),
				currentSeed
			};
			File.WriteAllLines(settingsPath, contents);
		}

		private void Update()
		{
		}
	}
	[HarmonyPatch(typeof(UpgradeStand))]
	internal class RerollRNGPatch
	{
		private static Dictionary<string, Random> upgradeRandoms = new Dictionary<string, Random>();

		[HarmonyPrefix]
		[HarmonyPatch("StateRerollOpenHatch")]
		private static void fixRerollRNG()
		{
			Random.InitState(RepoSeeded.shopTemporaryRandom.Next());
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetWeightedUpgradeExcluding")]
		private static bool fixDictRNG(Item excludeItem, Dictionary<string, int> displayedCounts, Dictionary<string, int> selectedDuringReroll, ref Item? __result, bool secondAttempt = false)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Invalid comparison between Unknown and I4
			Item excludeItem2 = excludeItem;
			List<Item> list = new List<Item>();
			foreach (Item item in from i in StatsManager.instance.itemDictionary.Values
				orderby (Object)(object)i == (Object)(object)excludeItem2, i.itemName, i.itemType, i.value.valueMax
				select i)
			{
				if ((int)item.itemType == 3 && (secondAttempt || !(((Object)item).name == ((Object)excludeItem2).name)))
				{
					list.Add(item);
				}
			}
			if (!secondAttempt)
			{
				upgradeRandoms.TryGetValue(((Object)excludeItem2).name, out Random value);
				Random.InitState(value.Next());
			}
			if (list.Count == 0)
			{
				if (!secondAttempt)
				{
					fixDictRNG(excludeItem2, displayedCounts, selectedDuringReroll, ref __result, secondAttempt: true);
					return false;
				}
				__result = null;
				return false;
			}
			if (secondAttempt && list.Count > 1 && list.Contains(excludeItem2))
			{
				list.Remove(excludeItem2);
			}
			__result = list[Random.Range(0, list.Count)];
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("SpawnNewUpgrades")]
		private static bool fixCacheDictRNG(UpgradeStand __instance)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			__instance.cachedUpgrades.Sort(delegate(CachedUpgrade a, CachedUpgrade b)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: 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)
				int num10 = string.Compare(((Object)a.itemData).name, ((Object)b.itemData).name);
				if (num10 == 0)
				{
					num10 = ((Enum)(itemType)(ref a.itemData.itemType)).CompareTo((object?)b.itemData.itemType);
				}
				if (num10 == 0)
				{
					num10 = a.itemData.value.valueMax.CompareTo(b.itemData.value.valueMax);
				}
				return num10;
			});
			Random.InitState(RepoSeeded.shopTemporaryRandom.Next());
			List<Item> list = new List<Item>();
			List<Item> list2 = new List<Item>();
			foreach (CachedUpgrade cachedUpgrade in __instance.cachedUpgrades)
			{
				list.Add(cachedUpgrade.itemData);
				list2.Add(cachedUpgrade.itemData);
			}
			Dictionary<string, int> currentlyDisplayedUpgradeCounts = __instance.GetCurrentlyDisplayedUpgradeCounts(list);
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			int num = 0;
			while (__instance.cachedUpgrades.Count > 0)
			{
				num++;
				for (int i = 0; i < list2.Count; i++)
				{
					Item val = list2[i];
					((Object)val).name = ((Object)val).name.Replace(" SeededReroll", "");
					Item weightedUpgradeExcluding = __instance.GetWeightedUpgradeExcluding(val, currentlyDisplayedUpgradeCounts, dictionary, false);
					if ((Object)(object)weightedUpgradeExcluding != (Object)null)
					{
						list2[i] = weightedUpgradeExcluding;
					}
				}
				bool flag = true;
				for (int j = 0; j < list2.Count; j++)
				{
					Item val2 = list2[j];
					string name = ((Object)val2).name;
					dictionary.TryAdd(name, 0);
					dictionary[name]++;
					int num2 = SemiFunc.StatGetItemsPurchased(name);
					int num3 = (currentlyDisplayedUpgradeCounts.ContainsKey(name) ? currentlyDisplayedUpgradeCounts[name] : 0);
					int num4 = DictionaryExtensions.Get<string, int>((IDictionary<string, int>)dictionary, name, 0) - 1;
					int num5 = num3 + num3 + num4;
					if ((val2.maxAmountInShop <= 0 || num5 < val2.maxAmountInShop) && (!val2.maxPurchase || StatsManager.instance.GetItemsUpgradesPurchasedTotal(name) < val2.maxPurchaseAmount) && (val2.minPlayerCount <= 1 || GameDirector.instance.PlayerList.Count >= val2.minPlayerCount))
					{
						continue;
					}
					bool flag2 = false;
					bool flag3 = false;
					foreach (Item value2 in StatsManager.instance.itemDictionary.Values)
					{
						string name2 = ((Object)value2).name;
						int num6 = SemiFunc.StatGetItemsPurchased(((Object)value2).name);
						int num7 = (currentlyDisplayedUpgradeCounts.ContainsKey(name2) ? currentlyDisplayedUpgradeCounts[name2] : 0);
						int num8 = DictionaryExtensions.Get<string, int>((IDictionary<string, int>)dictionary, ((Object)value2).name, 0);
						int num9 = num7 + num7 + num8;
						if ((value2.maxAmountInShop <= 0 || num9 < value2.maxAmountInShop) && (!value2.maxPurchase || StatsManager.instance.GetItemsUpgradesPurchasedTotal(name2) < value2.maxPurchaseAmount) && (value2.minPlayerCount <= 1 || GameDirector.instance.PlayerList.Count >= value2.minPlayerCount))
						{
							if ((Object)(object)value2 != (Object)(object)val2)
							{
								flag2 = true;
								break;
							}
							flag3 = true;
						}
					}
					if (!flag2 && !flag3)
					{
						list2.RemoveAt(j);
						__instance.cachedUpgrades.RemoveAt(j);
						dictionary[name]--;
						j--;
						continue;
					}
					if (flag3 && !flag2)
					{
						dictionary[name]--;
						int index = j;
						Item value = (list2[j] = Object.Instantiate<Item>(list2[j]));
						list2[index] = value;
						((Object)list2[j]).name = "BLOCKED!";
					}
					else if (flag2)
					{
						dictionary[name]--;
						Item val4 = Object.Instantiate<Item>(list2[j]);
						((Object)val4).name = ((Object)list2[j]).name + " SeededReroll";
						list2[j] = val4;
					}
					flag = false;
				}
				for (int k = 0; k < list2.Count; k++)
				{
					if ((Object)(object)list2[k] == (Object)null || ((Object)list2[k]).name == "BLOCKED!" || ((Object)list2[k]).name.EndsWith(" SeededReroll"))
					{
						continue;
					}
					CachedUpgrade val5 = __instance.cachedUpgrades[k];
					Item val6 = list2[k];
					if ((Object)(object)ShopManager.instance != (Object)null && (Object)(object)ShopManager.instance.itemRotateHelper != (Object)null)
					{
						((Component)ShopManager.instance.itemRotateHelper).transform.parent = ((Component)__instance).transform;
						((Component)ShopManager.instance.itemRotateHelper).transform.position = val5.position;
						((Component)ShopManager.instance.itemRotateHelper).transform.localRotation = val6.spawnRotationOffset;
						Quaternion rotation = ((Component)ShopManager.instance.itemRotateHelper).transform.rotation;
						((Component)ShopManager.instance.itemRotateHelper).transform.parent = ((Component)ShopManager.instance).transform;
						if (SemiFunc.IsMultiplayer())
						{
							PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)val6.prefab).ResourcePath, val5.position, rotation, (byte)0, (object[])null);
						}
						else
						{
							Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)val6.prefab).Prefab, val5.position, rotation);
						}
					}
					else if (SemiFunc.IsMultiplayer())
					{
						PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)val6.prefab).ResourcePath, val5.position, val5.rotation, (byte)0, (object[])null);
					}
					else
					{
						Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)val6.prefab).Prefab, val5.position, val5.rotation);
					}
					list2.RemoveAt(k);
					__instance.cachedUpgrades.RemoveAt(k);
					k--;
				}
			}
			return false;
		}

		private static void printListOfItems(List<Item> list)
		{
			foreach (Item item in list)
			{
				if ((Object)(object)item == (Object)null)
				{
					Debug.Log((object)"NULL");
				}
				else
				{
					Debug.Log((object)((Object)item).name);
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("StatePressSucceed")]
		private static void fixButtonBreakRNG()
		{
			Random.InitState(RepoSeeded.shopTemporaryRandom.Next());
		}

		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void createUpgradeRandoms()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Invalid comparison between Unknown and I4
			upgradeRandoms.Clear();
			foreach (Item item in StatsManager.instance.itemDictionary.Values.OrderBy((Item i) => ((Object)i).name))
			{
				if ((int)item.itemType == 3)
				{
					upgradeRandoms.TryAdd(((Object)item).name, new Random(RepoSeeded.shopTemporaryRandom.Next()));
				}
			}
		}
	}
	[HarmonyPatch(typeof(MenuPageSaves))]
	internal static class RNGSetterOnGameStart
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnNewGame")]
		private static void setSeedOnNewGame()
		{
			RepoSeeded.setSeed(RepoSeeded.currentSeed);
			RepoSeeded.JustHijackedTheSave = true;
			RepoSeeded.savedSeedToHistory = false;
		}
	}
	[HarmonyPatch(typeof(MenuPageLobby))]
	internal static class RNGSetterOnGameHost
	{
		[HarmonyPrefix]
		[HarmonyPatch("ButtonStart")]
		private static void OnHostGame()
		{
			RepoSeeded.setSeed(RepoSeeded.currentSeed);
			RepoSeeded.JustHijackedTheSave = true;
			RepoSeeded.savedSeedToHistory = false;
		}
	}
	[HarmonyPatch(typeof(StatsManager))]
	internal static class SaveHijack
	{
		private const string saveName = "R.E.P.O. SEEDED";

		private static StatsManager sm = StatsManager.instance;

		[HarmonyPostfix]
		[HarmonyPatch("SaveGame")]
		private static void InjectOwnRNGSaveData(ref string fileName)
		{
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(fileName) || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			sm.dateAndTime = DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
			string text = Application.persistentDataPath + "/saves";
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			string text2 = text + "/" + fileName;
			if (!Directory.Exists(text2))
			{
				Directory.CreateDirectory(text2);
			}
			string text3 = text2 + "/" + fileName + ".es3";
			if (File.Exists(text3))
			{
				StatsManager obj = sm;
				obj.backupIndex++;
				string destFileName = text2 + "/" + fileName + "_BACKUP" + sm.backupIndex + ".es3";
				File.Move(text3, destFileName);
			}
			ES3Settings val = new ES3Settings(new Enum[1] { (Enum)(object)(Location)4 });
			val.encryptionType = (EncryptionType)1;
			val.encryptionPassword = sm.totallyNormalString;
			val.path = text3;
			ES3.Save<string>("teamName", "R.E.P.O. SEEDED", val);
			ES3.Save<bool>("teamNameChanged", sm.teamNameChanged, val);
			ES3.Save<string>("dateAndTime", "Seed: " + RepoSeeded.currentSeed, val);
			ES3.Save<float>("timePlayed", sm.timePlayed, val);
			ES3.Save<Dictionary<string, string>>("playerNames", sm.playerNames, val);
			ES3.Save<int>("ValuableTypeRandom", RepoSeeded.ValuableTypeSeed, val);
			ES3.Save<int>("ValuableCostRandom", RepoSeeded.ValuableCostSeed, val);
			ES3.Save<int>("LevelRandom", RepoSeeded.LevelSeed, val);
			ES3.Save<int>("ShopRandom", RepoSeeded.ShopSeed, val);
			ES3.Save<int>("EnemyTypeRandom", RepoSeeded.EnemyTypeSeed, val);
			ES3.Save<int>("EnemyOrbRandom", RepoSeeded.EnemyOrbSeed, val);
			ES3.Save<int>("TruckTextRandom", RepoSeeded.TruckTextSeed, val);
			Dictionary<string, Dictionary<string, int>> dictionary = new Dictionary<string, Dictionary<string, int>>();
			foreach (KeyValuePair<string, Dictionary<string, int>> dictionaryOfDictionary in sm.dictionaryOfDictionaries)
			{
				if (sm.doNotSaveTheseDictionaries.Contains(dictionaryOfDictionary.Key))
				{
					continue;
				}
				if (sm.stripTheseDictionaries.TryGetValue(dictionaryOfDictionary.Key, out var value))
				{
					Dictionary<string, int> dictionary2 = new Dictionary<string, int>();
					foreach (KeyValuePair<string, int> item in dictionaryOfDictionary.Value)
					{
						if (value != item.Value)
						{
							dictionary2[item.Key] = item.Value;
						}
						else
						{
							dictionary2.Remove(item.Key);
						}
					}
					dictionary[dictionaryOfDictionary.Key] = dictionary2;
				}
				else
				{
					dictionary[dictionaryOfDictionary.Key] = dictionaryOfDictionary.Value;
				}
			}
			ES3.Save<Dictionary<string, Dictionary<string, int>>>("dictionaryOfDictionaries", dictionary, val);
			ES3.Save<int>("saveVersion", sm.saveVersion, val);
			ES3.StoreCachedFile(val);
		}

		[HarmonyPostfix]
		[HarmonyPatch("LoadGame")]
		public static void GetInjectedSaveData(string fileName, ref List<string> backupList)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			string text = Application.persistentDataPath + "/saves/" + fileName + "/" + fileName + ".es3";
			if (File.Exists(text))
			{
				sm.saveFileCurrent = fileName;
				ES3Settings val = new ES3Settings(text, (EncryptionType)1, sm.totallyNormalString, (ES3Settings)null);
				sm.teamName = ES3.Load<string>("teamName", (string)null, "R.E.P.O.", val);
				sm.teamNameChanged = ES3.Load<bool>("teamNameChanged", (string)null, sm.teamName != "R.E.P.O.", val);
				sm.dateAndTime = ES3.Load<string>("dateAndTime", (string)null, DateTime.Now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), val);
				sm.timePlayed = ES3.Load<float>("timePlayed", (string)null, 0f, val);
				sm.playerNames = ES3.Load<Dictionary<string, string>>("playerNames", (string)null, new Dictionary<string, string>(), val);
				sm.saveVersion = ES3.Load<int>("saveVersion", (string)null, 0, val);
				if (sm.teamName == "R.E.P.O. SEEDED")
				{
					RepoSeeded.currentSeed = sm.dateAndTime.Substring(6);
					RepoSeeded.ValuableTypeSeed = ES3.Load<int>("ValuableTypeRandom", (string)null, -1, val);
					RepoSeeded.ValuableTypeRandom = new Random(RepoSeeded.ValuableTypeSeed);
					RepoSeeded.ValuableCostSeed = ES3.Load<int>("ValuableCostRandom", (string)null, -1, val);
					RepoSeeded.ValuableCostRandom = new Random(RepoSeeded.ValuableCostSeed);
					RepoSeeded.LevelSeed = ES3.Load<int>("LevelRandom", (string)null, -1, val);
					RepoSeeded.LevelRandom = new Random(RepoSeeded.LevelSeed);
					RepoSeeded.ShopSeed = ES3.Load<int>("ShopRandom", (string)null, -1, val);
					RepoSeeded.ShopRandom = new Random(RepoSeeded.ShopSeed);
					RepoSeeded.EnemyTypeSeed = ES3.Load<int>("EnemyTypeRandom", (string)null, -1, val);
					RepoSeeded.TruckTextSeed = ES3.Load<int>("TruckTextRandom", (string)null, -1, val);
					RepoSeeded.TruckTextRandom = new Random(RepoSeeded.TruckTextSeed);
					RepoSeeded.EnemyTypeRandom = new Random(RepoSeeded.EnemyTypeSeed);
					RepoSeeded.EnemyOrbSeed = ES3.Load<int>("EnemyOrbRandom", (string)null, -1, val);
					RepoSeeded.EnemyOrbRandom = new Random(RepoSeeded.EnemyOrbSeed);
					RunManager.instance.enemiesSpawned = new List<EnemySetup>();
					RepoSeeded.JustHijackedTheSave = true;
				}
				foreach (KeyValuePair<string, Dictionary<string, int>> item in ES3.Load<Dictionary<string, Dictionary<string, int>>>("dictionaryOfDictionaries", (string)null, new Dictionary<string, Dictionary<string, int>>(), val))
				{
					if (sm.doNotSaveTheseDictionaries.Contains(item.Key))
					{
						continue;
					}
					if (sm.dictionaryOfDictionaries.TryGetValue(item.Key, out var value))
					{
						foreach (KeyValuePair<string, int> item2 in item.Value)
						{
							if (!sm.stripTheseDictionaries.ContainsKey(item.Key) || sm.stripTheseDictionaries[item.Key] != item2.Value)
							{
								value[item2.Key] = item2.Value;
							}
							else
							{
								value.Remove(item2.Key);
							}
						}
					}
					else
					{
						Debug.LogWarning((object)("dictionaryOfDictionaries does not contain key '" + item.Key + "'."));
						sm.dictionaryOfDictionaries.Add(item.Key, new Dictionary<string, int>(item.Value));
					}
				}
				if (sm.saveVersion < 1)
				{
					foreach (string item3 in sm.itemStatBattery.Keys.Where((string key) => !key.Contains("/")).ToList())
					{
						sm.itemStatBattery.Remove(item3);
					}
					foreach (string item4 in sm.item.Keys.Where((string key) => !sm.itemStatBattery.ContainsKey(key)).ToList())
					{
						sm.item.Remove(item4);
					}
				}
			}
			else
			{
				sm.teamName = "R.E.P.O.";
				sm.teamNameChanged = false;
				Debug.LogWarning((object)("Save file not found in " + text));
			}
			sm.saveVersion = sm.latestSaveVersion;
			RunManager.instance.levelsCompleted = sm.GetRunStatLevel();
			RunManager.instance.runLives = sm.GetRunStatLives();
			RunManager.instance.loadLevel = sm.GetRunStatSaveLevel();
			sm.PlayersAddAll();
			if (backupList == null)
			{
				backupList = sm.SaveFileGetBackups(fileName, Application.persistentDataPath + "/saves");
			}
			if (backupList.Count > 0)
			{
				Match match = Regex.Match(backupList[0], "_BACKUP(\\d+)$");
				sm.backupIndex = (match.Success ? int.Parse(match.Groups[1].Value) : 0);
			}
			else
			{
				sm.backupIndex = 0;
			}
			sm.saveFileReady = true;
		}
	}
	internal static class SeedHistory
	{
		private const int MAX_SEEDS = 10;

		private static string seedHistoryPath = Path.Combine(Paths.ConfigPath, "SeedHistory.txt");

		private static List<string> seeds = new List<string>();

		internal static void ReadSeeds()
		{
			if (File.Exists(seedHistoryPath))
			{
				seeds = File.ReadAllLines(seedHistoryPath).ToList();
			}
		}

		private static void saveSeeds()
		{
			File.WriteAllLines(seedHistoryPath, seeds);
		}

		internal static void addSeed(string seed)
		{
			seeds.Remove(seed);
			seeds.Add(seed);
			if (seeds.Count > 10)
			{
				seeds.Remove(seeds[0]);
			}
			saveSeeds();
		}

		internal static List<string> getSeeds()
		{
			return seeds;
		}
	}
	[HarmonyPatch(typeof(RunManager))]
	internal static class SetNewSeedToPreviousSeed
	{
		[HarmonyPostfix]
		[HarmonyPatch("ResetProgress")]
		private static void setSeedOnNewAutoRun()
		{
			RepoSeeded.setSeed(RepoSeeded.currentSeed);
			RepoSeeded.JustHijackedTheSave = true;
			RepoSeeded.savedSeedToHistory = false;
		}

		[HarmonyPostfix]
		[HarmonyPatch("LeaveToMainMenu")]
		private static void setSeedWhenBackToMenu()
		{
			RepoSeeded.setSeed(RepoSeeded.currentSeed);
			RepoSeeded.JustHijackedTheSave = true;
			RepoSeeded.savedSeedToHistory = false;
		}
	}
	[HarmonyPatch(typeof(ShopManager))]
	internal static class ShopRNGPatch
	{
		private const string placeholderName = "REPOSEEDED PLACEHOLDER";

		private static ShopManager sm = ShopManager.instance;

		[HarmonyPatch("GetAllItemsFromStatsManager")]
		[HarmonyPrefix]
		private static bool GetAlllItemsPrefix()
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Invalid comparison between Unknown and I4
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Invalid comparison between Unknown and I4
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Invalid comparison between Unknown and I4
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Invalid comparison between Unknown and I4
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Invalid comparison between Unknown and I4
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Invalid comparison between Unknown and I4
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			int num = RepoSeeded.ShopRandom.Next();
			Random.InitState(num);
			Debug.LogError((object)("initting shop with seed " + num));
			if (SemiFunc.IsNotMasterClient())
			{
				return false;
			}
			sm.potentialItems.Clear();
			sm.potentialItemConsumables.Clear();
			sm.potentialItemUpgrades.Clear();
			sm.potentialItemHealthPacks.Clear();
			sm.potentialSecretItems.Clear();
			sm.itemConsumablesAmount = Random.Range(4, 6);
			Item[] array = sortItemsOnName(StatsManager.instance.itemDictionary.Values);
			foreach (Item val in array)
			{
				Item val2 = val;
				int num2 = SemiFunc.StatGetItemsPurchased(((Object)val2).name);
				float num3 = val2.value.valueMax / 1000f * sm.itemValueMultiplier;
				if ((int)val2.itemType == 3)
				{
					num3 = sm.UpgradeValueGet(num3, val2);
				}
				else if ((int)val2.itemType == 8)
				{
					num3 = sm.HealthPackValueGet(num3);
				}
				else if ((int)val2.itemType == 5)
				{
					num3 = sm.CrystalValueGet(num3);
				}
				float num4 = Mathf.Clamp(num3, 1f, num3);
				bool flag = (int)val2.itemType == 5;
				bool flag2 = (int)val2.itemType == 3;
				bool flag3 = (int)val2.itemType == 8;
				int maxAmountInShop = val2.maxAmountInShop;
				if (num2 >= maxAmountInShop || (val2.maxPurchase && StatsManager.instance.GetItemsUpgradesPurchasedTotal(((Object)val2).name) >= val2.maxPurchaseAmount) || (val2.minPlayerCount > 1 && GameDirector.instance.PlayerList.Count < val2.minPlayerCount))
				{
					val2 = null;
				}
				for (int j = 0; j < maxAmountInShop; j++)
				{
					if ((Object)(object)val2 != (Object)null && j >= maxAmountInShop - num2)
					{
						val2 = null;
					}
					if (flag2)
					{
						sm.potentialItemUpgrades.Add(val2);
						continue;
					}
					if (flag3)
					{
						sm.potentialItemHealthPacks.Add(val2);
						continue;
					}
					if (flag)
					{
						sm.potentialItemConsumables.Add(val2);
						continue;
					}
					if ((int)val.itemSecretShopType == 0)
					{
						sm.potentialItems.Add(val2);
						continue;
					}
					if (!sm.potentialSecretItems.ContainsKey(val.itemSecretShopType))
					{
						sm.potentialSecretItems.Add(val.itemSecretShopType, new List<Item>());
					}
					sm.potentialSecretItems[val.itemSecretShopType].Add(val2);
				}
			}
			ListExtension.Shuffle<Item>((IList<Item>)sm.potentialItems);
			for (int num5 = sm.potentialItems.Count - 1; num5 >= 0; num5--)
			{
				if ((Object)(object)sm.potentialItems[num5] == (Object)null)
				{
					sm.potentialItems.RemoveAt(num5);
				}
			}
			ListExtension.Shuffle<Item>((IList<Item>)sm.potentialItemConsumables);
			for (int num6 = sm.potentialItemConsumables.Count - 1; num6 >= 0; num6--)
			{
				if ((Object)(object)sm.potentialItemConsumables[num6] == (Object)null)
				{
					sm.potentialItemConsumables.RemoveAt(num6);
				}
			}
			ListExtension.Shuffle<Item>((IList<Item>)sm.potentialItemUpgrades);
			for (int num7 = sm.potentialItemUpgrades.Count - 1; num7 >= 0; num7--)
			{
				if ((Object)(object)sm.potentialItemUpgrades[num7] == (Object)null)
				{
					sm.potentialItemUpgrades.RemoveAt(num7);
				}
			}
			ListExtension.Shuffle<Item>((IList<Item>)sm.potentialItemHealthPacks);
			for (int num8 = sm.potentialItemHealthPacks.Count - 1; num8 >= 0; num8--)
			{
				if ((Object)(object)sm.potentialItemHealthPacks[num8] == (Object)null)
				{
					sm.potentialItemHealthPacks.RemoveAt(num8);
				}
			}
			foreach (List<Item> value in sm.potentialSecretItems.Values)
			{
				ListExtension.Shuffle<Item>((IList<Item>)value);
				for (int num9 = value.Count - 1; num9 >= 0; num9--)
				{
					if ((Object)(object)value[num9] == (Object)null)
					{
						value.RemoveAt(num9);
					}
				}
			}
			return false;
		}

		[HarmonyPatch("GetAllItemVolumesInScene")]
		[HarmonyPrefix]
		private static bool GetAllVolumesPrefix()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			Random.InitState(RepoSeeded.ShopRandom.Next());
			if (SemiFunc.IsNotMasterClient())
			{
				return false;
			}
			sm.itemVolumes.Clear();
			sm.secretItemVolumes.Clear();
			ItemVolume[] array = Object.FindObjectsByType<ItemVolume>((FindObjectsSortMode)0);
			sortVolumesOnLocation(array);
			ItemVolume[] array2 = array;
			foreach (ItemVolume val in array2)
			{
				if ((int)val.itemSecretShopType == 0)
				{
					sm.itemVolumes.Add(val);
					continue;
				}
				if (!sm.secretItemVolumes.ContainsKey(val.itemSecretShopType))
				{
					sm.secretItemVolumes.Add(val.itemSecretShopType, new List<ItemVolume>());
				}
				sm.secretItemVolumes[val.itemSecretShopType].Add(val);
			}
			foreach (List<ItemVolume> value in sm.secretItemVolumes.Values)
			{
				ListExtension.Shuffle<ItemVolume>((IList<ItemVolume>)value);
			}
			ListExtension.Shuffle<ItemVolume>((IList<ItemVolume>)sm.itemVolumes);
			return false;
		}

		public static void sortVolumesOnLocation(ItemVolume[] volumes)
		{
			Array.Sort(volumes, delegate(ItemVolume a, ItemVolume b)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = new Vector3(0f, 0f, 0f) - ((Component)a).transform.position;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				val = new Vector3(0f, 0f, 0f) - ((Component)b).transform.position;
				return sqrMagnitude.CompareTo(((Vector3)(ref val)).sqrMagnitude);
			});
		}

		public static Item[] sortItemsOnName(IEnumerable<Item> items)
		{
			Item[] array = items.ToArray();
			Array.Sort(array, (Item a, Item b) => a.itemName.CompareTo(b.itemName));
			return array;
		}
	}
	[HarmonyPatch(typeof(TruckScreenText))]
	internal static class TruckTextRNGPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("NextLine")]
		private static bool RemoveTruckTextRNG(TruckScreenText __instance, ref int _currentLineIndex)
		{
			Random.InitState(RepoSeeded.TruckTextRandom.Next());
			return true;
		}
	}
	internal static class ValuableCostsRNGPatch
	{
		[HarmonyPatch("DollarValueSetLogic")]
		[HarmonyPrefix]
		private static bool RemoveValueRNG(ref Rigidbody ___rb)
		{
			return true;
		}
	}
	[HarmonyPatch(typeof(ValuableDirector))]
	internal static class ValuableTypesRNGPatch
	{
		[CompilerGenerated]
		private sealed class <newSetupHost>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			private ValuableDirector <vd>5__2;

			private string[] <_names>5__3;

			private int[] <_maxAmount>5__4;

			private List<ValuableVolume>[] <_volumes>5__5;

			private string[] <_path>5__6;

			private int[] <_chance>5__7;

			private List<PrefabRef>[] <_valuables>5__8;

			private int[] <_volumeIndex>5__9;

			private int <_i>5__10;

			private int <_cosmeticWorldObjectLevelLoopsClamped>5__11;

			private int <_i2>5__12;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <newSetupHost>d__1(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<vd>5__2 = null;
				<_names>5__3 = null;
				<_maxAmount>5__4 = null;
				<_volumes>5__5 = null;
				<_path>5__6 = null;
				<_chance>5__7 = null;
				<_valuables>5__8 = null;
				<_volumeIndex>5__9 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0c79: Unknown result type (might be due to invalid IL or missing references)
				//IL_0e28: Unknown result type (might be due to invalid IL or missing references)
				//IL_0e2e: Invalid comparison between Unknown and I4
				//IL_0c29: Unknown result type (might be due to invalid IL or missing references)
				//IL_0c33: Expected O, but got Unknown
				//IL_0f57: Unknown result type (might be due to invalid IL or missing references)
				//IL_0f61: Expected O, but got Unknown
				//IL_0fa3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0fad: Expected O, but got Unknown
				//IL_0dcd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0601: Unknown result type (might be due to invalid IL or missing references)
				//IL_0607: Invalid comparison between Unknown and I4
				//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_06f6: Invalid comparison between Unknown and I4
				ValuableDirector obj10;
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					<vd>5__2 = ValuableDirector.instance;
					if (SemiFunc.RunGetDifficultyMultiplier2() > 0f && !SemiFunc.RunIsArena())
					{
						float num = SemiFunc.RunGetDifficultyMultiplier2();
						<vd>5__2.totalMaxValue = Mathf.RoundToInt(<vd>5__2.totalMaxValueCurve2.Evaluate(num));
						<vd>5__2.tinyMaxAmount = Mathf.RoundToInt(<vd>5__2.tinyMaxAmountCurve2.Evaluate(num));
						<vd>5__2.smallMaxAmount = Mathf.RoundToInt(<vd>5__2.smallMaxAmountCurve2.Evaluate(num));
						<vd>5__2.mediumMaxAmount = Mathf.RoundToInt(<vd>5__2.mediumMaxAmountCurve2.Evaluate(num));
						<vd>5__2.bigMaxAmount = Mathf.RoundToInt(<vd>5__2.bigMaxAmountCurve2.Evaluate(num));
						<vd>5__2.wideMaxAmount = Mathf.RoundToInt(<vd>5__2.wideMaxAmountCurve2.Evaluate(num));
						<vd>5__2.tallMaxAmount = Mathf.RoundToInt(<vd>5__2.tallMaxAmountCurve2.Evaluate(num));
						<vd>5__2.veryTallMaxAmount = Mathf.RoundToInt(<vd>5__2.veryTallMaxAmountCurve2.Evaluate(num));
					}
					else
					{
						float num2 = SemiFunc.RunGetDifficultyMultiplier1();
						if (SemiFunc.RunIsArena())
						{
							num2 = 0.75f;
						}
						<vd>5__2.totalMaxValue = Mathf.RoundToInt(<vd>5__2.totalMaxValueCurve1.Evaluate(num2));
						<vd>5__2.tinyMaxAmount = Mathf.RoundToInt(<vd>5__2.tinyMaxAmountCurve1.Evaluate(num2));
						<vd>5__2.smallMaxAmount = Mathf.RoundToInt(<vd>5__2.smallMaxAmountCurve1.Evaluate(num2));
						<vd>5__2.mediumMaxAmount = Mathf.RoundToInt(<vd>5__2.mediumMaxAmountCurve1.Evaluate(num2));
						<vd>5__2.bigMaxAmount = Mathf.RoundToInt(<vd>5__2.bigMaxAmountCurve1.Evaluate(num2));
						<vd>5__2.wideMaxAmount = Mathf.RoundToInt(<vd>5__2.wideMaxAmountCurve1.Evaluate(num2));
						<vd>5__2.tallMaxAmount = Mathf.RoundToInt(<vd>5__2.tallMaxAmountCurve1.Evaluate(num2));
						<vd>5__2.veryTallMaxAmount = Mathf.RoundToInt(<vd>5__2.veryTallMaxAmountCurve1.Evaluate(num2));
					}
					if (SemiFunc.RunIsArena())
					{
						ValuableDirector obj2 = <vd>5__2;
						obj2.totalMaxAmount /= 2;
						ValuableDirector obj3 = <vd>5__2;
						obj3.tinyMaxAmount /= 3;
						ValuableDirector obj4 = <vd>5__2;
						obj4.smallMaxAmount /= 3;
						ValuableDirector obj5 = <vd>5__2;
						obj5.mediumMaxAmount /= 3;
						ValuableDirector obj6 = <vd>5__2;
						obj6.bigMaxAmount /= 3;
						ValuableDirector obj7 = <vd>5__2;
						obj7.wideMaxAmount /= 2;
						ValuableDirector obj8 = <vd>5__2;
						obj8.tallMaxAmount /= 2;
						ValuableDirector obj9 = <vd>5__2;
						obj9.veryTallMaxAmount /= 2;
					}
					foreach (LevelValuables valuablePreset in LevelGenerator.Instance.Level.ValuablePresets)
					{
						<vd>5__2.tinyValuables.AddRange(valuablePreset.tiny);
						<vd>5__2.smallValuables.AddRange(valuablePreset.small);
						<vd>5__2.mediumValuables.AddRange(valuablePreset.medium);
						<vd>5__2.bigValuables.AddRange(valuablePreset.big);
						<vd>5__2.wideValuables.AddRange(valuablePreset.wide);
						<vd>5__2.tallValuables.AddRange(valuablePreset.tall);
						<vd>5__2.veryTallValuables.AddRange(valuablePreset.veryTall);
					}
					List<ValuableVolume> list = Object.FindObjectsByType<ValuableVolume>((FindObjectsInactive)0, (FindObjectsSortMode)0).ToList();
					sortVolumesOnLocation(list);
					Random.InitState(RepoSeeded.ValuableTypeRandom.Next());
					<vd>5__2.tinyVolumes = list.FindAll((ValuableVolume x) => (int)x.VolumeType == 0);
					ListExtension.Shuffle<ValuableVolume>((IList<ValuableVolume>)<vd>5__2.tinyVolumes);
					<vd>5__2.smallVolumes = list.FindAll((ValuableVolume x) => (int)x.VolumeType == 1);
					ListExtension.Shuffle<ValuableVolume>((IList<ValuableVolume>)<vd>5__2.smallVolumes);
					<vd>5__2.mediumVolumes = list.FindAll((ValuableVolume x) => (int)x.VolumeType == 2);
					ListExtension.Shuffle<ValuableVolume>((IList<ValuableVolume>)<vd>5__2.mediumVolumes);
					<vd>5__2.bigVolumes = list.FindAll((ValuableVolume x) => (int)x.VolumeType == 3);
					ListExtension.Shuffle<ValuableVolume>((IList<ValuableVolume>)<vd>5__2.bigVolumes);
					<vd>5__2.wideVolumes = list.FindAll((ValuableVolume x) => (int)x.VolumeType == 4);
					ListExtension.Shuffle<ValuableVolume>((IList<ValuableVolume>)<vd>5__2.wideVolumes);
					<vd>5__2.tallVolumes = list.FindAll((ValuableVolume x) => (int)x.VolumeType == 5);
					ListExtension.Shuffle<ValuableVolume>((IList<ValuableVolume>)<vd>5__2.tallVolumes);
					<vd>5__2.veryTallVolumes = list.FindAll((ValuableVolume x) => (int)x.VolumeType == 6);
					ListExtension.Shuffle<ValuableVolume>((IList<ValuableVolume>)<vd>5__2.veryTallVolumes);
					if ((int)<vd>5__2.valuableDebug == 1)
					{
						<vd>5__2.totalMaxAmount = list.Count;
						<vd>5__2.totalMaxValue = 99999f;
						<vd>5__2.tinyMaxAmount = <vd>5__2.tinyVolumes.Count;
						<vd>5__2.smallMaxAmount = <vd>5__2.smallVolumes.Count;
						<vd>5__2.mediumMaxAmount = <vd>5__2.mediumVolumes.Count;
						<vd>5__2.bigMaxAmount = <vd>5__2.bigVolumes.Count;
						<vd>5__2.wideMaxAmount = <vd>5__2.wideVolumes.Count;
						<vd>5__2.tallMaxAmount = <vd>5__2.tallVolumes.Count;
						<vd>5__2.veryTallMaxAmount = <vd>5__2.veryTallVolumes.Count;
					}
					if ((int)<vd>5__2.valuableDebug == 2 || LevelGenerator.Instance.Level.ValuablePresets.Count <= 0)
					{
						<vd>5__2.totalMaxAmount = 0;
						<vd>5__2.tinyMaxAmount = 0;
						<vd>5__2.smallMaxAmount = 0;
						<vd>5__2.mediumMaxAmount = 0;
						<vd>5__2.bigMaxAmount = 0;
						<vd>5__2.wideMaxAmount = 0;
						<vd>5__2.tallMaxAmount = 0;
						<vd>5__2.veryTallMaxAmount = 0;
					}
					<vd>5__2.valuableTargetAmount = 0;
					<_names>5__3 = new string[7] { "Tiny", "Small", "Medium", "Big", "Wide", "Tall", "Very Tall" };
					<_maxAmount>5__4 = new int[7] { <vd>5__2.tinyMaxAmount, <vd>5__2.smallMaxAmount, <vd>5__2.mediumMaxAmount, <vd>5__2.bigMaxAmount, <vd>5__2.wideMaxAmount, <vd>5__2.tallMaxAmount, <vd>5__2.veryTallMaxAmount };
					<_volumes>5__5 = new List<ValuableVolume>[7] { <vd>5__2.tinyVolumes, <vd>5__2.smallVolumes, <vd>5__2.mediumVolumes, <vd>5__2.bigVolumes, <vd>5__2.wideVolumes, <vd>5__2.tallVolumes, <vd>5__2.veryTallVolumes };
					<_path>5__6 = new string[7] { <vd>5__2.tinyPath, <vd>5__2.smallPath, <vd>5__2.mediumPath, <vd>5__2.bigPath, <vd>5__2.widePath, <vd>5__2.tallPath, <vd>5__2.veryTallPath };
					<_chance>5__7 = new int[7] { <vd>5__2.tinyChance, <vd>5__2.smallChance, <vd>5__2.mediumChance, <vd>5__2.bigChance, <vd>5__2.wideChance, <vd>5__2.tallChance, <vd>5__2.veryTallChance };
					<_valuables>5__8 = new List<PrefabRef>[7] { <vd>5__2.tinyValuables, <vd>5__2.smallValuables, <vd>5__2.mediumValuables, <vd>5__2.bigValuables, <vd>5__2.wideValuables, <vd>5__2.tallValuables, <vd>5__2.veryTallValuables };
					<_volumeIndex>5__9 = new int[7];
					<_i>5__10 = 0;
					goto IL_0b23;
				}
				case 1:
					<>1__state = -1;
					<_i>5__10++;
					goto IL_0b23;
				case 2:
					<>1__state = -1;
					goto IL_0c43;
				case 3:
					<>1__state = -1;
					goto IL_0dfa;
				case 4:
					<>1__state = -1;
					<vd>5__2.SpawnCosmeticWorldObject((Rarity)1, <_volumeIndex>5__9, <_volumes>5__5);
					<>2__current = null;
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					<vd>5__2.SpawnCosmeticWorldObject((Rarity)2, <_volumeIndex>5__9, <_volumes>5__5);
					<>2__current = null;
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -1;
					<vd>5__2.SpawnCosmeticWorldObject((Rarity)3, <_volumeIndex>5__9, <_volumes>5__5);
					<>2__current = null;
					<>1__state = 7;
					return true;
				case 7:
					<>1__state = -1;
					goto IL_0eef;
				case 8:
				{
					<>1__state = -1;
					ValuableDirector obj = <vd>5__2;
					obj.cosmeticWorldObjectSpawnPlayerReady++;
					goto IL_0f72;
				}
				case 9:
					<>1__state = -1;
					goto IL_0f72;
				case 10:
					{
						<>1__state = -1;
						break;
					}
					IL_0f72:
					if (SemiFunc.IsMultiplayer() && <vd>5__2.cosmeticWorldObjectSpawnPlayerReady < PhotonNetwork.CurrentRoom.PlayerCount)
					{
						<>2__current = (object)new WaitForSeconds(0.1f);
						<>1__state = 9;
						return true;
					}
					<vd>5__2.VolumesAndSwitchSetup();
					break;
					IL_0c43:
					if (GameManager.instance.gameMode == 1 && <vd>5__2.valuableSpawnPlayerReady < PhotonNetwork.CurrentRoom.PlayerCount)
					{
						<>2__current = (object)new WaitForSeconds(0.1f);
						<>1__state = 2;
						return true;
					}
					<vd>5__2.cosmeticWorldObjectTargetAmount = 0;
					if ((int)<vd>5__2.cosmeticWorldObjectDebug == 0 && SemiFunc.RunIsLevel())
					{
						<_i>5__10 = <vd>5__2.CosmeticWorldObjectLevelLoopsGet();
						<_cosmeticWorldObjectLevelLoopsClamped>5__11 = <vd>5__2.CosmeticWorldObjectLevelLoopsClampedGet();
						<_i2>5__12 = 0;
						goto IL_0e0c;
					}
					if ((int)<vd>5__2.cosmeticWorldObjectDebug == 1)
					{
						<vd>5__2.SpawnCosmeticWorldObject((Rarity)0, <_volumeIndex>5__9, <_volumes>5__5);
						<>2__current = null;
						<>1__state = 4;
						return true;
					}
					goto IL_0eef;
					IL_0dfa:
					<_i2>5__12++;
					goto IL_0e0c;
					IL_0eef:
					if (SemiFunc.IsMultiplayer())
					{
						<vd>5__2.PhotonView.RPC("CosmeticWorldObjectTargetSetRPC", (RpcTarget)0, new object[1] { <vd>5__2.cosmeticWorldObjectTargetAmount });
					}
					<>2__current = null;
					<>1__state = 8;
					return true;
					IL_0e0c:
					if (<_i2>5__12 <= <_cosmeticWorldObjectLevelLoopsClamped>5__11)
					{
						float num3 = ((<_i2>5__12 >= <_i>5__10) ? ((float)(RunManager.instance.levelsCompleted % <vd>5__2.cosmeticWorldObjectsLevelLoop) / (float)<vd>5__2.cosmeticWorldObjectsLevelLoop) : 1f);
						int num4 = Mathf.RoundToInt(<vd>5__2.cosmeticWorldObjectsSpawnCurve.Evaluate(num3) * 100f);
						if (RunManager.instance.cosmeticWorldObjectBadLuckCount > 0)
						{
							num4 += Mathf.RoundToInt((float)RunManager.instance.cosmeticWorldObjectBadLuckCount * 25f);
						}
						if (Random.Range(0, 100) < num4)
						{
							CosmeticWorldObjectSetup val = null;
							float num5 = -1f;
							foreach (CosmeticWorldObjectSetup cosmeticWorldObjectSetup in <vd>5__2.cosmeticWorldObjectSetups)
							{
								int num6 = Mathf.RoundToInt(cosmeticWorldObjectSetup.chanceCurve.Evaluate(num3) * 100f);
								int num7 = Random.Range(0, num6);
								if ((float)num7 > num5)
								{
									num5 = num7;
									val = cosmeticWorldObjectSetup;
								}
							}
							if (val != null)
							{
								<vd>5__2.SpawnCosmeticWorldObject(val.rarity, <_volumeIndex>5__9, <_volumes>5__5);
								<>2__current = null;
								<>1__state = 3;
								return true;
							}
						}
						goto IL_0dfa;
					}
					goto IL_0eef;
					IL_0b23:
					if (<_i>5__10 < <vd>5__2.totalMaxAmount)
					{
						Random.InitState(RepoSeeded.ValuableTypeRandom.Next());
						float num8 = -1f;
						int num9 = -1;
						for (int i = 0; i < <_names>5__3.Length; i++)
						{
							if (<_volumeIndex>5__9[i] < <_maxAmount>5__4[i] && <_volumeIndex>5__9[i] < <_volumes>5__5[i].Count && <_valuables>5__8[i].Count != 0)
							{
								int num10 = Random.Range(0, <_chance>5__7[i]);
								if ((float)num10 > num8)
								{
									num8 = num10;
									num9 = i;
								}
							}
						}
						if (num9 != -1)
						{
							ValuableVolume val2 = <_volumes>5__5[num9][<_volumeIndex>5__9[num9]];
							PrefabRef val3 = <_valuables>5__8[num9][Random.Range(0, <_valuables>5__8[num9].Count)];
							<vd>5__2.SpawnValuable(val3, val2, <_path>5__6[num9]);
							<_volumeIndex>5__9[num9]++;
							<>2__current = null;
							<>1__state = 1;
							return true;
						}
					}
					if (<vd>5__2.valuableTargetAmount < <vd>5__2.totalMaxAmount && Object.op_Implicit((Object)(object)DebugComputerCheck.instance) && (DebugComputerCheck.instance.DebugDisable || !DebugComputerCheck.instance.LevelDebug || !DebugComputerCheck.instance.ModuleOverrideActive || DebugComputerCheck.instance.ModuleOverride == null))
					{
						for (int j = 0; j < <_names>5__3.Length; j++)
						{
							if (<_volumeIndex>5__9[j] < <_maxAmount>5__4[j])
							{
								Debug.LogError((object)("Could not spawn enough ''" + <_names>5__3[j] + "'' valuables!"));
							}
						}
					}
					if (SemiFunc.IsMultiplayer())
					{
						<vd>5__2.PhotonView.RPC("ValuablesTargetSetRPC", (RpcTarget)0, new object[1] { <vd>5__2.valuableTargetAmount });
					}
					obj10 = <vd>5__2;
					obj10.valuableSpawnPlayerReady++;
					goto IL_0c43;
				}
				if (GameManager.instance.gameMode == 1 && <vd>5__2.switchSetupPlayerReady < PhotonNetwork.CurrentRoom.PlayerCount)
				{
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 10;
					return true;
				}
				<vd>5__2.setupComplete = true;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("SetupHost")]
		private static bool ValuablesRNGSeeder(ref IEnumerator __result)
		{
			__result = newSetupHost();
			return false;
		}

		[IteratorStateMachine(typeof(<newSetupHost>d__1))]
		private static IEnumerator newSetupHost()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <newSetupHost>d__1(0);
		}

		[HarmonyPatch("SpawnValuable")]
		[HarmonyPrefix]
		private static bool RemoveStartRandomizing(ref PrefabRef _valuable, ref ValuableVolume _volume, ref string _path)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			ValuableDirector instance = ValuableDirector.instance;
			GameObject prefab = ((PrefabRef<GameObject>)(object)_valuable).Prefab;
			GameObject val = ((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)_valuable).resourcePath, ((Component)_volume).transform.position, ((Component)_volume).transform.rotation, (byte)0, (object[])null) : Object.Instantiate<GameObject>(prefab, ((Component)_volume).transform.position, ((Component)_volume).transform.rotation));
			ValuableObject component = val.GetComponent<ValuableObject>();
			Random.InitState(RepoSeeded.ValuableCostRandom.Next());
			component.DollarValueSetLogic();
			instance.valuableTargetAmount++;
			instance.totalCurrentValue += component.dollarValueCurrent * 0.001f;
			if (instance.totalCurrentValue > instance.totalMaxValue)
			{
				instance.totalMaxAmount = instance.valuableTargetAmount;
			}
			return false;
		}

		public static void sortVolumesOnLocation(List<ValuableVolume> volumes)
		{
			volumes.Sort(delegate(ValuableVolume a, ValuableVolume b)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val = new Vector3(0f, 0f, 0f) - ((Component)a).transform.position;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				val = new Vector3(0f, 0f, 0f) - ((Component)b).transform.position;
				return sqrMagnitude.CompareTo(((Vector3)(ref val)).sqrMagnitude);
			});
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}