Decompiled source of Nachos Reset Mod v1.0.6

Nachito.ResetMod.dll

Decompiled 17 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Nachito.ResetMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("ResetMod")]
[assembly: AssemblyTitle("Nachito.ResetMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 ResetMod
{
	[BepInPlugin("Nachito.ResetMod", "ResetMod", "1.0.2")]
	public class ResetMod : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <ChooseSeed>d__35 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ResetMod <>4__this;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.doneUnloading));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					StartOfRound.Instance.StartGame();
					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();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadNewLevelWait>d__32 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int randomSeed;

			public ResetMod <>4__this;

			private Exception <arg>5__1;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<arg>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0167: Expected O, but got Unknown
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Expected O, but got Unknown
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					RoundManager.Instance.GenerateNewLevelClientRpc(randomSeed, RoundManager.Instance.currentLevel.levelID, 0, -1, (int[])null);
					if (RoundManager.Instance.currentLevel.spawnEnemiesAndScrap)
					{
						<>2__current = (object)new WaitUntil((Func<bool>)(() => RoundManager.Instance.dungeonCompletedGenerating));
						<>1__state = 3;
						return true;
					}
					goto IL_0157;
				case 3:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => RoundManager.Instance.playersFinishedGeneratingFloor.Count >= GameNetworkManager.Instance.connectedPlayers));
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					Debug.Log((object)"Players finished generating the new floor");
					goto IL_0157;
				case 6:
					<>1__state = -1;
					RoundManager.Instance.SpawnSyncedProps();
					if (RoundManager.Instance.currentLevel.spawnEnemiesAndScrap)
					{
						RoundManager.Instance.GeneratedFloorPostProcessing();
					}
					<>2__current = null;
					<>1__state = 7;
					return true;
				case 7:
					{
						<>1__state = -1;
						RoundManager.Instance.playersFinishedGeneratingFloor.Clear();
						RoundManager.Instance.dungeonFinishedGeneratingForAllPlayers = true;
						RoundManager.Instance.RefreshEnemyVents();
						RoundManager.Instance.RefreshLightsList();
						if (RoundManager.Instance.currentLevel.spawnEnemiesAndScrap)
						{
							RoundManager.Instance.SetLevelObjectVariables();
						}
						RoundManager.Instance.ResetEnemySpawningVariables();
						RoundManager.Instance.ResetEnemyTypesSpawnedCounts();
						RoundManager.Instance.playersManager.newGameIsLoading = false;
						FlashlightItem.globalFlashlightInterferenceLevel = 0;
						RoundManager.Instance.powerOffPermanently = false;
						RoundManager.Instance.RefreshEnemiesList();
						try
						{
							RoundManager.Instance.PredictAllOutsideEnemies();
						}
						catch (Exception ex)
						{
							<arg>5__1 = ex;
							Debug.Log((object)$"Error caught when predicting outside enemies: {<arg>5__1}");
						}
						return false;
					}
					IL_0157:
					<>2__current = (object)new WaitForSeconds(0.3f);
					<>1__state = 6;
					return true;
				}
			}

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

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

		[CompilerGenerated]
		private sealed class <Reroll>d__31 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ResetMod <>4__this;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Expected O, but got Unknown
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Expected O, but got Unknown
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					CanReset = false;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => <>4__this.doneUnloading || <>4__this.firstRoll));
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					StartOfRound.Instance.fullyLoadedPlayers.Clear();
					((NetworkBehaviour)RoundManager.Instance).NetworkManager.SceneManager.LoadScene(RoundManager.Instance.currentLevel.sceneName, (LoadSceneMode)1);
					<>2__current = (object)new WaitUntil((Func<bool>)(() => StartOfRound.Instance.fullyLoadedPlayers.Count >= GameNetworkManager.Instance.connectedPlayers));
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					StartOfRound.Instance.ChooseNewRandomMapSeed();
					StartOfRound.Instance.overrideRandomSeed = true;
					StartOfRound.Instance.overrideSeedNumber = StartOfRound.Instance.randomMapSeed;
					RoundManager.Instance.dungeonFinishedGeneratingForAllPlayers = false;
					if (RoundManager.Instance.loadLevelCoroutine != null)
					{
						RoundManager.Instance.loadLevelCoroutine = null;
					}
					RoundManager.Instance.loadLevelCoroutine = ((MonoBehaviour)RoundManager.Instance).StartCoroutine(<>4__this.LoadNewLevelWait(StartOfRound.Instance.randomMapSeed));
					<>2__current = (object)new WaitUntil((Func<bool>)(() => RoundManager.Instance.dungeonFinishedGeneratingForAllPlayers));
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					SimulateBeeSpawns();
					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();
			}
		}

		public static AssetBundle? NachoAssets;

		public static TMP_FontAsset? ResetFont;

		public static List<GameObject> ResetText = new List<GameObject>();

		public static Canvas? ResetCanvas;

		public static bool CanReset;

		public static bool ChosenSeed;

		public static List<GrabbableObject> spawnedBees = new List<GrabbableObject>();

		public static List<GrabbableObject> scrapGenerated = new List<GrabbableObject>();

		public static bool loadingGame;

		public bool finished = false;

		public bool doneUnloading = false;

		public bool firstRoll = false;

		private ConfigEntry<bool> autoReroll;

		private ConfigEntry<int> minValue;

		private ConfigEntry<int> minOutside;

		private ConfigEntry<int> minScrapAmount;

		public static ResetMod Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)52;
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			NachoAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "nachoreset"));
			if ((Object)(object)NachoAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			ResetFont = NachoAssets.LoadAsset<TMP_FontAsset>("Assets/Perfect DOS VGA 437 SDF.asset");
			autoReroll = ((BaseUnityPlugin)this).Config.Bind<bool>("Auto Reroll", "Enable Auto Reroll", false, new ConfigDescription("Allows you to automatically reroll until finding at least the specified value/scrap amount", (AcceptableValueBase)null, Array.Empty<object>()));
			minValue = ((BaseUnityPlugin)this).Config.Bind<int>("Auto Reroll", "Min Value", 0, new ConfigDescription("Minimum required seed value for auto reroll.", (AcceptableValueBase)null, Array.Empty<object>()));
			minScrapAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Auto Reroll", "Min Scrap Amount", 0, new ConfigDescription("Minimum required scrap amount for auto reroll.", (AcceptableValueBase)null, Array.Empty<object>()));
			minOutside = ((BaseUnityPlugin)this).Config.Bind<int>("Auto Reroll", "Min Outside Amount", 0, new ConfigDescription("Minimum required outside scrap amount for auto reroll.", (AcceptableValueBase)null, Array.Empty<object>()));
			Patch();
			Logger.LogInfo((object)"Nachito.ResetMod v1.0.2 has loaded!");
		}

		public static void CreateResetCanvas()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("AchievementsCanvas");
			ResetCanvas = val.AddComponent<Canvas>();
			ResetCanvas.renderMode = (RenderMode)0;
			CanvasScaler val2 = val.AddComponent<CanvasScaler>();
			val2.referenceResolution = new Vector2(1920f, 1080f);
			val2.screenMatchMode = (ScreenMatchMode)0;
			val2.uiScaleMode = (ScaleMode)1;
			val.AddComponent<GraphicRaycaster>();
		}

		public static TextMeshProUGUI? CreateResetText(Vector2 pos, int size = 36)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ResetCanvas == (Object)null)
			{
				CreateResetCanvas();
			}
			if ((Object)(object)ResetCanvas == (Object)null)
			{
				return null;
			}
			GameObject val = new GameObject("ResetText" + pos.y);
			val.transform.SetParent(((Component)ResetCanvas).transform, false);
			val.AddComponent<CanvasRenderer>();
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).font = ResetFont;
			((TMP_Text)val2).fontSize = size;
			((TMP_Text)val2).characterSpacing = 8f;
			RectTransform component = ((Component)val2).GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(900f, 60f);
			component.anchoredPosition = pos;
			ResetText.Add(val);
			return val2;
		}

		[IteratorStateMachine(typeof(<Reroll>d__31))]
		public IEnumerator Reroll()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Reroll>d__31(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<LoadNewLevelWait>d__32))]
		public IEnumerator LoadNewLevelWait(int randomSeed)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadNewLevelWait>d__32(0)
			{
				<>4__this = this,
				randomSeed = randomSeed
			};
		}

		public void SceneManager_OnLoadComplete(ulong clientId, string sceneName, LoadSceneMode loadSceneMode)
		{
			if (loadingGame)
			{
				firstRoll = false;
			}
		}

		public void SceneManager_OnUnloadComplete(ulong clientId, string sceneName)
		{
			if (loadingGame)
			{
				doneUnloading = true;
			}
		}

		[IteratorStateMachine(typeof(<ChooseSeed>d__35))]
		public IEnumerator ChooseSeed()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ChooseSeed>d__35(0)
			{
				<>4__this = this
			};
		}

		private static void SimulateBeeSpawns()
		{
			RoundManager.Instance.isSpawningEnemies = true;
			RoundManager.Instance.currentHour = RoundManager.Instance.timeScript.hour - 1;
			((MonoBehaviour)Instance).Invoke("AfterDaytimeScrapSpawn", 0.01f);
		}

		public void AfterDaytimeScrapSpawn()
		{
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val in array)
			{
				if (!val.scrapPersistedThroughRounds && (val.itemProperties.itemName.ToLower() == "hive" || val.itemProperties.itemName.ToLower() == "egg"))
				{
					spawnedBees.Add(val);
				}
				else if (val.itemProperties.isScrap && !val.scrapPersistedThroughRounds)
				{
					scrapGenerated.Add(val);
				}
			}
			foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
			{
				Object.Destroy((Object)(object)((Component)spawnedEnemy).gameObject);
			}
			RoundManager.Instance.SpawnedEnemies.Clear();
			if ((Object)(object)ResetCanvas == (Object)null)
			{
				CreateResetCanvas();
			}
			foreach (GameObject item in ResetText)
			{
				Object.Destroy((Object)(object)item.gameObject);
			}
			TextMeshProUGUI val2 = CreateResetText(new Vector2(-50f, 250f));
			((TMP_Text)val2).text = "Seed: " + StartOfRound.Instance.randomMapSeed;
			TextMeshProUGUI val3 = CreateResetText(new Vector2(-50f, 200f));
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 91);
			GrabbableObject[] array2 = Object.FindObjectsOfType<GrabbableObject>();
			for (int j = 0; j < array2.Length; j++)
			{
				if (array2[j].itemProperties.isScrap && !array2[j].scrapPersistedThroughRounds)
				{
					num3 += array2[j].itemProperties.maxValue - array2[j].itemProperties.minValue;
					num2 += Mathf.Clamp(random.Next(array2[j].itemProperties.minValue, array2[j].itemProperties.maxValue), array2[j].scrapValue - 6 * j, array2[j].scrapValue + 9 * j);
					num++;
				}
			}
			((TMP_Text)val3).text = "Item count: " + scrapGenerated.Count + "\nScan Value: " + num2 + "\nOutside Items: " + spawnedBees.Count + "\n\n(R to Reroll, Y to play seed)";
			RoundManager.Instance.currentHour = 0;
			CanReset = true;
			if (autoReroll.Value && (minScrapAmount.Value > scrapGenerated.Count || minOutside.Value > spawnedBees.Count || minValue.Value > num2))
			{
				foreach (GameObject item2 in ResetText)
				{
					Object.Destroy((Object)(object)item2.gameObject);
				}
				ResetText.Clear();
				Instance.doneUnloading = false;
				((NetworkBehaviour)RoundManager.Instance).NetworkManager.SceneManager.UnloadScene(SceneManager.GetSceneAt(1));
				((MonoBehaviour)Instance).StartCoroutine("Reroll");
			}
			foreach (GrabbableObject spawnedBee in spawnedBees)
			{
				Object.Destroy((Object)(object)((Component)spawnedBee).gameObject);
			}
			foreach (GrabbableObject item3 in scrapGenerated)
			{
				Object.Destroy((Object)(object)((Component)item3).gameObject);
			}
			foreach (EnemyAINestSpawnObject enemyNestSpawnObject in RoundManager.Instance.enemyNestSpawnObjects)
			{
				Object.Destroy((Object)(object)((Component)enemyNestSpawnObject).gameObject);
			}
			GrabbableObject[] array3 = Object.FindObjectsOfType<GrabbableObject>();
			foreach (GrabbableObject val4 in array3)
			{
				if (!val4.isInShipRoom && !scrapGenerated.Contains(val4) && !spawnedBees.Contains(val4))
				{
					Object.Destroy((Object)(object)((Component)val4).gameObject);
				}
			}
			spawnedBees.Clear();
			scrapGenerated.Clear();
			RoundManager.Instance.enemyNestSpawnObjects.Clear();
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Nachito.ResetMod");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Nachito.ResetMod";

		public const string PLUGIN_NAME = "ResetMod";

		public const string PLUGIN_VERSION = "1.0.2";
	}
}
namespace ResetMod.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	public class HostPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OnStart(StartOfRound __instance)
		{
			ResetMod.ChosenSeed = false;
		}

		[HarmonyPatch("StartGame")]
		[HarmonyPrefix]
		private static bool StopGameStart(StartOfRound __instance)
		{
			if (__instance.localPlayerController.isHostPlayerObject && StartOfRound.Instance.gameStats.daysSpent <= 0 && !ResetMod.ChosenSeed && __instance.currentLevelID != 3)
			{
				ResetMod.loadingGame = true;
				ResetMod.Instance.firstRoll = true;
				((MonoBehaviour)ResetMod.Instance).StartCoroutine("Reroll");
			}
			else
			{
				ResetMod.ChosenSeed = true;
			}
			if (ResetMod.ChosenSeed)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerPatches
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OnStart()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			NetworkManager.Singleton.SceneManager.OnLoadComplete += new OnLoadCompleteDelegateHandler(ResetMod.Instance.SceneManager_OnLoadComplete);
			NetworkManager.Singleton.SceneManager.OnUnloadComplete += new OnUnloadCompleteDelegateHandler(ResetMod.Instance.SceneManager_OnUnloadComplete);
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CheckButtonPressed(PlayerControllerB __instance)
		{
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			if (!ResetMod.CanReset || ResetMod.ChosenSeed || StartOfRound.Instance.gameStats.daysSpent > 0 || !__instance.isHostPlayerObject)
			{
				return;
			}
			if (((ButtonControl)Keyboard.current.rKey).wasPressedThisFrame)
			{
				foreach (GameObject item in ResetMod.ResetText)
				{
					Object.Destroy((Object)(object)item.gameObject);
				}
				ResetMod.ResetText.Clear();
				ResetMod.Instance.doneUnloading = false;
				((NetworkBehaviour)__instance).NetworkManager.SceneManager.UnloadScene(SceneManager.GetSceneAt(1));
				((MonoBehaviour)ResetMod.Instance).StartCoroutine("Reroll");
			}
			if (!((ButtonControl)Keyboard.current.yKey).wasPressedThisFrame)
			{
				return;
			}
			foreach (GameObject item2 in ResetMod.ResetText)
			{
				Object.Destroy((Object)(object)item2.gameObject);
			}
			ResetMod.ResetText.Clear();
			foreach (EnemyAINestSpawnObject enemyNestSpawnObject in RoundManager.Instance.enemyNestSpawnObjects)
			{
				Object.Destroy((Object)(object)((Component)enemyNestSpawnObject).gameObject);
			}
			RoundManager.Instance.enemyNestSpawnObjects.Clear();
			ResetMod.ChosenSeed = true;
			ResetMod.Instance.doneUnloading = false;
			((NetworkBehaviour)__instance).NetworkManager.SceneManager.UnloadScene(SceneManager.GetSceneAt(1));
			((MonoBehaviour)ResetMod.Instance).StartCoroutine("ChooseSeed");
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatch
	{
		[HarmonyPatch("FinishGeneratingNewLevelClientRpc")]
		[HarmonyPostfix]
		private static void AfterGenerating(RoundManager __instance)
		{
			StartOfRound.Instance.overrideRandomSeed = false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}