Decompiled source of Nachos Achievements v1.1.5

NachoAchievements.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 NachoAchievements.Util;
using Newtonsoft.Json;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
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("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("NachoAchievements")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.5.0")]
[assembly: AssemblyInformationalVersion("1.1.5+2b9f2b47d8cf4dda980a34ee0258b0dfa55e2c48")]
[assembly: AssemblyProduct("NachoAchievements")]
[assembly: AssemblyTitle("NachoAchievements")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.5.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 NachoAchievements
{
	[BepInPlugin("NachoAchievements", "NachoAchievements", "1.1.5")]
	public class NachoAchievements : BaseUnityPlugin
	{
		public static Dictionary<string, Dictionary<string, string>> Achievements = new Dictionary<string, Dictionary<string, string>>();

		public static AssetBundle NachoAssets;

		public static TMP_FontAsset AchievementsFont;

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

		public static Canvas AchievementsCanvas;

		public static Dictionary<string, int> scrapFound = new Dictionary<string, int>();

		public static List<string> enemiesKilled = new List<string>();

		public static GameObject achievementGetText = null;

		public static GameObject achievementGetTextSubtitle = null;

		public static GameObject achievementEnterButton = null;

		private static EventSystem events = EventSystem.current;

		private static PointerEventData pointerData;

		public static TextMeshProUGUI TMP;

		public static string prevText;

		public static float destroyTimer;

		private ConfigEntry<bool> resetAchievements;

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


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


		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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, "nachoachievements"));
			if ((Object)(object)NachoAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			AchievementsFont = NachoAssets.LoadAsset<TMP_FontAsset>("assets/3270-regular sdf.asset");
			Patch();
			resetAchievements = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Reset Achievements", false, new ConfigDescription("Wether to reset every achievement next time you boot up the game (does not include save file-dependent achievements)", (AcceptableValueBase)null, Array.Empty<object>()));
			CreateAchievements();
			WriteAchievements();
			Logger.LogInfo((object)"NachoAchievements v1.1.5 has loaded!");
		}

		private void Update()
		{
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			if (AchievementsText != null && AchievementsText.Count > 0)
			{
				float num = 200f;
				if (((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame)
				{
					for (int i = 0; i < AchievementsText.Count; i++)
					{
						Object.Destroy((Object)(object)AchievementsText[i]);
					}
					QuickMenuManager quickMenuManager = GameNetworkManager.Instance.localPlayerController.quickMenuManager;
					quickMenuManager.CloseQuickMenu();
					Object.Destroy((Object)(object)TMP);
					prevText = string.Empty;
					AchievementsText.Clear();
				}
				if (((InputControl<float>)(object)((Vector2Control)Mouse.current.scroll).y).ReadValue() > 0f)
				{
					for (int j = 0; j < AchievementsText.Count; j++)
					{
						RectTransform component = AchievementsText[j].GetComponent<RectTransform>();
						if (j == 0 && component.anchoredPosition.y <= 450f)
						{
							return;
						}
						component.anchoredPosition -= new Vector2(0f, num);
					}
					if ((Object)(object)TMP != (Object)null)
					{
						RectTransform component2 = ((Component)TMP).GetComponent<RectTransform>();
						if ((Object)(object)component2 != (Object)null)
						{
							component2.anchoredPosition -= new Vector2(0f, num);
						}
					}
				}
				if (((InputControl<float>)(object)((Vector2Control)Mouse.current.scroll).y).ReadValue() < 0f)
				{
					for (int k = 0; k < AchievementsText.Count; k++)
					{
						RectTransform component3 = AchievementsText[k].GetComponent<RectTransform>();
						if (k == 0 && component3.anchoredPosition.y >= (float)(-450 + AchievementsText.Count * 100))
						{
							return;
						}
						component3.anchoredPosition += new Vector2(0f, num);
					}
					if ((Object)(object)TMP != (Object)null)
					{
						RectTransform component4 = ((Component)TMP).GetComponent<RectTransform>();
						if ((Object)(object)component4 != (Object)null)
						{
							component4.anchoredPosition += new Vector2(0f, num);
						}
					}
				}
				pointerData = new PointerEventData(events)
				{
					position = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue()
				};
				List<RaycastResult> list = new List<RaycastResult>();
				Canvas val = Object.FindObjectOfType<Canvas>();
				GraphicRaycaster component5 = ((Component)val).GetComponent<GraphicRaycaster>();
				((BaseRaycaster)component5).Raycast(pointerData, list);
				foreach (RaycastResult item in list)
				{
					RaycastResult current = item;
					TextMeshProUGUI componentInChildren = ((RaycastResult)(ref current)).gameObject.GetComponentInChildren<TextMeshProUGUI>();
					if ((Object)(object)componentInChildren != (Object)null && ((Object)(object)TMP == (Object)null || ((TMP_Text)componentInChildren).text != prevText))
					{
						string[] array = Achievements.Keys.ToArray();
						int num2 = AchievementsText.IndexOf(((RaycastResult)(ref current)).gameObject);
						if (num2 != -1 && Achievements.ContainsKey(array[num2]) && Achievements[array[num2]].ContainsKey("description"))
						{
							string text = Achievements[array[num2]]["description"];
							CreateAchievementDescription(componentInChildren, text);
						}
					}
				}
				if (list.Count <= 0)
				{
					if ((Object)(object)TMP != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)TMP).gameObject);
					}
					prevText = string.Empty;
				}
			}
			if ((Object)(object)achievementGetText != (Object)null)
			{
				destroyTimer += Time.deltaTime;
				if (destroyTimer >= 5f)
				{
					Object.Destroy((Object)(object)achievementGetText);
					Object.Destroy((Object)(object)achievementGetTextSubtitle);
				}
			}
		}

		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("NachoAchievements");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		public static void CheckAchievements(Dictionary<string, string> callback)
		{
			List<string> list = Achievements.Keys.ToList();
			if (!callback.ContainsKey("callback"))
			{
				Logger.LogError((object)"Error! Callback does not exist.");
				return;
			}
			foreach (string item in list)
			{
				if (!Achievements[item].ContainsKey("callback"))
				{
					Logger.LogError((object)("Error! Achievement " + item + " does not contain a callback. Skipping..."));
				}
				else
				{
					if (Achievements[item]["callback"] != callback["callback"])
					{
						continue;
					}
					List<string> list2 = new List<string>();
					List<string> list3 = callback.Keys.ToList();
					foreach (string item2 in list3)
					{
						if (!(item2 == "callback"))
						{
							list2.Add(item2);
						}
					}
					bool flag = true;
					foreach (string item3 in list2)
					{
						string text = callback[item3];
						string empty = string.Empty;
						empty = (Achievements[item].ContainsKey(item3) ? Achievements[item][item3] : "Any");
						switch (item3)
						{
						case "rank":
						{
							if (int.TryParse(empty, out var result2) && int.Parse(text) >= result2)
							{
								continue;
							}
							break;
						}
						case "soundMinDistance":
						{
							if (float.TryParse(empty, out var result) && float.Parse(text) <= result)
							{
								continue;
							}
							break;
						}
						case "amount in ship":
							if ((empty == "True" && callback.ContainsKey("scrap") && Achievements[item].ContainsKey("scrap") && callback["scrap"] == Achievements[item]["scrap"]) || empty == "False")
							{
								flag = false;
								Achievements[item]["progress"] = text;
								if (CheckIfSingleRun(item))
								{
									Instance.SaveAchievementOnServerRpc(item, int.Parse(Achievements[item]["progress"]), StartOfRound.Instance.localPlayerController.playerSteamId);
								}
							}
							break;
						}
						if (empty == "Unique")
						{
							List<string> list4 = ES3.Load<List<string>>(item, "LCGeneralSaveData", new List<string>());
							if ((CheckIfSingleRun(item) && Instance.GetUniqueOnServerRpc(item, StartOfRound.Instance.localPlayerController.playerSteamId).Contains(text)) || (!CheckIfSingleRun(item) && list4.Contains(text)))
							{
								flag = false;
							}
							else
							{
								Instance.SaveUniqueOnServerRpc(item, StartOfRound.Instance.localPlayerController.playerSteamId, text);
								list4.Add(text);
								ES3.Save<List<string>>(item, list4, "LCGeneralSaveData");
							}
						}
						if (text != empty && empty != "Any" && empty != "Unique")
						{
							flag = false;
						}
					}
					if (flag)
					{
						Achievements[item]["progress"] = (int.Parse(Achievements[item]["progress"]) + 1).ToString();
						if (CheckIfSingleRun(item))
						{
							Instance.SaveAchievementOnServerRpc(item, int.Parse(Achievements[item]["progress"]), StartOfRound.Instance.localPlayerController.playerSteamId);
						}
					}
				}
			}
			CheckAchievementCount();
			foreach (string item4 in list)
			{
				if (int.TryParse(Achievements[item4]["count"], out var result3) && int.Parse(Achievements[item4]["progress"]) >= result3 && Achievements[item4]["completed"] == "False")
				{
					CreateAchievementGetText(item4);
					Achievements[item4]["completed"] = "True";
				}
			}
			WriteAchievements();
		}

		public static bool CheckIfSingleRun(string key)
		{
			return Achievements[key].ContainsKey("single run") && Achievements[key]["single run"] == "True";
		}

		[ServerRpc(RequireOwnership = false)]
		public void SaveAchievementOnServerRpc(string key, int progress, ulong playerSteamID)
		{
			ES3.Save<int>("SingleRun" + key + playerSteamID, progress, GameNetworkManager.Instance.currentSaveFileName);
		}

		[ServerRpc(RequireOwnership = false)]
		public string[] GetUniqueOnServerRpc(string key, ulong playerSteamID)
		{
			return ES3.Load<List<string>>(key + playerSteamID, GameNetworkManager.Instance.currentSaveFileName, new List<string>()).ToArray();
		}

		[ServerRpc(RequireOwnership = false)]
		public void SaveUniqueOnServerRpc(string key, ulong playerSteamID, string enemy)
		{
			List<string> list = ES3.Load<List<string>>(key + playerSteamID, GameNetworkManager.Instance.currentSaveFileName, new List<string>());
			if (!list.Contains(enemy))
			{
				list.Add(enemy);
				ES3.Save<List<string>>(key + playerSteamID, list, GameNetworkManager.Instance.currentSaveFileName);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void GetAchievementsOnServerRpc(ulong playerSteamID)
		{
			List<string> list = Achievements.Keys.ToList();
			foreach (string item in list)
			{
				if (CheckIfSingleRun(item))
				{
					int progress = ES3.Load<int>("SingleRun" + item + playerSteamID, GameNetworkManager.Instance.currentSaveFileName, 0);
					SaveAchievementOnClientRpc(item, progress, playerSteamID);
				}
			}
		}

		[ClientRpc]
		public void SaveAchievementOnClientRpc(string key, int progress, ulong playerSteamID)
		{
			if (playerSteamID == GameNetworkManager.Instance.localPlayerController.playerSteamId)
			{
				Achievements[key]["progress"] = progress.ToString();
			}
		}

		public static void ResetSingleDayAchievements()
		{
			List<string> list = Achievements.Keys.ToList();
			foreach (string item in list)
			{
				if (Achievements[item].ContainsKey("single day") && Achievements[item]["single day"] == "True")
				{
					Achievements[item]["progress"] = "0";
				}
			}
		}

		public static void ResetSingleRunAchievements()
		{
			List<string> list = Achievements.Keys.ToList();
			foreach (string item in list)
			{
				if (CheckIfSingleRun(item))
				{
					Achievements[item]["progress"] = "0";
					Instance.SaveAchievementOnServerRpc(item, 0, GameNetworkManager.Instance.localPlayerController.playerSteamId);
				}
			}
		}

		public static void CreateAchievements()
		{
			Paths.CheckFolders();
			string path = Path.Combine(Paths.DataFolder, "achievements.json");
			if (!File.Exists(path) || Instance.resetAchievements.Value)
			{
				File.WriteAllText(path, "");
			}
			string pluginPath = Paths.PluginPath;
			string[] directories = Directory.GetDirectories(pluginPath);
			string[] array = directories;
			foreach (string text in array)
			{
				if (!Directory.Exists(text))
				{
					continue;
				}
				string path2 = Path.Combine(text, "achievements.json");
				if (!File.Exists(path2))
				{
					continue;
				}
				string text2 = File.ReadAllText(path2);
				Dictionary<string, Dictionary<string, string>> dictionary = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(text2);
				string text3 = File.ReadAllText(path);
				Dictionary<string, Dictionary<string, string>> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(text3);
				if (dictionary == null)
				{
					continue;
				}
				foreach (KeyValuePair<string, Dictionary<string, string>> item in dictionary)
				{
					if (dictionary2 != null && dictionary2.ContainsKey(item.Key))
					{
						dictionary[item.Key]["progress"] = dictionary2[item.Key]["progress"];
						dictionary[item.Key]["completed"] = dictionary2[item.Key]["completed"];
					}
					Achievements.Add(item.Key, item.Value);
					Logger.LogInfo((object)("Added Achievement " + item.Key));
				}
			}
			WriteAchievements();
		}

		public static void WriteAchievements()
		{
			Paths.CheckFolders();
			string path = Path.Combine(Paths.DataFolder, "achievements.json");
			File.WriteAllText(path, JsonConvert.SerializeObject((object)Achievements));
		}

		public static void OnAchievementsClicked()
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			QuickMenuManager quickMenuManager = GameNetworkManager.Instance.localPlayerController.quickMenuManager;
			quickMenuManager.mainButtonsPanel.SetActive(false);
			quickMenuManager.playerListPanel.SetActive(false);
			List<string> list = Achievements.Keys.ToList();
			CheckAchievementCount();
			int num = 0;
			for (int i = 0; i < list.Count; i++)
			{
				if (Achievements[list[i]].ContainsValue("Unique") && !CheckIfSingleRun(list[i]))
				{
					Achievements[list[i]]["progress"] = ES3.Load<List<string>>(list[i], "LCGeneralSaveData", new List<string>()).Count.ToString();
				}
				TextMeshProUGUI val = CreateAchievementsText(new Vector2(-150f, (float)(450 - num * 100)), add: true);
				num++;
				string text = list[i];
				if (int.TryParse(Achievements[list[i]]["count"], out var result) && result > 1)
				{
					text = text + " " + ((int.Parse(Achievements[list[i]]["progress"]) <= result) ? Achievements[list[i]]["progress"] : ((object)result))?.ToString() + " / " + result;
				}
				((TMP_Text)val).text = text;
				if (Achievements[list[i]]["completed"] == "True")
				{
					((Graphic)val).color = Color.yellow;
				}
			}
		}

		public static void CheckAchievementCount()
		{
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = Achievements.Keys.ToList();
			foreach (string item in list)
			{
				if (!Achievements[item].ContainsKey("count callback"))
				{
					continue;
				}
				if (Achievements[item]["count callback"] == "Unique Scrap Total")
				{
					int num = 0;
					foreach (Item items in StartOfRound.Instance.allItemsList.itemsList)
					{
						if (items.isScrap)
						{
							num++;
						}
					}
					Achievements[item]["count"] = num.ToString();
				}
				else
				{
					if (!(Achievements[item]["count callback"] == "All Scrap Today") || !RoundManager.Instance.dungeonFinishedGeneratingForAllPlayers)
					{
						continue;
					}
					int num2 = 0;
					int num3 = 0;
					GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
					foreach (GrabbableObject val in array)
					{
						if (Object.op_Implicit((Object)(object)val.itemProperties) && val.itemProperties.isScrap)
						{
							Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
							if (!((Bounds)(ref bounds)).Contains(((Component)val).gameObject.transform.position))
							{
								num2++;
							}
							else if (RoundManager.Instance.scrapCollectedThisRound.Contains(val))
							{
								num3++;
							}
						}
					}
					if (Achievements[item].ContainsKey("moon") && (StartOfRound.Instance.currentLevelID.ToString() == Achievements[item]["moon"] || Achievements[item]["moon"] == "Any"))
					{
						Achievements[item]["count"] = (num2 + num3).ToString();
					}
				}
			}
		}

		public static TextMeshProUGUI CreateAchievementsText(Vector2 pos, bool add, int size = 36)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)AchievementsCanvas == (Object)null)
			{
				CreateAchievementsCanvas();
			}
			GameObject val = new GameObject("AchievementsText" + pos.y);
			val.transform.SetParent(((Component)AchievementsCanvas).transform, false);
			val.AddComponent<CanvasRenderer>();
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).font = AchievementsFont;
			((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;
			if (add)
			{
				AchievementsText.Add(val);
			}
			return val2;
		}

		public static TextMeshProUGUI CreateAchievementGetText(string text)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)AchievementsCanvas == (Object)null)
			{
				CreateAchievementsCanvas();
			}
			if ((Object)(object)achievementGetText != (Object)null)
			{
				Object.Destroy((Object)(object)achievementGetText);
			}
			if ((Object)(object)achievementGetTextSubtitle != (Object)null)
			{
				Object.Destroy((Object)(object)achievementGetTextSubtitle);
			}
			achievementGetText = new GameObject("AchievementGetText");
			achievementGetText.transform.SetParent(((Component)AchievementsCanvas).transform, false);
			achievementGetText.AddComponent<CanvasRenderer>();
			TextMeshProUGUI val = achievementGetText.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val).font = AchievementsFont;
			((TMP_Text)val).fontSize = 128f;
			((TMP_Text)val).text = "<mark=#00000060>ACHIEVEMENT GET!</mark>";
			((TMP_Text)val).m_textAlignment = (TextAlignmentOptions)514;
			((Graphic)val).color = Color.yellow;
			((TMP_Text)val).SetOutlineThickness(0.05f);
			((TMP_Text)val).SetOutlineColor(Color32.op_Implicit(Color.black));
			((TMP_Text)val).characterSpacing = 8f;
			RectTransform component = ((Component)val).GetComponent<RectTransform>();
			component.anchoredPosition += new Vector2(310f, 500f);
			component.sizeDelta += new Vector2(1500f, 0f);
			achievementGetTextSubtitle = new GameObject("AchievementGetText");
			achievementGetTextSubtitle.transform.SetParent(((Component)AchievementsCanvas).transform, false);
			achievementGetTextSubtitle.AddComponent<CanvasRenderer>();
			TextMeshProUGUI val2 = achievementGetTextSubtitle.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).font = AchievementsFont;
			((TMP_Text)val2).fontSize = 64f;
			((TMP_Text)val2).text = "<mark=#00000060>" + text + "</mark>";
			((TMP_Text)val2).m_textAlignment = (TextAlignmentOptions)514;
			((Graphic)val2).color = Color.yellow;
			((TMP_Text)val2).SetOutlineThickness(0.05f);
			((TMP_Text)val2).SetOutlineColor(Color32.op_Implicit(Color.black));
			((TMP_Text)val2).characterSpacing = 8f;
			RectTransform component2 = ((Component)val2).GetComponent<RectTransform>();
			component2.sizeDelta += new Vector2(1500f, 0f);
			component2.anchoredPosition = component.anchoredPosition - new Vector2(-2f, 150f);
			destroyTimer = 0f;
			HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.levelIncreaseSFX);
			return val;
		}

		public static void CreateAchievementsCanvas()
		{
			//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");
			AchievementsCanvas = val.AddComponent<Canvas>();
			AchievementsCanvas.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 void CreateAchievementDescription(TextMeshProUGUI tmp, string text)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (!(text == prevText))
			{
				if ((Object)(object)TMP != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)TMP).gameObject);
				}
				TMP = CreateAchievementsText(((Component)tmp).GetComponent<RectTransform>().anchoredPosition + new Vector2(600f, 0f), add: false);
				((TMP_Text)TMP).text = text;
				prevText = text;
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NachoAchievements";

		public const string PLUGIN_NAME = "NachoAchievements";

		public const string PLUGIN_VERSION = "1.1.5";
	}
}
namespace NachoAchievements.Util
{
	public static class Paths
	{
		public static string ExecutionPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		public static string GameFolder => Path.GetDirectoryName(Application.dataPath);

		public static string BepInExFolder => Path.Combine(GameFolder, "BepInEx");

		public static string BepInExConfigFolder => Path.Combine(BepInExFolder, "config");

		public static string DataFolder => Path.Combine(BepInExConfigFolder, "NachosAchievements");

		public static void CheckFolders()
		{
			if (!Directory.Exists(DataFolder))
			{
				Directory.CreateDirectory(DataFolder);
			}
		}
	}
}
namespace NachoAchievements.Patches
{
	[HarmonyPatch(typeof(Button))]
	internal class ButtonPatches
	{
		[HarmonyPatch("Press")]
		[HarmonyPrefix]
		private static bool OnPress(Button __instance)
		{
			if ((Object)(object)NachoAchievements.achievementEnterButton != (Object)null && (Object)(object)__instance == (Object)(object)NachoAchievements.achievementEnterButton.GetComponentInChildren<Button>())
			{
				NachoAchievements.OnAchievementsClicked();
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(EnemyAI))]
	internal class EnemyAIPatches
	{
		private static Dictionary<EnemyAI, float> enemiesStareTime = new Dictionary<EnemyAI, float>();

		[HarmonyPatch("DetectNoise")]
		[HarmonyPostfix]
		private static void OnDetectNoise(EnemyAI __instance, Vector3 noisePosition, float noiseLoudness, int timesPlayedInOneSpot = 0, int noiseID = 0)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (!Physics.Linecast(((Component)__instance).transform.position, noisePosition, StartOfRound.Instance.collidersAndRoomMask))
			{
				int num = noiseID;
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				dictionary.Add("callback", "On Enemy Sound Heard");
				dictionary.Add("enemy", __instance.enemyType.enemyName);
				dictionary.Add("sound", num.ToString());
				dictionary.Add("soundMinDistance", Vector3.Distance(((Component)__instance).transform.position, noisePosition).ToString());
				dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
				dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
				NachoAchievements.CheckAchievements(dictionary);
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void CheckStaring(EnemyAI __instance)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (!enemiesStareTime.ContainsKey(__instance))
			{
				enemiesStareTime.Add(__instance, 0f);
			}
			if (StartOfRound.Instance.localPlayerController.HasLineOfSightToPosition(((Component)__instance).transform.position + Vector3.up * 0.4f, 60f, 100, 5f))
			{
				enemiesStareTime[__instance] += Time.deltaTime;
				if (enemiesStareTime[__instance] >= 5f)
				{
					Dictionary<string, string> dictionary = new Dictionary<string, string>();
					dictionary.Add("callback", "Enemy Stared At");
					dictionary.Add("enemy", __instance.enemyType.enemyName);
					dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
					dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
					NachoAchievements.CheckAchievements(dictionary);
					enemiesStareTime[__instance] = 0f;
				}
			}
			else
			{
				enemiesStareTime[__instance] = 0f;
			}
		}

		[HarmonyPatch("OnDestroy")]
		[HarmonyPostfix]
		private static void OnDestroyed(EnemyAI __instance)
		{
			enemiesStareTime.Clear();
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatches
	{
		[HarmonyPatch("AttemptScanNewCreature")]
		[HarmonyPostfix]
		private static void OnAttemptNewCreatureScan(HUDManager __instance)
		{
		}

		[HarmonyPatch("FillEndGameStats")]
		[HarmonyPostfix]
		private static void OnResultsFilled(HUDManager __instance)
		{
			int num = 0;
			int num2 = 0;
			for (int i = 0; i < __instance.playersManager.allPlayerScripts.Length; i++)
			{
				PlayerControllerB val = __instance.playersManager.allPlayerScripts[i];
				if (val.disconnectedMidGame || val.isPlayerDead || val.isPlayerControlled)
				{
					if (val.isPlayerDead)
					{
						num++;
					}
					else if (val.isPlayerControlled)
					{
						num2++;
					}
				}
				int num3 = 0;
				float num4 = (float)RoundManager.Instance.scrapCollectedInLevel / RoundManager.Instance.totalScrapValueInLevel;
				if (num2 == StartOfRound.Instance.connectedPlayersAmount + 1)
				{
					num3++;
				}
				else if (num > 1)
				{
					num3--;
				}
				if (num4 >= 0.99f)
				{
					num3 += 2;
				}
				else if (num4 >= 0.6f)
				{
					num3++;
				}
				else if (num4 <= 0.25f)
				{
					num3--;
				}
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				dictionary.Add("callback", "On Rank Or Above Gotten");
				dictionary.Add("rank", num3.ToString());
				dictionary.Add("weapon", "Landmine");
				dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
				dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
				NachoAchievements.CheckAchievements(dictionary);
			}
		}
	}
	[HarmonyPatch(typeof(KnifeItem))]
	internal class KnifePatches
	{
		[HarmonyPatch("HitKnife")]
		[HarmonyPrefix]
		private static void OnHitKnife(KnifeItem __instance, bool cancel = false)
		{
			//IL_0048: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.previousPlayerHeldBy == (Object)null || cancel || !(Time.realtimeSinceStartup - __instance.timeAtLastDamageDealt > 0.43f))
			{
				return;
			}
			RaycastHit[] source = Physics.SphereCastAll(((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.right * 0.1f, 0.3f, ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.forward, 0.75f, __instance.knifeMask, (QueryTriggerInteraction)2);
			List<RaycastHit> list = source.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
			List<EnemyAI> list2 = new List<EnemyAI>();
			IHittable val2 = default(IHittable);
			for (int i = 0; i < list.Count; i++)
			{
				RaycastHit val = list[i];
				if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer == 8)
				{
					continue;
				}
				val = list[i];
				if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer == 11)
				{
					continue;
				}
				val = list[i];
				if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
				{
					continue;
				}
				val = list[i];
				if ((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)__instance.previousPlayerHeldBy).transform)
				{
					continue;
				}
				val = list[i];
				if (!(((RaycastHit)(ref val)).point == Vector3.zero))
				{
					Vector3 position = ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.position;
					RaycastHit val3 = list[i];
					if (Physics.Linecast(position, ((RaycastHit)(ref val3)).point, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
					{
						continue;
					}
				}
				Vector3 forward = ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.forward;
				val = list[i];
				EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<EnemyAICollisionDetect>();
				if ((Object)(object)component != (Object)null && !((Object)(object)component.mainScript == (Object)null) && !list2.Contains(component.mainScript))
				{
					if (component.mainScript.enemyHP > 0 && component.mainScript.enemyHP - ((component.mainScript.enemyType.enemyName == "Butler") ? 100 : __instance.knifeHitForce) <= 0)
					{
						Dictionary<string, string> dictionary = new Dictionary<string, string>();
						dictionary.Add("callback", "On Kill Enemy");
						dictionary.Add("enemy", component.mainScript.enemyType.enemyName);
						dictionary.Add("weapon", "Knife");
						dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
						dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
						dictionary.Add("local", ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
						NachoAchievements.CheckAchievements(dictionary);
					}
					list2.Add(component.mainScript);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Landmine))]
	internal class LandminePatches
	{
		private static bool playerSetOffMine = false;

		private static List<EnemyAI> enemiesThatWereAlive = new List<EnemyAI>();

		[HarmonyPatch("OnTriggerExit")]
		[HarmonyPrefix]
		private static void OnMineSetOff(Landmine __instance, Collider other)
		{
			if (!__instance.hasExploded && __instance.mineActivated)
			{
				PlayerControllerB component = ((Component)other).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component != (Object)null && (Object)(object)component == (Object)(object)StartOfRound.Instance.localPlayerController)
				{
					playerSetOffMine = true;
				}
			}
		}

		[HarmonyPatch("SpawnExplosion")]
		[HarmonyPrefix]
		private static void OnMineExploded(Landmine __instance, Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f, int nonLethalDamage = 50, float physicsForce = 0f, GameObject overridePrefab = null, bool goThroughCar = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			Collider[] array = Physics.OverlapSphere(explosionPosition, damageRange, 2621448, (QueryTriggerInteraction)2);
			RaycastHit val = default(RaycastHit);
			for (int i = 0; i < array.Length; i++)
			{
				float num = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
				if ((!Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, ref val, 1073742080, (QueryTriggerInteraction)1) || ((goThroughCar || ((Component)((RaycastHit)(ref val)).collider).gameObject.layer != 30) && !(num > 4f))) && ((Component)array[i]).gameObject.layer == 19)
				{
					EnemyAICollisionDetect componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren != (Object)null && ((NetworkBehaviour)componentInChildren.mainScript).IsOwner && num < 4.5f && !componentInChildren.mainScript.isEnemyDead)
					{
						enemiesThatWereAlive.Add(componentInChildren.mainScript);
					}
				}
			}
		}

		[HarmonyPatch("SpawnExplosion")]
		[HarmonyPostfix]
		private static void PostMineExploded(Landmine __instance, Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f, int nonLethalDamage = 50, float physicsForce = 0f, GameObject overridePrefab = null, bool goThroughCar = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			Collider[] array = Physics.OverlapSphere(explosionPosition, damageRange, 2621448, (QueryTriggerInteraction)2);
			RaycastHit val = default(RaycastHit);
			for (int i = 0; i < array.Length; i++)
			{
				float num = Vector3.Distance(explosionPosition, ((Component)array[i]).transform.position);
				if ((!Physics.Linecast(explosionPosition, ((Component)array[i]).transform.position + Vector3.up * 0.3f, ref val, 1073742080, (QueryTriggerInteraction)1) || ((goThroughCar || ((Component)((RaycastHit)(ref val)).collider).gameObject.layer != 30) && !(num > 4f))) && ((Component)array[i]).gameObject.layer == 19)
				{
					EnemyAICollisionDetect componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren != (Object)null && ((NetworkBehaviour)componentInChildren.mainScript).IsOwner && num < 4.5f && componentInChildren.mainScript.isEnemyDead && enemiesThatWereAlive.Contains(componentInChildren.mainScript))
					{
						Dictionary<string, string> dictionary = new Dictionary<string, string>();
						dictionary.Add("callback", "On Kill Enemy");
						dictionary.Add("enemy", componentInChildren.mainScript.enemyType.enemyName);
						dictionary.Add("weapon", "Landmine");
						dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
						dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
						dictionary.Add("local", playerSetOffMine.ToString());
						NachoAchievements.CheckAchievements(dictionary);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(QuickMenuManager))]
	internal class MenuManagerPatches
	{
		[HarmonyPatch("OpenQuickMenu")]
		[HarmonyPostfix]
		private static void AddMenuButton(QuickMenuManager __instance)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.mainButtonsPanel.activeSelf)
			{
				return;
			}
			Transform[] componentsInChildren = __instance.mainButtonsPanel.GetComponentsInChildren<Transform>();
			foreach (Transform val in componentsInChildren)
			{
				GameObject gameObject = ((Component)val).gameObject;
				if (((Object)gameObject).name == "Resume" && (Object)(object)NachoAchievements.achievementEnterButton == (Object)null)
				{
					RectTransform componentInChildren = gameObject.GetComponentInChildren<RectTransform>();
					componentInChildren.anchoredPosition += new Vector2(0f, 90f);
					NachoAchievements.achievementEnterButton = Object.Instantiate<GameObject>(gameObject, __instance.mainButtonsPanel.transform);
					RectTransform component = NachoAchievements.achievementEnterButton.GetComponent<RectTransform>();
					component.anchoredPosition -= new Vector2(0f, 90f);
					((TMP_Text)NachoAchievements.achievementEnterButton.GetComponentInChildren<TextMeshProUGUI>()).text = "> Achievements";
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatches
	{
		public static Dictionary<GrabbableObject, PlayerControllerB> playerDroppedBy = new Dictionary<GrabbableObject, PlayerControllerB>();

		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		private static void OnPlayerDeath(PlayerControllerB __instance, CauseOfDeath causeOfDeath = 0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			CauseOfDeath val = causeOfDeath;
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			dictionary.Add("callback", "On Death");
			dictionary.Add("cause", ((object)(CauseOfDeath)(ref val)).ToString());
			dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
			dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
			dictionary.Add("local", ((Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
			NachoAchievements.CheckAchievements(dictionary);
		}

		[HarmonyPatch("GrabObject")]
		[HarmonyPostfix]
		private static void OnGrabObject(PlayerControllerB __instance)
		{
			if (__instance.ItemSlots != null)
			{
				int num = Mathf.RoundToInt(Mathf.Clamp(__instance.carryWeight - 1f, 0f, 100f) * 105f);
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				dictionary.Add("callback", "On Grab Object");
				dictionary.Add("weight", num.ToString());
				dictionary.Add("scrap", __instance.currentlyGrabbingObject.itemProperties.itemName);
				dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
				dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
				dictionary.Add("local", ((Object)(object)__instance == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
				NachoAchievements.CheckAchievements(dictionary);
			}
		}

		[HarmonyPatch("DiscardHeldObject")]
		[HarmonyPrefix]
		private static void OnPlaceObject(PlayerControllerB __instance)
		{
			playerDroppedBy[__instance.currentlyHeldObjectServer] = __instance;
		}

		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		private static void OnClientConnect(PlayerControllerB __instance)
		{
			NachoAchievements.Instance.GetAchievementsOnServerRpc(__instance.playerSteamId);
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			dictionary.Add("callback", "On Player Join");
			dictionary.Add("players", __instance.playersManager.allPlayerScripts.Length.ToString());
			NachoAchievements.CheckAchievements(dictionary);
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class RoundManagerPatches
	{
		[HarmonyPatch("CollectNewScrapForThisRound")]
		[HarmonyPrefix]
		private static void AddScrapAchievements(RoundManager __instance, GrabbableObject scrapObject)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (scrapObject.scrapPersistedThroughRounds || __instance.scrapCollectedThisRound.Contains(scrapObject))
			{
				return;
			}
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			int num = 0;
			GrabbableObject[] array2 = array;
			foreach (GrabbableObject val in array2)
			{
				if (val.itemProperties.itemName == scrapObject.itemProperties.itemName)
				{
					Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
					if (((Bounds)(ref bounds)).Contains(((Component)val).gameObject.transform.position))
					{
						num++;
					}
				}
			}
			if (scrapObject.itemProperties.isScrap)
			{
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				dictionary.Add("callback", "On Scrap Collected");
				dictionary.Add("scrap", scrapObject.itemProperties.itemName);
				dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
				dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
				dictionary.Add("amount in ship", num.ToString());
				dictionary.Add("local", ((Object)(object)scrapObject.playerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
				NachoAchievements.CheckAchievements(dictionary);
			}
			else
			{
				Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
				dictionary2.Add("callback", "On Item Collected");
				dictionary2.Add("scrap", scrapObject.itemProperties.itemName);
				dictionary2.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
				dictionary2.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
				dictionary2.Add("amount in ship", num.ToString());
				dictionary2.Add("local", ((Object)(object)scrapObject.playerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
				NachoAchievements.CheckAchievements(dictionary2);
			}
		}

		[HarmonyPatch("FinishGeneratingLevel")]
		[HarmonyPostfix]
		private static void OnLevelFinishedLoading(RoundManager __instance)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			dictionary.Add("callback", "On Level Finished Loading");
			dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
			dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
			NachoAchievements.CheckAchievements(dictionary);
		}

		[HarmonyPatch("DestroyTreeAtPosition")]
		[HarmonyPrefix]
		private static void OnDestroyTree(RoundManager __instance, Vector3 pos, float range = 5f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (Physics.OverlapSphereNonAlloc(pos, range, __instance.tempColliderResults, 33554432, (QueryTriggerInteraction)1) != 0)
			{
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				dictionary.Add("callback", "On Tree Destroyed");
				dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
				dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
				dictionary.Add("local", TerrainObstacleTriggerPatches.driverWhoCollidedIsSelf.ToString());
				NachoAchievements.CheckAchievements(dictionary);
				TerrainObstacleTriggerPatches.driverWhoCollidedIsSelf = false;
			}
		}
	}
	[HarmonyPatch(typeof(SandWormAI))]
	internal class SandWormAIPatches
	{
		[HarmonyPatch("OnCollideWithEnemy")]
		[HarmonyPostfix]
		private static void OnWormEatEnemy(SandWormAI __instance, EnemyAI enemyScript = null)
		{
			if (__instance.emerged)
			{
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				dictionary.Add("callback", "On Kill Enemy");
				dictionary.Add("enemy", enemyScript.enemyType.enemyName);
				dictionary.Add("weapon", "Worm");
				dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
				dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
				dictionary.Add("local", ((Object)(object)((EnemyAI)__instance).targetPlayer == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
				NachoAchievements.CheckAchievements(dictionary);
			}
		}
	}
	[HarmonyPatch(typeof(ShotgunItem))]
	internal class ShotgunPatches
	{
		private static List<EnemyAI> enemiesThatWereAlive = new List<EnemyAI>();

		[HarmonyPatch("ShootGun")]
		[HarmonyPrefix]
		private static void OnGunShotPre(ShotgunItem __instance, Vector3 shotgunPosition, Vector3 shotgunForward)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0027: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			enemiesThatWereAlive.Clear();
			RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[10];
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(shotgunPosition - shotgunForward * 10f, shotgunForward);
			int num = Physics.SphereCastNonAlloc(val, 5f, array, 15f, 524288, (QueryTriggerInteraction)2);
			List<EnemyAI> list = new List<EnemyAI>();
			RaycastHit val2 = default(RaycastHit);
			IHittable val3 = default(IHittable);
			for (int i = 0; i < num; i++)
			{
				if (!Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref array[i])).transform).GetComponent<EnemyAICollisionDetect>()))
				{
					continue;
				}
				EnemyAI mainScript = ((Component)((RaycastHit)(ref array[i])).transform).GetComponent<EnemyAICollisionDetect>().mainScript;
				if (((Object)(object)__instance.heldByEnemy != (Object)null && (Object)(object)__instance.heldByEnemy == (Object)(object)mainScript) || ((RaycastHit)(ref array[i])).distance == 0f || Physics.Linecast(shotgunPosition, ((RaycastHit)(ref array[i])).point, ref val2, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) || !((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<IHittable>(ref val3))
				{
					continue;
				}
				float num2 = Vector3.Distance(shotgunPosition, ((RaycastHit)(ref array[i])).point);
				int num3 = ((num2 < 3.7f) ? 5 : ((!(num2 < 6f)) ? 2 : 3));
				EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref array[i])).collider).GetComponent<EnemyAICollisionDetect>();
				if ((!((Object)(object)component != (Object)null) || (!((Object)(object)component.mainScript == (Object)null) && !list.Contains(component.mainScript))) && (Object)(object)component != (Object)null)
				{
					if (!component.mainScript.isEnemyDead)
					{
						enemiesThatWereAlive.Add(component.mainScript);
					}
					list.Add(component.mainScript);
				}
			}
		}

		[HarmonyPatch("ShootGun")]
		[HarmonyPostfix]
		private static void OnGunShot(ShotgunItem __instance, Vector3 shotgunPosition, Vector3 shotgunForward)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[10];
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(shotgunPosition - shotgunForward * 10f, shotgunForward);
			int num = Physics.SphereCastNonAlloc(val, 5f, array, 15f, 524288, (QueryTriggerInteraction)2);
			List<EnemyAI> list = new List<EnemyAI>();
			int num2 = 0;
			RaycastHit val2 = default(RaycastHit);
			IHittable val3 = default(IHittable);
			for (int i = 0; i < num; i++)
			{
				if (!Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref array[i])).transform).GetComponent<EnemyAICollisionDetect>()))
				{
					continue;
				}
				EnemyAI mainScript = ((Component)((RaycastHit)(ref array[i])).transform).GetComponent<EnemyAICollisionDetect>().mainScript;
				if (((Object)(object)__instance.heldByEnemy != (Object)null && (Object)(object)__instance.heldByEnemy == (Object)(object)mainScript) || ((RaycastHit)(ref array[i])).distance == 0f || Physics.Linecast(shotgunPosition, ((RaycastHit)(ref array[i])).point, ref val2, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) || !((Component)((RaycastHit)(ref array[i])).transform).TryGetComponent<IHittable>(ref val3))
				{
					continue;
				}
				float num3 = Vector3.Distance(shotgunPosition, ((RaycastHit)(ref array[i])).point);
				int num4 = ((num3 < 3.7f) ? 5 : ((!(num3 < 6f)) ? 2 : 3));
				EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref array[i])).collider).GetComponent<EnemyAICollisionDetect>();
				if ((!((Object)(object)component != (Object)null) || (!((Object)(object)component.mainScript == (Object)null) && !list.Contains(component.mainScript))) && (Object)(object)component != (Object)null)
				{
					if (component.mainScript.isEnemyDead && enemiesThatWereAlive.Contains(component.mainScript))
					{
						Dictionary<string, string> dictionary = new Dictionary<string, string>();
						dictionary.Add("callback", "On Kill Enemy");
						dictionary.Add("enemy", component.mainScript.enemyType.enemyName);
						dictionary.Add("weapon", "Shotgun");
						dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
						dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
						dictionary.Add("local", ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
						NachoAchievements.CheckAchievements(dictionary);
					}
					list.Add(component.mainScript);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Shovel))]
	internal class ShovelPatches
	{
		private static List<EnemyAI> enemiesThatWereAlive = new List<EnemyAI>();

		[HarmonyPatch("HitShovel")]
		[HarmonyPrefix]
		private static void PreHitShovel(Shovel __instance, bool cancel = false)
		{
			//IL_0035: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			enemiesThatWereAlive.Clear();
			if (cancel)
			{
				return;
			}
			__instance.previousPlayerHeldBy.twoHanded = false;
			__instance.objectsHitByShovel = Physics.SphereCastAll(((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.forward, 1.5f, __instance.shovelMask, (QueryTriggerInteraction)2);
			__instance.objectsHitByShovelList = __instance.objectsHitByShovel.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
			List<EnemyAI> list = new List<EnemyAI>();
			IHittable val2 = default(IHittable);
			for (int i = 0; i < __instance.objectsHitByShovelList.Count; i++)
			{
				RaycastHit val = __instance.objectsHitByShovelList[i];
				if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
				{
					continue;
				}
				val = __instance.objectsHitByShovelList[i];
				if ((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)__instance.previousPlayerHeldBy).transform)
				{
					continue;
				}
				val = __instance.objectsHitByShovelList[i];
				if (!(((RaycastHit)(ref val)).point == Vector3.zero))
				{
					Vector3 position = ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.position;
					RaycastHit val3 = __instance.objectsHitByShovelList[i];
					if (Physics.Linecast(position, ((RaycastHit)(ref val3)).point, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
					{
						continue;
					}
				}
				Vector3 forward = ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.forward;
				val = __instance.objectsHitByShovelList[i];
				EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<EnemyAICollisionDetect>();
				if ((Object)(object)component != (Object)null && !((Object)(object)component.mainScript == (Object)null) && !list.Contains(component.mainScript) && (!StartOfRound.Instance.hangarDoorsClosed || component.mainScript.isInsidePlayerShip == __instance.previousPlayerHeldBy.isInHangarShipRoom))
				{
					if (!component.mainScript.isEnemyDead)
					{
						enemiesThatWereAlive.Add(component.mainScript);
					}
					list.Add(component.mainScript);
				}
			}
		}

		[HarmonyPatch("HitShovel")]
		[HarmonyPostfix]
		private static void PostHitShovel(Shovel __instance, bool cancel = false)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			if (cancel)
			{
				return;
			}
			__instance.previousPlayerHeldBy.twoHanded = false;
			__instance.objectsHitByShovel = Physics.SphereCastAll(((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.position + ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.right * -0.35f, 0.8f, ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.forward, 1.5f, __instance.shovelMask, (QueryTriggerInteraction)2);
			__instance.objectsHitByShovelList = __instance.objectsHitByShovel.OrderBy((RaycastHit x) => ((RaycastHit)(ref x)).distance).ToList();
			List<EnemyAI> list = new List<EnemyAI>();
			IHittable val2 = default(IHittable);
			for (int i = 0; i < __instance.objectsHitByShovelList.Count; i++)
			{
				RaycastHit val = __instance.objectsHitByShovelList[i];
				if (!((Component)((RaycastHit)(ref val)).transform).TryGetComponent<IHittable>(ref val2))
				{
					continue;
				}
				val = __instance.objectsHitByShovelList[i];
				if ((Object)(object)((RaycastHit)(ref val)).transform == (Object)(object)((Component)__instance.previousPlayerHeldBy).transform)
				{
					continue;
				}
				val = __instance.objectsHitByShovelList[i];
				if (!(((RaycastHit)(ref val)).point == Vector3.zero))
				{
					Vector3 position = ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.position;
					RaycastHit val3 = __instance.objectsHitByShovelList[i];
					if (Physics.Linecast(position, ((RaycastHit)(ref val3)).point, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1))
					{
						continue;
					}
				}
				Vector3 forward = ((Component)__instance.previousPlayerHeldBy.gameplayCamera).transform.forward;
				val = __instance.objectsHitByShovelList[i];
				EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref val)).transform).GetComponent<EnemyAICollisionDetect>();
				if ((Object)(object)component != (Object)null && !((Object)(object)component.mainScript == (Object)null) && !list.Contains(component.mainScript) && (!StartOfRound.Instance.hangarDoorsClosed || component.mainScript.isInsidePlayerShip == __instance.previousPlayerHeldBy.isInHangarShipRoom))
				{
					if (component.mainScript.isEnemyDead && enemiesThatWereAlive.Contains(component.mainScript))
					{
						Dictionary<string, string> dictionary = new Dictionary<string, string>();
						dictionary.Add("callback", "On Kill Enemy");
						dictionary.Add("enemy", component.mainScript.enemyType.enemyName);
						dictionary.Add("weapon", "Shovel");
						dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
						dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
						dictionary.Add("local", ((Object)(object)((GrabbableObject)__instance).playerHeldBy == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
						NachoAchievements.CheckAchievements(dictionary);
					}
					list.Add(component.mainScript);
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatches
	{
		[HarmonyPatch("OnLocalDisconnect")]
		[HarmonyPostfix]
		private static void OnDisconnect(StartOfRound __instance)
		{
			NachoAchievements.ResetSingleDayAchievements();
		}

		[HarmonyPatch("ShipHasLeft")]
		[HarmonyPostfix]
		private static void OnShipLeft(StartOfRound __instance)
		{
			NachoAchievements.ResetSingleDayAchievements();
		}
	}
	[HarmonyPatch(typeof(StormyWeather))]
	internal class StormyPatches
	{
		[HarmonyPatch("LightningStrike")]
		[HarmonyPrefix]
		private static void SpawnLightningPatch(StormyWeather __instance, Vector3 strikePosition, bool useTargetedObject)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(strikePosition + Vector3.up * 0.25f, 5f, 2621448, (QueryTriggerInteraction)2);
			List<EnemyAI> list = new List<EnemyAI>();
			for (int i = 0; i < array.Length; i++)
			{
				float num = Vector3.Distance(strikePosition + Vector3.up * 0.25f, ((Component)array[i]).transform.position);
				if (((Component)array[i]).gameObject.layer == 19)
				{
					EnemyAICollisionDetect componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
					if ((Object)(object)componentInChildren != (Object)null && ((NetworkBehaviour)componentInChildren.mainScript).IsOwner && num < 4.5f && componentInChildren.mainScript.enemyHP > 0 && componentInChildren.mainScript.enemyType.canDie && !list.Contains(componentInChildren.mainScript))
					{
						Dictionary<string, string> dictionary = new Dictionary<string, string>();
						dictionary.Add("callback", "On Kill Enemy");
						dictionary.Add("enemy", componentInChildren.mainScript.enemyType.enemyName);
						dictionary.Add("weapon", "Lightning");
						dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
						dictionary.Add("local", (useTargetedObject && PlayerControllerBPatches.playerDroppedBy.ContainsKey(__instance.targetingMetalObject) && (Object)(object)PlayerControllerBPatches.playerDroppedBy[__instance.targetingMetalObject] == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
						dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
						NachoAchievements.CheckAchievements(dictionary);
						list.Add(componentInChildren.mainScript);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(StoryLog))]
	internal class StoryLogPatches
	{
		[HarmonyPatch("CollectLog")]
		[HarmonyPostfix]
		private static void OnStoryLogCollected(StoryLog __instance)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			dictionary.Add("callback", "On Log Collected");
			dictionary.Add("logID", __instance.storyLogID.ToString());
			dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
			dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
			NachoAchievements.CheckAchievements(dictionary);
		}
	}
	[HarmonyPatch(typeof(StunGrenadeItem))]
	internal class StunGrenadePatches
	{
		[HarmonyPatch("ExplodeStunGrenade")]
		[HarmonyPrefix]
		private static void ExplodeGrenadePatch(StunGrenadeItem __instance)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0043: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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)
			if (!(((GrabbableObject)__instance).itemProperties.itemName == "Easter egg") || !__instance.explodeOnThrow)
			{
				return;
			}
			Collider[] array = Physics.OverlapSphere(((Component)__instance).transform.position + Vector3.up * 0.2f, 3f, 2621448, (QueryTriggerInteraction)2);
			List<EnemyAI> list = new List<EnemyAI>();
			for (int i = 0; i < array.Length; i++)
			{
				float num = Vector3.Distance(((Component)__instance).transform.position + Vector3.up * 0.2f, ((Component)array[i]).transform.position);
				if (((Component)array[i]).gameObject.layer != 19)
				{
					continue;
				}
				EnemyAICollisionDetect componentInChildren = ((Component)array[i]).gameObject.GetComponentInChildren<EnemyAICollisionDetect>();
				if ((Object)(object)componentInChildren != (Object)null && ((NetworkBehaviour)componentInChildren.mainScript).IsOwner && num < 4.5f && !list.Contains(componentInChildren.mainScript) && componentInChildren.mainScript.enemyType.canDie)
				{
					if (!componentInChildren.mainScript.isEnemyDead)
					{
						Dictionary<string, string> dictionary = new Dictionary<string, string>();
						dictionary.Add("callback", "On Kill Enemy");
						dictionary.Add("enemy", componentInChildren.mainScript.enemyType.enemyName);
						dictionary.Add("weapon", "Easter egg");
						dictionary.Add("moon", StartOfRound.Instance.currentLevelID.ToString());
						dictionary.Add("challenge", StartOfRound.Instance.isChallengeFile.ToString());
						dictionary.Add("local", ((Object)(object)__instance.playerThrownBy == (Object)(object)StartOfRound.Instance.localPlayerController).ToString());
						NachoAchievements.CheckAchievements(dictionary);
					}
					list.Add(componentInChildren.mainScript);
				}
			}
		}
	}
	[HarmonyPatch(typeof(TerrainObstacleTrigger))]
	internal class TerrainObstacleTriggerPatches
	{
		public static bool driverWhoCollidedIsSelf;

		[HarmonyPatch("OnTriggerEnter")]
		[HarmonyPrefix]
		private static void OnCarHit(TerrainObstacleTrigger __instance, Collider other)
		{
			//IL_002c: 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)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			VehicleController component = ((Component)other).GetComponent<VehicleController>();
			if (!((Object)(object)component == (Object)null) && ((NetworkBehaviour)component).IsOwner && ((Vector3)(ref component.averageVelocity)).magnitude > 5f && Vector3.Angle(component.averageVelocity, ((Component)__instance).transform.position - component.mainRigidbody.position) < 80f && (Object)(object)component.currentDriver == (Object)(object)StartOfRound.Instance.localPlayerController)
			{
				driverWhoCollidedIsSelf = true;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}