Decompiled source of MONOLITH v1.0.1

BepInEx/plugins/MONOLITH/ModMenu.dll

Decompiled 41 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModMenu.Api;
using ModMenu.Behaviours.ModList;
using ModMenu.Behaviours.OptionList;
using ModMenu.Behaviours.OptionList.Dummies;
using ModMenu.Behaviours.OptionList.ValueControllers;
using ModMenu.Mods;
using ModMenu.Options;
using ModMenu.Patches;
using ModMenu.Utils;
using Newtonsoft.Json;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: StraftatMod(true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
}
namespace ModMenu
{
	internal static class ModMenuManager
	{
		public static Mod[] mods;

		public static void Init()
		{
			Dictionary<string, PluginInfo>.ValueCollection values = Chainloader.PluginInfos.Values;
			List<Mod> list = new List<Mod>();
			foreach (PluginInfo item in values)
			{
				ModInfo info = new ModInfo
				{
					guid = item.Metadata.GUID,
					name = item.Metadata.Name,
					version = item.Metadata.Version.ToString()
				};
				list.Add(new Mod(info));
			}
			mods = list.ToArray();
		}
	}
	public static class PluginInfo
	{
		public const string guid = "kestrel.straftat.modmenu";

		public const string name = "ModMenu";

		public const string version = "1.2.0";
	}
	[BepInPlugin("kestrel.straftat.modmenu", "ModMenu", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		private enum TestEnum
		{
			OptionA,
			OptionB,
			OptionC,
			OptionD,
			AndSoOn
		}

		private enum TestEnum2
		{
			AnotherTestEnum,
			IsntThisCool,
			HeyHiiiiHeyLookAtMe,
			ColonThree
		}

		internal static ManualLogSource Logger;

		private static ConfigEntry<string> m_superSecretConfigEntry;

		public static readonly string loadBearingColonThree = ":3";

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			if (loadBearingColonThree != ":3")
			{
				Application.Quit();
			}
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			CreateExampleConfigs();
			Assets.Init();
			ModMenuCustomisation.RegisterContentBuilder(CustomContentBuilder);
			ModMenuCustomisation.HideEntry((ConfigEntryBase)(object)m_superSecretConfigEntry);
			ModMenuCustomisation.SetPluginDescription("Configure your mods ingame!");
			ModMenuCustomisation.SetPluginIcon(Assets.ModMenuModIcon);
			new Harmony("kestrel.straftat.modmenu").PatchAll();
			Logger.LogInfo((object)"Hiiiiiiiiiiii :3");
		}

		private static void WriteToKillfeed(string text)
		{
			PauseManager.Instance.WriteOfflineLog(text);
		}

		private void CreateExampleConfigs()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: 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_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Config.Bind<bool>("Examples.Basic", "Bool", false, "A bool");
			((BaseUnityPlugin)this).Config.Bind<string>("Examples.Basic", "String", "Hiiiii", "A string");
			((BaseUnityPlugin)this).Config.Bind<float>("Examples.Numeric", "Unrestricted Float", 0f, "A float");
			((BaseUnityPlugin)this).Config.Bind<float>("Examples.Numeric", "Acceptable Range Float", 0f, new ConfigDescription("A float with a range restriction", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), Array.Empty<object>()));
			((BaseUnityPlugin)this).Config.Bind<float>("Examples.Numeric", "Acceptable List Float", 0f, new ConfigDescription("A float with a list of acceptable values", (AcceptableValueBase)(object)new AcceptableValueList<float>(new float[6] { 0f, 0.5f, 1f, 1.5f, 2f, 10f }), Array.Empty<object>()));
			((BaseUnityPlugin)this).Config.Bind<int>("Examples.Numeric", "Unrestricted Int", 0, "An int");
			((BaseUnityPlugin)this).Config.Bind<int>("Examples.Numeric", "Acceptable Range Int", 0, new ConfigDescription("An int with a range restriction", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-10, 10), Array.Empty<object>()));
			((BaseUnityPlugin)this).Config.Bind<int>("Examples.Numeric", "Acceptable List Int", 0, new ConfigDescription("An int with a list of acceptable values", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[7] { 0, 1, 2, 3, 4, 5, 10 }), Array.Empty<object>()));
			((BaseUnityPlugin)this).Config.Bind<uint>("Examples.Numeric", "UInt", 0u, "An unsigned int");
			((BaseUnityPlugin)this).Config.Bind<sbyte>("Examples.Numeric", "SByte", (sbyte)0, "A signed byte");
			((BaseUnityPlugin)this).Config.Bind<byte>("Examples.Numeric", "Byte", (byte)0, "A byte");
			((BaseUnityPlugin)this).Config.Bind<Vector2>("Examples.UnityTypes", "Unrestricted Vector2", Vector2.zero, "A Vector2");
			((BaseUnityPlugin)this).Config.Bind<Vector2>("Examples.UnityTypes", "Acceptable List Vector2", Vector2.zero, new ConfigDescription("A Vector2 with a list of acceptable values", (AcceptableValueBase)(object)new AcceptableValueList<Vector2>((Vector2[])(object)new Vector2[6]
			{
				Vector2.zero,
				Vector2.one,
				Vector2.up,
				Vector2.down,
				Vector2.left,
				Vector2.right
			}), Array.Empty<object>()));
			((BaseUnityPlugin)this).Config.Bind<Vector3>("Examples.UnityTypes", "Vector3", Vector3.zero, "A Vector3");
			((BaseUnityPlugin)this).Config.Bind<Vector4>("Examples.UnityTypes", "Vector4", Vector4.zero, "A Vector4");
			((BaseUnityPlugin)this).Config.Bind<Quaternion>("Examples.UnityTypes", "Quaternion", Quaternion.identity, "A Quaternion");
			((BaseUnityPlugin)this).Config.Bind<Color>("Examples.UnityTypes", "Color", Color.white, "A Color");
			((BaseUnityPlugin)this).Config.Bind<TestEnum>("Examples.Other", "Enum", TestEnum.OptionA, "An enum");
			((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Examples.Other", "Keyboard Shortcut", new KeyboardShortcut((KeyCode)285, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "A keyboard shortcut");
			((BaseUnityPlugin)this).Config.Bind<KeyCode>("Examples.Other", "KeyCode", (KeyCode)97, "A keycode");
			m_superSecretConfigEntry = ((BaseUnityPlugin)this).Config.Bind<string>("Examples.Secret", "Super Secret Entry", ":3", "shhh");
			m_superSecretConfigEntry.SettingChanged += delegate
			{
				WriteToKillfeed(">:3");
			};
		}

		private static void CustomContentBuilder(OptionListContext c)
		{
			//IL_0102: 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_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			c.InsertHeader(13, "Custom Section 1");
			TextDummy textDummy = c.InsertTextBox(14, "This section was generated with the Mod Menu API! With it, you can add custom ui elements anywhere in your mod's config page. Go to Assets/Scripts/Plugin.cs in the mod's source code to see example usage of the API.");
			((Component)textDummy).GetComponent<LayoutElement>().preferredHeight = 128f;
			textDummy.OnItemHovered += delegate
			{
				c.SetInfoPanelContents("Custom Info Panel Contents", "Custom Section 1", "You can also set custom text that appears here! how fun");
			};
			c.InsertButton(15, "", "A very interesting button", delegate
			{
				WriteToKillfeed("Button pressed!");
			});
			c.InsertButton(16, "Plugins Directory", "Show Path", delegate
			{
				string pluginPath = Paths.PluginPath;
				WriteToKillfeed("Plugins directory: " + pluginPath);
			});
			c.AppendHeader("Custom Section 2");
			c.AppendTextBox("Another custom section!");
			c.AppendTextBox("With some colored text! :3").Color = new Color(0.77f, 0.53f, 1f);
			TestEnum2 dropdownValue = TestEnum2.AnotherTestEnum;
			DropdownValueController dropdown = c.AppendDropdown("Custom Dropdown", () => dropdownValue, delegate(TestEnum2 value)
			{
				dropdownValue = value;
				WriteToKillfeed($"dropdownValue is {dropdownValue}");
			});
			dropdown.OnItemHovered += delegate
			{
				c.SetInfoPanelContents("Custom Dropdown", "Custom Section 2", "A custom dropdown with some custom info panel contents.");
				c.ShowInfoPanelResetButton(delegate
				{
					WriteToKillfeed("dropdownValue reset!");
					dropdownValue = TestEnum2.AnotherTestEnum;
					dropdown.UpdateAppearance();
				});
			};
			bool boolValue = false;
			c.AppendCheckbox("Custom Checkbox", () => boolValue, delegate(bool value)
			{
				boolValue = value;
				WriteToKillfeed($"checkboxValue is {value}");
			});
			Color colorValue = new Color(0.77f, 0.53f, 1f);
			c.AppendColorInput("Custom Color Input", () => colorValue, delegate(Color value)
			{
				//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)
				colorValue = value;
				WriteToKillfeed($"colorValue is {value}");
			});
			string stringValue = "hiii";
			c.AppendStringInput("Custom String Input", () => stringValue, delegate(string value)
			{
				stringValue = value;
				WriteToKillfeed("stringValue is " + value);
			});
			KeyboardShortcut keyboardShortcutValue = KeyboardShortcut.Empty;
			c.AppendKeyboardShortcutInput("Custom Keyboard Shortcut Input", () => keyboardShortcutValue, delegate(KeyboardShortcut value)
			{
				//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)
				keyboardShortcutValue = value;
				WriteToKillfeed($"keyboardShortcutValue is {value}");
			});
			KeyCode keyCodeValue = (KeyCode)0;
			c.AppendKeyCodeInput("Custom KeyCode Input", () => keyCodeValue, delegate(KeyCode value)
			{
				//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)
				keyCodeValue = value;
				WriteToKillfeed($"keyCodeValue is {value}");
			});
			Quaternion quaternionValue = Quaternion.identity;
			c.AppendQuaternionInput("Custom Quaternion Input", () => quaternionValue, delegate(Quaternion value)
			{
				//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)
				quaternionValue = value;
				WriteToKillfeed($"quaternionValue is {value}");
			});
			Vector2 vector2Value = Vector2.zero;
			c.AppendVector2Input("Custom Vector2 Input", () => vector2Value, delegate(Vector2 value)
			{
				//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)
				vector2Value = value;
				WriteToKillfeed($"vector2Value is {value}");
			});
			Vector3 vector3Value = Vector3.zero;
			c.AppendVector3Input("Custom Vector3 Input", () => vector3Value, delegate(Vector3 value)
			{
				//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)
				vector3Value = value;
				WriteToKillfeed($"vector3Value is {value}");
			});
			Vector4 vector4Value = Vector4.zero;
			c.AppendVector4Input("Custom Vector4 Input", () => vector4Value, delegate(Vector4 value)
			{
				//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)
				vector4Value = value;
				WriteToKillfeed($"vector4Value is {value}");
			});
			c.AppendTextBox("Some weirder stuff").Color = new Color(0.77254903f, 0.5254902f, 1f);
			float floatValue = 0f;
			Action<float> setter = delegate(float value)
			{
				floatValue = value;
				WriteToKillfeed($"floatValue is {floatValue}");
			};
			NumericInputFieldValueController inputField = c.AppendNumericInputField("Custom Float Input", () => floatValue, setter);
			NumericSliderValueController slider = c.AppendNumericSlider("Custom Float Slider", () => floatValue, setter, 0f, 100f);
			NumericInputFieldValueController numericInputFieldValueController = inputField;
			numericInputFieldValueController.setter = (Action<object>)Delegate.Combine(numericInputFieldValueController.setter, (Action<object>)delegate
			{
				slider.UpdateAppearance();
			});
			NumericSliderValueController numericSliderValueController = slider;
			numericSliderValueController.setter = (Action<object>)Delegate.Combine(numericSliderValueController.setter, (Action<object>)delegate
			{
				inputField.UpdateAppearance();
			});
			int sliderMin = -200;
			int sliderMax = 200;
			float floatValue2 = 0f;
			NumericSliderValueController floatSlider2 = c.AppendNumericSlider("Custom Float Slider 2", () => floatValue2, delegate(float value)
			{
				floatValue2 = value;
				WriteToKillfeed($"floatValue2 is {floatValue2}");
			}, sliderMin, sliderMax);
			NumericSliderValueController minSlider = c.AppendNumericSlider("Slider 2 Min (int slider example)", () => sliderMin, delegate(int value)
			{
				sliderMin = value;
				floatSlider2.slider.minValue = sliderMin;
			}, -1000f, sliderMax - 5);
			NumericSliderValueController maxSlider = c.AppendNumericSlider("Slider 2 Max (int slider example)", () => sliderMax, delegate(int value)
			{
				sliderMax = value;
				floatSlider2.slider.maxValue = sliderMax;
			}, sliderMin + 5, 1000f);
			NumericSliderValueController numericSliderValueController2 = minSlider;
			numericSliderValueController2.setter = (Action<object>)Delegate.Combine(numericSliderValueController2.setter, (Action<object>)delegate
			{
				maxSlider.slider.minValue = sliderMin + 5;
			});
			NumericSliderValueController numericSliderValueController3 = maxSlider;
			numericSliderValueController3.setter = (Action<object>)Delegate.Combine(numericSliderValueController3.setter, (Action<object>)delegate
			{
				minSlider.slider.maxValue = sliderMax - 5;
			});
		}
	}
}
namespace ModMenu.Utils
{
	internal static class AcceptableValueBaseExtensions
	{
		public static string HumanizedString(this AcceptableValueBase avb)
		{
			Type type = ((object)avb).GetType();
			if (avb.IsAcceptableValueRange())
			{
				object value = type.GetProperty("MinValue").GetValue(avb);
				object value2 = type.GetProperty("MaxValue").GetValue(avb);
				return "Accepts " + value?.ToString() + " to " + value2;
			}
			if (avb.IsAcceptableValueList())
			{
				object[] array = ((IEnumerable)type.GetProperty("AcceptableValues").GetValue(avb)).Cast<object>().ToArray();
				return "Accepts " + string.Join(", ", from v in array.SkipLast(1)
					select v.ToString()) + " and " + array[^1];
			}
			throw new NotSupportedException($"Type \"{type}\" is not supported.");
		}

		public static bool IsAcceptableValueList(this AcceptableValueBase avb)
		{
			return ((object)avb).GetType().GetGenericTypeDefinition() == typeof(AcceptableValueList<>);
		}

		public static bool IsAcceptableValueRange(this AcceptableValueBase avb)
		{
			return ((object)avb).GetType().GetGenericTypeDefinition() == typeof(AcceptableValueRange<>);
		}
	}
	internal static class Assets
	{
		private static AssetBundle m_bundle;

		public static Sprite DefaultModIcon { get; private set; }

		public static Sprite ModMenuModIcon { get; private set; }

		public static GameObject CategoryHeader { get; private set; }

		public static GameObject IntegralSliderOption { get; private set; }

		public static GameObject FloatingSliderOption { get; private set; }

		public static GameObject IntegralInputFieldOption { get; private set; }

		public static GameObject FloatingInputFieldOption { get; private set; }

		public static GameObject BoolCheckboxOption { get; private set; }

		public static GameObject StringInputFieldOption { get; private set; }

		public static GameObject EnumDropdownOption { get; private set; }

		public static GameObject KeyCodeOption { get; private set; }

		public static GameObject KeyboardShortcutOption { get; private set; }

		public static GameObject AcceptableListDropdownOption { get; private set; }

		public static GameObject Vector2Option { get; private set; }

		public static GameObject Vector3Option { get; private set; }

		public static GameObject Vector4Option { get; private set; }

		public static GameObject QuaternionOption { get; private set; }

		public static GameObject ColorOption { get; private set; }

		public static GameObject TextDummy { get; private set; }

		public static GameObject ButtonDummy { get; private set; }

		internal static T Load<T>(string name) where T : Object
		{
			return m_bundle.LoadAsset<T>(name);
		}

		public static void Init()
		{
			Plugin.Logger.LogInfo((object)"Loading assets...");
			m_bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "modmenu"));
			DefaultModIcon = Assets.Load<Sprite>("NoIcon");
			ModMenuModIcon = Assets.Load<Sprite>("ModIcon");
			CategoryHeader = Assets.Load<GameObject>("CategoryHeader");
			IntegralSliderOption = Assets.Load<GameObject>("IntegralSliderOption");
			FloatingSliderOption = Assets.Load<GameObject>("FloatingSliderOption");
			IntegralInputFieldOption = Assets.Load<GameObject>("IntegralInputFieldOption");
			FloatingInputFieldOption = Assets.Load<GameObject>("FloatingInputFieldOption");
			BoolCheckboxOption = Assets.Load<GameObject>("BoolCheckboxOption");
			StringInputFieldOption = Assets.Load<GameObject>("StringInputFieldOption");
			EnumDropdownOption = Assets.Load<GameObject>("EnumDropdownOption");
			KeyCodeOption = Assets.Load<GameObject>("KeyCodeOption");
			KeyboardShortcutOption = Assets.Load<GameObject>("KeyboardShortcutOption");
			AcceptableListDropdownOption = Assets.Load<GameObject>("AcceptableListDropdownOption");
			Vector2Option = Assets.Load<GameObject>("Vector2Option");
			Vector3Option = Assets.Load<GameObject>("Vector3Option");
			Vector4Option = Assets.Load<GameObject>("Vector4Option");
			QuaternionOption = Assets.Load<GameObject>("QuaternionOption");
			ColorOption = Assets.Load<GameObject>("ColorOption");
			TextDummy = Assets.Load<GameObject>("TextDummy");
			ButtonDummy = Assets.Load<GameObject>("ButtonDummy");
			Plugin.Logger.LogInfo((object)"Assets loaded!");
		}
	}
	internal static class BepInExUtils
	{
		internal static Dictionary<Assembly, PluginInfo> PluginInfoCache { get; } = new Dictionary<Assembly, PluginInfo>();

		internal static Dictionary<PluginInfo, string> PluginTypeNameCache { get; } = new Dictionary<PluginInfo, string>();

		internal static string GetPluginInfoTypeName(PluginInfo pluginInfo)
		{
			if (PluginTypeNameCache.TryGetValue(pluginInfo, out var value))
			{
				return value;
			}
			value = AccessTools.Property(typeof(PluginInfo), "TypeName").GetValue(pluginInfo) as string;
			PluginTypeNameCache.Add(pluginInfo, value);
			return value;
		}

		internal static PluginInfo GetPluginInfoFromAssembly(Assembly assembly)
		{
			if (PluginInfoCache.TryGetValue(assembly, out var value))
			{
				return value;
			}
			using (IEnumerator<PluginInfo> enumerator = Chainloader.PluginInfos.Values.Where((PluginInfo info) => assembly.GetType(GetPluginInfoTypeName(info)) != null).GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					PluginInfo current = enumerator.Current;
					PluginInfoCache.Add(assembly, current);
					return current;
				}
			}
			PluginInfoCache.Add(assembly, null);
			return null;
		}
	}
	internal static class TypeExtensions
	{
		public static bool IsIntegral(this Type type)
		{
			if (!(type == typeof(sbyte)) && !(type == typeof(byte)) && !(type == typeof(short)) && !(type == typeof(ushort)) && !(type == typeof(int)) && !(type == typeof(uint)) && !(type == typeof(long)))
			{
				return type == typeof(ulong);
			}
			return true;
		}

		public static bool IsFloating(this Type type)
		{
			if (!(type == typeof(float)) && !(type == typeof(double)))
			{
				return type == typeof(decimal);
			}
			return true;
		}
	}
}
namespace ModMenu.Patches
{
	[HarmonyPatch(typeof(PauseManager))]
	internal static class PauseManagerPatch
	{
		public static readonly HashSet<BoxedValueController> currentlyRebindingKeybindContollers = new HashSet<BoxedValueController>();

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void InitModsTab(GameObject ___optionsMenu)
		{
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			//IL_010c: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_015d: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)___optionsMenu))
			{
				return;
			}
			((Component)___optionsMenu.transform.Find("OPTIONS HUD").GetChild(0).GetChild(3)).gameObject.SetActive(false);
			GameObject pcTab = ((Component)___optionsMenu.transform.Find("PcTab")).gameObject;
			GameObject audioTab = ((Component)___optionsMenu.transform.Find("AudioTab")).gameObject;
			GameObject graphTab = ((Component)___optionsMenu.transform.Find("GraphTab")).gameObject;
			GameObject modsTab = Object.Instantiate<GameObject>(Assets.Load<GameObject>("ModMenu"), ___optionsMenu.transform);
			((Object)modsTab).name = "ModsTab";
			modsTab.SetActive(false);
			Transform val = ___optionsMenu.transform.Find("Tabsbutton");
			Button component = Object.Instantiate<GameObject>(Assets.Load<GameObject>("ModsTabButton"), ((Component)val).transform).GetComponent<Button>();
			UnityAction val2 = default(UnityAction);
			for (int i = 0; i < val.childCount; i++)
			{
				RectTransform component2 = ((Component)val.GetChild(i)).GetComponent<RectTransform>();
				if (component2 == null)
				{
					continue;
				}
				component2.sizeDelta = new Vector2(110f, 63.21f);
				component2.anchoredPosition = new Vector2((float)(-710 + i * 110), 343.8f);
				ButtonClickedEvent onClick = ((Component)component2).GetComponent<Button>().onClick;
				UnityAction obj = val2;
				if (obj == null)
				{
					UnityAction val3 = delegate
					{
						modsTab.SetActive(false);
					};
					UnityAction val4 = val3;
					val2 = val3;
					obj = val4;
				}
				((UnityEvent)onClick).AddListener(obj);
			}
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				modsTab.SetActive(true);
				pcTab.SetActive(false);
				audioTab.SetActive(false);
				graphTab.SetActive(false);
			});
		}

		[HarmonyPatch("Menu")]
		[HarmonyPrefix]
		public static bool DoNotOpenIfRebinding()
		{
			return currentlyRebindingKeybindContollers.Count == 0;
		}
	}
}
namespace ModMenu.Options
{
	internal class AcceptableListDropdownOption : Option
	{
		public AcceptableListDropdownOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.AcceptableListDropdownOption;
		}
	}
	internal class BoolOption : ValueOption<bool>
	{
		public BoolOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.BoolCheckboxOption;
		}
	}
	internal class ColorOption : ValueOption<Color>
	{
		public ColorOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.ColorOption;
		}
	}
	internal class EnumDropdownOption : Option
	{
		public EnumDropdownOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.EnumDropdownOption;
		}
	}
	internal class FloatingInputFieldOption : Option
	{
		public FloatingInputFieldOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.FloatingInputFieldOption;
		}
	}
	internal class FloatingSliderOption : Option
	{
		public FloatingSliderOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.FloatingSliderOption;
		}
	}
	internal class IntegralInputFieldOption : Option
	{
		public IntegralInputFieldOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.IntegralInputFieldOption;
		}
	}
	internal class IntegralSliderOption : Option
	{
		public IntegralSliderOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.IntegralSliderOption;
		}
	}
	internal class KeyboardShortcutOption : ValueOption<KeyboardShortcut>
	{
		public KeyboardShortcutOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.KeyboardShortcutOption;
		}
	}
	internal class KeyCodeOption : ValueOption<KeyCode>
	{
		public KeyCodeOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.KeyCodeOption;
		}
	}
	internal abstract class Option
	{
		public string Name => BaseEntry.Definition.Key;

		public string Section => BaseEntry.Definition.Section;

		public string Description => BaseEntry.Description.Description;

		public AcceptableValueBase AcceptableValues => BaseEntry.Description.AcceptableValues;

		public ConfigEntryBase BaseEntry { get; }

		public object BoxedValue
		{
			get
			{
				return BaseEntry.BoxedValue;
			}
			set
			{
				BaseEntry.BoxedValue = value;
			}
		}

		protected Option(ConfigEntryBase entry)
		{
			BaseEntry = entry;
		}

		public abstract GameObject GetListItemPrefab();

		public void ResetToDefault()
		{
			BoxedValue = BaseEntry.DefaultValue;
		}

		public static Option CreateForEntry(ConfigEntryBase entry)
		{
			Type settingType = entry.SettingType;
			AcceptableValueBase acceptableValues = entry.Description.AcceptableValues;
			if (acceptableValues != null && acceptableValues.IsAcceptableValueList())
			{
				return new AcceptableListDropdownOption(entry);
			}
			if (settingType == typeof(bool))
			{
				return new BoolOption(entry);
			}
			if (settingType == typeof(string))
			{
				return new StringInputFieldOption(entry);
			}
			if (settingType.IsIntegral())
			{
				if (acceptableValues != null && acceptableValues.IsAcceptableValueRange())
				{
					return new IntegralSliderOption(entry);
				}
				return new IntegralInputFieldOption(entry);
			}
			if (settingType.IsFloating())
			{
				if (acceptableValues != null && acceptableValues.IsAcceptableValueRange())
				{
					return new FloatingSliderOption(entry);
				}
				return new FloatingInputFieldOption(entry);
			}
			if (settingType == typeof(KeyCode))
			{
				return new KeyCodeOption(entry);
			}
			if (settingType == typeof(KeyboardShortcut))
			{
				return new KeyboardShortcutOption(entry);
			}
			if (settingType == typeof(Vector2))
			{
				return new Vector2Option(entry);
			}
			if (settingType == typeof(Vector3))
			{
				return new Vector3Option(entry);
			}
			if (settingType == typeof(Vector4))
			{
				return new Vector4Option(entry);
			}
			if (settingType == typeof(Quaternion))
			{
				return new QuaternionOption(entry);
			}
			if (settingType == typeof(Color))
			{
				return new ColorOption(entry);
			}
			if (settingType.IsEnum && !settingType.IsDefined(typeof(FlagsAttribute), inherit: false))
			{
				return new EnumDropdownOption(entry);
			}
			throw new NotSupportedException($"Options of type \"{settingType}\" are not supported.");
		}
	}
	internal abstract class ValueOption<T> : Option
	{
		public T Value
		{
			get
			{
				return (T)base.BaseEntry.BoxedValue;
			}
			set
			{
				base.BaseEntry.BoxedValue = value;
			}
		}

		protected ValueOption(ConfigEntryBase entry)
			: base(entry)
		{
		}
	}
	internal class QuaternionOption : ValueOption<Quaternion>
	{
		public QuaternionOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.QuaternionOption;
		}
	}
	internal class StringInputFieldOption : ValueOption<string>
	{
		public StringInputFieldOption(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.StringInputFieldOption;
		}
	}
	internal class Vector2Option : ValueOption<Vector2>
	{
		public Vector2Option(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.Vector2Option;
		}
	}
	internal class Vector3Option : ValueOption<Vector3>
	{
		public Vector3Option(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.Vector3Option;
		}
	}
	internal class Vector4Option : ValueOption<Vector4>
	{
		public Vector4Option(ConfigEntryBase entry)
			: base(entry)
		{
		}

		public override GameObject GetListItemPrefab()
		{
			return Assets.Vector4Option;
		}
	}
}
namespace ModMenu.Mods
{
	internal class Mod
	{
		public readonly List<Option> config = new List<Option>();

		public ModInfo info;

		public readonly PluginInfo pluginInfo;

		public readonly Action<OptionListContext>? customContentBuilder;

		public bool HasAnyConfigs => config.Count > 0;

		public bool HasAdvancedMetadata { get; private set; }

		public Mod(ModInfo info)
		{
			this.info = info;
			if (Chainloader.PluginInfos.TryGetValue(info.guid, out pluginInfo))
			{
				ModMenuCustomisation.Builders.TryGetValue(info.guid, out customContentBuilder);
				LoadMetadata();
				LoadConfigEntries();
			}
		}

		private void LoadMetadata()
		{
			info.icon = Assets.DefaultModIcon;
			info.description = "No description found.";
			string text = Path.GetFullPath(pluginInfo.Location);
			DirectoryInfo parent = Directory.GetParent(text);
			while (parent != null && !string.Equals(parent.Name, "plugins", StringComparison.OrdinalIgnoreCase))
			{
				text = parent.FullName;
				parent = Directory.GetParent(text);
			}
			if (text.EndsWith(".dll"))
			{
				return;
			}
			if (ModMenuCustomisation.Icons.TryGetValue(info.guid, out var value))
			{
				info.icon = value;
				HasAdvancedMetadata = true;
			}
			else
			{
				string text2 = Directory.EnumerateFiles(text, "icon.png", SearchOption.AllDirectories).FirstOrDefault();
				if (!string.IsNullOrEmpty(text2))
				{
					TryLoadIcon(text2);
				}
			}
			string text3 = Directory.EnumerateFiles(text, "manifest.json", SearchOption.AllDirectories).FirstOrDefault();
			if (!string.IsNullOrEmpty(text3))
			{
				TryLoadManifest(text3);
			}
			if (ModMenuCustomisation.Descriptions.TryGetValue(info.guid, out var value2))
			{
				info.description = value2;
				HasAdvancedMetadata = true;
			}
		}

		private void LoadConfigEntries()
		{
			ConfigFile val = pluginInfo.Instance.Config;
			if (val == null)
			{
				return;
			}
			foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in val)
			{
				try
				{
					if (!ModMenuCustomisation.HiddenConfigEntries.Contains(item.Value))
					{
						config.Add(Option.CreateForEntry(item.Value));
					}
				}
				catch (NotSupportedException ex)
				{
					Plugin.Logger.LogWarning((object)$"Error generating config entry \"{item.Key}\" for \"{info.name}\": {ex.Message}");
				}
			}
		}

		private bool TryLoadIcon(string path)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_003f: 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)
			Texture2D val = new Texture2D(256, 256);
			if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
			{
				return false;
			}
			info.icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			HasAdvancedMetadata = true;
			return true;
		}

		private bool TryLoadManifest(string path)
		{
			//IL_004d: Expected O, but got Unknown
			try
			{
				ThunderstoreManifest thunderstoreManifest = JsonConvert.DeserializeObject<ThunderstoreManifest>(File.ReadAllText(path));
				info.description = thunderstoreManifest?.Description;
				info.name = thunderstoreManifest?.Name.Replace('_', ' ');
				HasAdvancedMetadata = true;
			}
			catch (JsonException ex)
			{
				JsonException ex2 = ex;
				Plugin.Logger.LogWarning((object)("Error trying to load manifest for \"" + info.name + "\": " + ((Exception)(object)ex2).Message));
				return false;
			}
			return true;
		}
	}
	internal struct ModInfo
	{
		public string name;

		public string guid;

		public string description;

		public string version;

		public Sprite icon;
	}
	internal class ThunderstoreManifest
	{
		[JsonProperty("name")]
		public string Name { get; set; }

		[JsonProperty("version_number")]
		public string Version { get; set; }

		[JsonProperty("website_url")]
		public string WebsiteUrl { get; set; }

		[JsonProperty("description")]
		public string Description { get; set; }

		[JsonProperty("dependencies")]
		public string[] Dependencies { get; set; }
	}
}
namespace ModMenu.Behaviours
{
	internal class ModMenu : MonoBehaviour
	{
		public ModListPanel modListPanel;

		private void Awake()
		{
			ModMenuManager.Init();
		}
	}
	internal class ShowTooltip : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public string textToShow;

		public void OnPointerEnter(PointerEventData eventData)
		{
			FloatingName.Instance.nameToShow = textToShow;
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			FloatingName.Instance.nameToShow = "";
		}
	}
}
namespace ModMenu.Behaviours.OptionList
{
	internal class OptionInfoPanel : MonoBehaviour
	{
		public TextMeshProUGUI nameText;

		public TextMeshProUGUI categoryText;

		public TextMeshProUGUI descriptionText;

		public Button resetButton;

		private void Awake()
		{
			ClearInfo();
		}

		public void PlayClickSound()
		{
			PauseManager.Instance.PlayMenuClip(PauseManager.Instance.releaseMenuClip);
		}

		public void SetContents(string title, string subtitle, string description)
		{
			ClearInfo();
			((TMP_Text)nameText).text = title;
			((TMP_Text)categoryText).text = subtitle;
			((TMP_Text)descriptionText).text = description;
		}

		public void ShowInfoFor(Option option)
		{
			ClearInfo();
			((TMP_Text)nameText).text = option.Name;
			((TMP_Text)descriptionText).text = option.Description;
			string section = option.Section;
			string name = option.BaseEntry.SettingType.Name;
			((TMP_Text)categoryText).text = section + " | " + name + " | Defaults to " + option.BaseEntry.DefaultValue;
			if (option.AcceptableValues != null)
			{
				TextMeshProUGUI obj = categoryText;
				((TMP_Text)obj).text = ((TMP_Text)obj).text + " | " + option.AcceptableValues.HumanizedString();
			}
		}

		public void ShowResetButtonFor(BoxedValueController controller)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			((Component)resetButton).gameObject.SetActive(true);
			((UnityEvent)resetButton.onClick).AddListener((UnityAction)delegate
			{
				controller.ResetValue();
				controller.UpdateAppearance();
			});
		}

		public void ClearInfo()
		{
			((UnityEventBase)resetButton.onClick).RemoveAllListeners();
			((Component)resetButton).gameObject.SetActive(false);
			((TMP_Text)nameText).text = "";
			((TMP_Text)categoryText).text = "";
			((TMP_Text)descriptionText).text = "";
		}
	}
	public class OptionListItem : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		public delegate void ItemHoverHandler();

		public TextMeshProUGUI nameText;

		public string NameText
		{
			get
			{
				return ((TMP_Text)nameText).text;
			}
			set
			{
				((TMP_Text)nameText).text = value;
			}
		}

		public event ItemHoverHandler OnItemHovered;

		public event ItemHoverHandler OnItemUnhovered;

		public void OnPointerEnter(PointerEventData eventData)
		{
			this.OnItemHovered?.Invoke();
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			this.OnItemUnhovered?.Invoke();
		}
	}
	internal class OptionListPanel : MonoBehaviour
	{
		public GameObject container;

		public OptionInfoPanel infoPanel;

		public TMP_InputField searchBar;

		private Dictionary<string, GameObject[]> m_optionCache = new Dictionary<string, GameObject[]>();

		private string m_currentEnabledGuid = "";

		private GameObject m_noOptionsText;

		private GameObject m_noOptionsSadFace;

		private void Awake()
		{
			OptionListContext optionListContext = new OptionListContext(this);
			m_noOptionsText = ((Component)optionListContext.AppendHeader("No options found")).gameObject;
			m_noOptionsSadFace = ((Component)optionListContext.AppendHeader(":c")).gameObject;
			((Object)m_noOptionsText).name = "No options found header";
			((Object)m_noOptionsSadFace).name = "No options found sad face";
			((TMP_Text)m_noOptionsSadFace.GetComponent<TextMeshProUGUI>()).fontSize = 24f;
			m_noOptionsText.SetActive(false);
			m_noOptionsSadFace.SetActive(false);
		}

		private static bool ShouldDisplayWithFilter(string filter, OptionListItem item)
		{
			string value = filter.ToLower();
			if (item is BoxedValueController { sourceOption: { } sourceOption })
			{
				if (!sourceOption.Name.ToLower().Contains(value))
				{
					return sourceOption.Section.ToLower().Contains(value);
				}
				return true;
			}
			return item.NameText.ToLower().Contains(value);
		}

		public void FilterOptionList(string filter)
		{
			if (!m_optionCache.TryGetValue(m_currentEnabledGuid, out var value))
			{
				return;
			}
			GameObject[] array = value;
			OptionListItem item = default(OptionListItem);
			foreach (GameObject val in array)
			{
				if (filter == string.Empty)
				{
					val.SetActive(true);
				}
				else if (val.TryGetComponent<OptionListItem>(ref item))
				{
					val.SetActive(ShouldDisplayWithFilter(filter, item));
				}
				else
				{
					val.SetActive(false);
				}
			}
		}

		public void ShowListFor(Mod mod)
		{
			ClearList();
			m_currentEnabledGuid = mod.info.guid;
			searchBar.SetTextWithoutNotify(string.Empty);
			if (m_optionCache.TryGetValue(m_currentEnabledGuid, out var value))
			{
				GameObject[] array = value;
				foreach (GameObject obj in array)
				{
					obj.SetActive(true);
					obj.GetComponent<BoxedValueController>()?.UpdateAppearance();
				}
				return;
			}
			List<GameObject> list = new List<GameObject>();
			if (!mod.HasAnyConfigs)
			{
				list.Add(m_noOptionsText);
				list.Add(m_noOptionsSadFace);
				m_noOptionsText.SetActive(true);
				m_noOptionsSadFace.SetActive(true);
			}
			else
			{
				OptionListContext optionListContext = new OptionListContext(this);
				string text = "";
				foreach (Option item in mod.config)
				{
					if (item.Section != text)
					{
						TextDummy textDummy = optionListContext.AppendHeader(item.Section);
						((Object)textDummy).name = mod.info.name + "/" + item.Section;
						list.Add(((Component)textDummy).gameObject);
					}
					text = item.Section;
					GameObject val = optionListContext.AppendControllerForOption(item);
					((Object)val).name = mod.info.name + "/" + item.Section + "/" + item.Name;
					list.Add(val);
				}
				optionListContext = new OptionListContext(this);
				try
				{
					mod.customContentBuilder?.Invoke(optionListContext);
				}
				catch (Exception arg)
				{
					Plugin.Logger.LogError((object)$"Error invoking custom content builder for {mod.info.guid}: {arg}");
				}
				list.AddRange(optionListContext.GetNewChildren());
			}
			m_optionCache[m_currentEnabledGuid] = list.ToArray();
		}

		private void ClearList()
		{
			if (m_optionCache.TryGetValue(m_currentEnabledGuid, out var value))
			{
				GameObject[] array = value;
				for (int i = 0; i < array.Length; i++)
				{
					array[i].SetActive(false);
				}
			}
		}
	}
}
namespace ModMenu.Behaviours.OptionList.ValueControllers
{
	public class BoolValueController : ValueController<bool>
	{
		public Toggle toggle;

		public void OnCheckboxValueChanged(bool value)
		{
			SetValue(value);
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			toggle.SetIsOnWithoutNotify(GetValue());
		}
	}
	public class ColorValueController : ValueController<Color>
	{
		public TMP_InputField inputField;

		public Image preview;

		public void OnInputFieldEndEdit(string value)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Color value2 = default(Color);
			if (ColorUtility.TryParseHtmlString(value, ref value2))
			{
				SetValue(value2);
			}
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			//IL_000c: 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)
			inputField.SetTextWithoutNotify("#" + ColorUtility.ToHtmlStringRGBA(GetValue()).ToLower());
			((Graphic)preview).color = GetValue();
		}
	}
	public class DropdownValueController : BoxedValueController
	{
		public TMP_Dropdown dropdown;

		private string[] m_dropdownNames;

		private object[] m_dropdownValues;

		public void OnDropdownValueChanged(int index)
		{
			setter(m_dropdownValues[index]);
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			dropdown.SetValueWithoutNotify(Array.IndexOf(m_dropdownValues, getter()));
		}

		internal override void SetupFromOption(Option option)
		{
			Type settingType = option.BaseEntry.SettingType;
			if (settingType.IsEnum)
			{
				SetValuesFromEnum(settingType);
			}
			else
			{
				if (!option.AcceptableValues.IsAcceptableValueList())
				{
					throw new InvalidOperationException("Cannot setup a dropdown value controller from a non-enum option type with no acceptable value list.");
				}
				SetValuesFromOption(option);
			}
			base.SetupFromOption(option);
		}

		internal override void SetupFromValues<T>(Func<T> getter, Action<T> setter)
		{
			if (!typeof(T).IsEnum)
			{
				throw new InvalidOperationException("Cannot setup a dropdown value controller by values from a non-enum type");
			}
			SetValuesFromEnum(typeof(T));
			base.SetupFromValues(getter, setter);
		}

		protected override void Setup()
		{
			dropdown.ClearOptions();
			dropdown.AddOptions(m_dropdownNames.ToList());
		}

		private void SetValuesFromEnum(Type enumType)
		{
			m_dropdownNames = Enum.GetNames(enumType);
			m_dropdownValues = Enum.GetValues(enumType).Cast<object>().ToArray();
		}

		private void SetValuesFromOption(Option option)
		{
			AcceptableValueBase acceptableValues = option.AcceptableValues;
			m_dropdownValues = ((IEnumerable)((object)acceptableValues).GetType().GetProperty("AcceptableValues").GetValue(acceptableValues)).Cast<object>().ToArray();
			m_dropdownNames = m_dropdownValues.Select((object v) => v.ToString()).ToArray();
		}
	}
	public abstract class KeybindValueController<T> : ValueController<T>
	{
		public TextMeshProUGUI buttonText;

		protected bool rebinding;

		protected KeyCode[] keysToCheck;

		public void OnRebindButtonPressed()
		{
			if (!rebinding)
			{
				StartRebinding();
			}
			else
			{
				StopRebinding();
			}
			UpdateAppearance();
		}

		public override void ResetValue()
		{
			base.ResetValue();
			StopRebinding();
		}

		public override void UpdateAppearance()
		{
			((TMP_Text)buttonText).text = (rebinding ? "Cancel" : GetValue().ToString());
		}

		protected abstract void UpdateRebinding();

		protected override void Setup()
		{
			keysToCheck = UnityInput.Current.SupportedKeyCodes.Except((IEnumerable<KeyCode>)(object)new KeyCode[3]
			{
				(KeyCode)323,
				default(KeyCode),
				(KeyCode)27
			}).ToArray();
		}

		protected void StartRebinding()
		{
			rebinding = true;
			PauseManagerPatch.currentlyRebindingKeybindContollers.Add(this);
			UpdateAppearance();
		}

		protected void StopRebinding()
		{
			rebinding = false;
			PauseManagerPatch.currentlyRebindingKeybindContollers.Remove(this);
			UpdateAppearance();
		}

		private void OnDisable()
		{
			StopRebinding();
		}

		private void Update()
		{
			if (rebinding)
			{
				UpdateRebinding();
			}
		}
	}
	public class KeyboardShortcutValueController : KeybindValueController<KeyboardShortcut>
	{
		protected override void UpdateRebinding()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)27))
			{
				SetValue(KeyboardShortcut.Empty);
				StopRebinding();
				return;
			}
			KeyCode[] array = keysToCheck;
			foreach (KeyCode val in array)
			{
				if (Input.GetKeyUp(val))
				{
					SetValue(new KeyboardShortcut(val, ((IEnumerable<KeyCode>)keysToCheck).Where((Func<KeyCode, bool>)Input.GetKey).ToArray()));
					StopRebinding();
					break;
				}
			}
		}
	}
	public class KeyCodeValueController : KeybindValueController<KeyCode>
	{
		protected override void UpdateRebinding()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)27))
			{
				SetValue((KeyCode)0);
				StopRebinding();
				return;
			}
			KeyCode[] array = keysToCheck;
			foreach (KeyCode val in array)
			{
				if (Input.GetKeyUp(val))
				{
					SetValue(val);
					StopRebinding();
					break;
				}
			}
		}
	}
	public class NumericInputFieldValueController : BoxedValueController
	{
		public TMP_InputField inputField;

		private bool m_isIntegralType;

		public void OnInputFieldEndEdit(string value)
		{
			try
			{
				object obj = Convert.ChangeType(value, base.ValueType);
				if (obj != null)
				{
					setter(obj);
				}
			}
			catch (Exception ex) when (ex is OverflowException || ex is FormatException || ex is InvalidCastException)
			{
			}
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			inputField.SetTextWithoutNotify(m_isIntegralType ? getter().ToString() : $"{getter():F}");
		}

		protected override void Setup()
		{
			m_isIntegralType = base.ValueType.IsIntegral();
		}
	}
	public class NumericSliderValueController : BoxedValueController
	{
		public Slider slider;

		public TMP_InputField inputField;

		private bool m_boundsSet;

		private bool m_isIntegralType;

		public void OnSliderValueChanged(float value)
		{
			if (m_boundsSet)
			{
				object obj = Convert.ChangeType(value, base.ValueType);
				if (obj != null)
				{
					setter(obj);
				}
				UpdateAppearance();
			}
		}

		public void OnInputFieldEndEdit(string value)
		{
			try
			{
				object obj = Convert.ChangeType(value, base.ValueType);
				if (obj != null)
				{
					setter(obj);
				}
			}
			catch (Exception ex) when (ex is OverflowException || ex is FormatException || ex is InvalidCastException)
			{
			}
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			object obj = getter();
			slider.SetValueWithoutNotify(Convert.ToSingle(obj));
			inputField.SetTextWithoutNotify(m_isIntegralType ? obj.ToString() : $"{obj:F}");
		}

		internal override void SetupFromOption(Option option)
		{
			AcceptableValueBase acceptableValues = option.AcceptableValues;
			Type type = ((object)acceptableValues).GetType();
			slider.minValue = Convert.ToSingle(type.GetProperty("MinValue").GetValue(acceptableValues));
			slider.maxValue = Convert.ToSingle(type.GetProperty("MaxValue").GetValue(acceptableValues));
			base.SetupFromOption(option);
			m_boundsSet = true;
		}

		protected override void Setup()
		{
			m_isIntegralType = base.ValueType.IsIntegral();
		}
	}
	public class QuaternionValueController : ValueController<Quaternion>
	{
		public TMP_InputField xInputField;

		public TMP_InputField yInputField;

		public TMP_InputField zInputField;

		public TMP_InputField wInputField;

		public void OnInputFieldEndEdit()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			Quaternion value = GetValue();
			float num = value.x;
			float num2 = value.y;
			float num3 = value.z;
			float num4 = value.w;
			if (float.TryParse(xInputField.text, out var result))
			{
				num = result;
			}
			if (float.TryParse(yInputField.text, out var result2))
			{
				num2 = result2;
			}
			if (float.TryParse(zInputField.text, out var result3))
			{
				num3 = result3;
			}
			if (float.TryParse(wInputField.text, out var result4))
			{
				num4 = result4;
			}
			SetValue(new Quaternion(num, num2, num3, num4));
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Quaternion value = GetValue();
			xInputField.SetTextWithoutNotify(value.x.ToString("F"));
			yInputField.SetTextWithoutNotify(value.y.ToString("F"));
			zInputField.SetTextWithoutNotify(value.z.ToString("F"));
			wInputField.SetTextWithoutNotify(value.w.ToString("F"));
		}
	}
	public class StringValueController : ValueController<string>
	{
		public TMP_InputField inputField;

		public void OnInputFieldEndEdit(string value)
		{
			SetValue(value);
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			inputField.SetTextWithoutNotify(GetValue());
		}
	}
	public abstract class BoxedValueController : OptionListItem
	{
		public Func<object> getter;

		public Action<object> setter;

		internal Option sourceOption;

		private object m_defaultValue;

		private Tweener m_errorShake;

		public Type ValueType { get; private set; }

		private void Start()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			m_errorShake = (Tweener)(object)TweenExtensions.Pause<TweenerCore<Vector3, Vector3[], Vector3ArrayOptions>>(TweenSettingsExtensions.SetAutoKill<TweenerCore<Vector3, Vector3[], Vector3ArrayOptions>>(DOTween.Shake((DOGetter<Vector3>)(() => ((Component)this).transform.localPosition), (DOSetter<Vector3>)delegate(Vector3 p)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				((Component)this).transform.localPosition = p;
			}, 0.2f, 15f * Vector3.right, 20, 90f, true, (ShakeRandomnessMode)0), false));
		}

		public abstract void UpdateAppearance();

		public virtual void ResetValue()
		{
			setter(m_defaultValue);
		}

		internal virtual void SetupFromOption(Option option)
		{
			sourceOption = option;
			m_defaultValue = option.BaseEntry.DefaultValue;
			ValueType = option.BaseEntry.SettingType;
			getter = () => option.BoxedValue;
			setter = delegate(object value)
			{
				try
				{
					option.BoxedValue = value;
				}
				catch (Exception ex)
				{
					Tweener errorShake = m_errorShake;
					if (errorShake != null)
					{
						TweenExtensions.Restart((Tween)(object)errorShake, true, -1f);
					}
					UpdateAppearance();
					if (!(ex is InvalidOperationException))
					{
						throw;
					}
				}
			};
			Setup();
			UpdateAppearance();
		}

		internal virtual void SetupFromValues<T>(Func<T> getter, Action<T> setter)
		{
			m_defaultValue = default(T);
			ValueType = typeof(T);
			this.getter = () => getter();
			this.setter = delegate(object value)
			{
				setter((T)value);
			};
			Setup();
			UpdateAppearance();
		}

		protected virtual void Setup()
		{
		}
	}
	public abstract class ValueController<T> : BoxedValueController
	{
		public T GetValue()
		{
			return (T)getter();
		}

		public void SetValue(T value)
		{
			setter(value);
		}
	}
	public class Vector2ValueController : ValueController<Vector2>
	{
		public TMP_InputField xInputField;

		public TMP_InputField yInputField;

		public void OnInputFieldEndEdit()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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)
			Vector2 value = GetValue();
			float num = value.x;
			float num2 = value.y;
			if (float.TryParse(xInputField.text, out var result))
			{
				num = result;
			}
			if (float.TryParse(yInputField.text, out var result2))
			{
				num2 = result2;
			}
			SetValue(new Vector2(num, num2));
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Vector2 value = GetValue();
			xInputField.SetTextWithoutNotify(value.x.ToString("F"));
			yInputField.SetTextWithoutNotify(value.y.ToString("F"));
		}
	}
	public class Vector3ValueController : ValueController<Vector3>
	{
		public TMP_InputField xInputField;

		public TMP_InputField yInputField;

		public TMP_InputField zInputField;

		public void OnInputFieldEndEdit()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			Vector3 value = GetValue();
			float num = value.x;
			float num2 = value.y;
			float num3 = value.z;
			if (float.TryParse(xInputField.text, out var result))
			{
				num = result;
			}
			if (float.TryParse(yInputField.text, out var result2))
			{
				num2 = result2;
			}
			if (float.TryParse(zInputField.text, out var result3))
			{
				num3 = result3;
			}
			SetValue(new Vector3(num, num2, num3));
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Vector3 value = GetValue();
			xInputField.SetTextWithoutNotify(value.x.ToString("F"));
			yInputField.SetTextWithoutNotify(value.y.ToString("F"));
			zInputField.SetTextWithoutNotify(value.z.ToString("F"));
		}
	}
	public class Vector4ValueController : ValueController<Vector4>
	{
		public TMP_InputField xInputField;

		public TMP_InputField yInputField;

		public TMP_InputField zInputField;

		public TMP_InputField wInputField;

		public void OnInputFieldEndEdit()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			Vector4 value = GetValue();
			float num = value.x;
			float num2 = value.y;
			float num3 = value.z;
			float num4 = value.w;
			if (float.TryParse(xInputField.text, out var result))
			{
				num = result;
			}
			if (float.TryParse(yInputField.text, out var result2))
			{
				num2 = result2;
			}
			if (float.TryParse(zInputField.text, out var result3))
			{
				num3 = result3;
			}
			if (float.TryParse(wInputField.text, out var result4))
			{
				num4 = result4;
			}
			SetValue(new Vector4(num, num2, num3, num4));
			UpdateAppearance();
		}

		public override void UpdateAppearance()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Vector4 value = GetValue();
			xInputField.SetTextWithoutNotify(value.x.ToString("F"));
			yInputField.SetTextWithoutNotify(value.y.ToString("F"));
			zInputField.SetTextWithoutNotify(value.z.ToString("F"));
			wInputField.SetTextWithoutNotify(value.w.ToString("F"));
		}
	}
}
namespace ModMenu.Behaviours.OptionList.Dummies
{
	public class ButtonDummy : OptionListItem
	{
		public TextMeshProUGUI buttonTextMeshProText;

		public Button button;

		public string ButtonText
		{
			get
			{
				return ((TMP_Text)buttonTextMeshProText).text;
			}
			set
			{
				((TMP_Text)buttonTextMeshProText).text = value;
			}
		}

		private void Start()
		{
			if (string.IsNullOrWhiteSpace(base.NameText))
			{
				((Component)button).GetComponent<LayoutElement>().flexibleWidth = 1f;
				((Component)nameText).gameObject.SetActive(false);
			}
		}
	}
	public class TextDummy : OptionListItem
	{
		public string Text
		{
			get
			{
				return ((TMP_Text)nameText).text;
			}
			set
			{
				((TMP_Text)nameText).text = value;
			}
		}

		public Color Color
		{
			get
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				return ((Graphic)nameText).color;
			}
			set
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				((Graphic)nameText).color = value;
			}
		}

		public TMP_Style Style
		{
			get
			{
				return ((TMP_Text)nameText).textStyle;
			}
			set
			{
				((TMP_Text)nameText).textStyle = value;
			}
		}

		public float FontSize
		{
			get
			{
				return ((TMP_Text)nameText).fontSize;
			}
			set
			{
				((TMP_Text)nameText).fontSize = value;
			}
		}
	}
}
namespace ModMenu.Behaviours.ModList
{
	internal class ModInfoPanel : MonoBehaviour
	{
		public TextMeshProUGUI descriptionText;

		public TextMeshProUGUI nameText;

		public TextMeshProUGUI extraInfoText;

		public Image icon;

		public ShowTooltip nameTooltip;

		private void Awake()
		{
			ClearInfo();
		}

		public void ShowInfoFor(Mod mod)
		{
			((Behaviour)icon).enabled = true;
			((TMP_Text)nameText).text = mod.info.name;
			((TMP_Text)nameText).ForceMeshUpdate(false, false);
			nameTooltip.textToShow = (((TMP_Text)nameText).isTextTruncated ? mod.info.name : "");
			((TMP_Text)descriptionText).text = mod.info.description;
			icon.sprite = mod.info.icon;
			((TMP_Text)extraInfoText).text = mod.info.guid + "\nv" + mod.info.version;
		}

		public void ClearInfo()
		{
			((Behaviour)icon).enabled = false;
			((TMP_Text)descriptionText).text = "";
			((TMP_Text)nameText).text = "";
			nameTooltip.textToShow = "";
			((TMP_Text)extraInfoText).text = "";
		}
	}
	internal class ModListItem : MonoBehaviour
	{
		public delegate void ModSelectHandler(Mod mod);

		public Image icon;

		public TextMeshProUGUI nameText;

		public TextMeshProUGUI versionText;

		private Mod m_mod;

		public Mod Mod
		{
			get
			{
				return m_mod;
			}
			set
			{
				m_mod = value;
				((TMP_Text)nameText).text = m_mod.info.name;
				((TMP_Text)versionText).text = "v" + m_mod.info.version;
				icon.sprite = m_mod.info.icon;
			}
		}

		public event ModSelectHandler OnModSelected;

		public void OnClick()
		{
			this.OnModSelected?.Invoke(Mod);
		}
	}
	internal class ModListPanel : MonoBehaviour
	{
		public GameObject container;

		public GameObject itemPrefab;

		public OptionListPanel optionListPanel;

		public ModInfoPanel modInfoPanel;

		public OptionInfoPanel optionInfoPanel;

		private void Awake()
		{
			foreach (Mod item in from m in ModMenuManager.mods
				orderby !m.HasAdvancedMetadata, m.info.name, m.info.guid
				select m)
			{
				ModListItem component = Object.Instantiate<GameObject>(itemPrefab, container.transform).GetComponent<ModListItem>();
				((Object)component).name = item.info.name;
				component.Mod = item;
				component.OnModSelected += SelectMod;
			}
		}

		private static bool ShouldDisplayWithFilter(string filter, ModInfo modInfo)
		{
			string value = filter.ToLower();
			if (!modInfo.name.ToLower().Contains(value))
			{
				return modInfo.guid.ToLower().Contains(value);
			}
			return true;
		}

		public void FilterModList(string filter)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			foreach (Transform item in container.transform)
			{
				Transform val = item;
				if (filter == string.Empty)
				{
					((Component)val).gameObject.SetActive(true);
					continue;
				}
				ModListItem component = ((Component)val).GetComponent<ModListItem>();
				if (component != null)
				{
					ModInfo info = component.Mod.info;
					((Component)component).gameObject.SetActive(ShouldDisplayWithFilter(filter, info));
				}
			}
		}

		private void SelectMod(Mod mod)
		{
			optionListPanel.ShowListFor(mod);
			optionInfoPanel.ClearInfo();
			modInfoPanel.ShowInfoFor(mod);
		}
	}
}
namespace ModMenu.Api
{
	public static class ModMenuCustomisation
	{
		internal static Dictionary<string, Action<OptionListContext>> Builders { get; } = new Dictionary<string, Action<OptionListContext>>();

		internal static Dictionary<string, Sprite> Icons { get; } = new Dictionary<string, Sprite>();

		internal static Dictionary<string, string> Descriptions { get; } = new Dictionary<string, string>();

		internal static HashSet<ConfigEntryBase> HiddenConfigEntries { get; } = new HashSet<ConfigEntryBase>();

		public static void RegisterContentBuilder(Action<OptionListContext> builder)
		{
			try
			{
				PluginInfo pluginInfoFromAssembly = BepInExUtils.GetPluginInfoFromAssembly(Assembly.GetCallingAssembly());
				if (pluginInfoFromAssembly != null)
				{
					Builders.Add(pluginInfoFromAssembly.Metadata.GUID, builder);
					return;
				}
				throw new InvalidOperationException("RegisterContentBuilder must be called from an assembly containing a BepInEx plugin.");
			}
			catch (ArgumentException)
			{
				throw new InvalidOperationException("RegisterContentBuilder can only be called once per assembly.");
			}
		}

		public static void HideEntry(ConfigEntryBase entry)
		{
			HiddenConfigEntries.Add(entry);
		}

		public static void HideEntries(IEnumerable<ConfigEntryBase> entries)
		{
			foreach (ConfigEntryBase entry in entries)
			{
				HiddenConfigEntries.Add(entry);
			}
		}

		public static void SetPluginIcon(Sprite icon)
		{
			try
			{
				PluginInfo pluginInfoFromAssembly = BepInExUtils.GetPluginInfoFromAssembly(Assembly.GetCallingAssembly());
				if (pluginInfoFromAssembly != null)
				{
					Icons.Add(pluginInfoFromAssembly.Metadata.GUID, icon);
					return;
				}
				throw new InvalidOperationException("SetPluginIcon must be called from an assembly containing a BepInEx plugin.");
			}
			catch (ArgumentException)
			{
				throw new InvalidOperationException("SetPluginIcon can only be called once per assembly.");
			}
		}

		public static void SetPluginDescription(string description)
		{
			try
			{
				PluginInfo pluginInfoFromAssembly = BepInExUtils.GetPluginInfoFromAssembly(Assembly.GetCallingAssembly());
				if (pluginInfoFromAssembly != null)
				{
					Descriptions.Add(pluginInfoFromAssembly.Metadata.GUID, description);
					return;
				}
				throw new InvalidOperationException("SetPluginDescription must be called from an assembly containing a BepInEx plugin.");
			}
			catch (ArgumentException)
			{
				throw new InvalidOperationException("SetPluginDescription can only be called once per assembly.");
			}
		}
	}
	public class OptionListContext
	{
		private OptionListPanel m_panel;

		private OptionInfoPanel m_infoPanel;

		private HashSet<GameObject> m_originalChildren = new HashSet<GameObject>();

		public Transform Root { get; }

		private T PrependItem<T>(T item) where T : OptionListItem
		{
			((Component)item).transform.SetAsFirstSibling();
			return item;
		}

		private T InsertItem<T>(int position, T item) where T : OptionListItem
		{
			((Component)item).transform.SetSiblingIndex(FindActualIndex(position));
			return item;
		}

		public TextDummy AppendHeader(string text)
		{
			TextDummy component = Object.Instantiate<GameObject>(Assets.CategoryHeader, Root).GetComponent<TextDummy>();
			component.OnItemHovered += ClearInfoPanelContents;
			component.Text = text;
			return component;
		}

		public TextDummy PrependHeader(string text)
		{
			return PrependItem(AppendHeader(text));
		}

		public TextDummy InsertHeader(int position, string text)
		{
			return InsertItem(position, AppendHeader(text));
		}

		public TextDummy AppendTextBox(string text)
		{
			TextDummy component = Object.Instantiate<GameObject>(Assets.TextDummy, Root).GetComponent<TextDummy>();
			component.OnItemHovered += ClearInfoPanelContents;
			component.Text = text;
			return component;
		}

		public TextDummy PrependTextBox(string text)
		{
			return PrependItem(AppendTextBox(text));
		}

		public TextDummy InsertTextBox(int position, string text)
		{
			return InsertItem(position, AppendTextBox(text));
		}

		public ButtonDummy AppendButton(string nameText, string buttonText, Action onClick)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			ButtonDummy component = Object.Instantiate<GameObject>(Assets.ButtonDummy, Root).GetComponent<ButtonDummy>();
			component.OnItemHovered += ClearInfoPanelContents;
			((UnityEvent)component.button.onClick).AddListener(new UnityAction(onClick.Invoke));
			component.ButtonText = buttonText;
			component.NameText = nameText;
			return component;
		}

		public ButtonDummy PrependButton(string nameText, string buttonText, Action onClick)
		{
			return PrependItem(PrependButton(nameText, buttonText, onClick));
		}

		public ButtonDummy InsertButton(int position, string nameText, string buttonText, Action onClick)
		{
			return InsertItem(position, AppendButton(nameText, buttonText, onClick));
		}

		private TController AppendValueController<TController, TValue>(GameObject prefab, string nameText, Func<TValue> getter, Action<TValue> setter) where TController : ValueController<TValue>
		{
			TController component = Object.Instantiate<GameObject>(prefab, Root).GetComponent<TController>();
			component.SetupFromValues(getter, setter);
			component.OnItemHovered += ClearInfoPanelContents;
			component.NameText = nameText;
			return component;
		}

		public BoolValueController AppendCheckbox(string nameText, Func<bool> getter, Action<bool> setter)
		{
			return AppendValueController<BoolValueController, bool>(Assets.BoolCheckboxOption, nameText, getter, setter);
		}

		public BoolValueController PrependCheckbox(string nameText, Func<bool> getter, Action<bool> setter)
		{
			return PrependItem(AppendCheckbox(nameText, getter, setter));
		}

		public BoolValueController InsertCheckbox(int position, string nameText, Func<bool> getter, Action<bool> setter)
		{
			return InsertItem(position, AppendCheckbox(nameText, getter, setter));
		}

		public StringValueController AppendStringInput(string nameText, Func<string> getter, Action<string> setter)
		{
			return AppendValueController<StringValueController, string>(Assets.StringInputFieldOption, nameText, getter, setter);
		}

		public StringValueController PrependStringInput(string nameText, Func<string> getter, Action<string> setter)
		{
			return PrependItem(AppendStringInput(nameText, getter, setter));
		}

		public StringValueController InsertStringInput(int position, string nameText, Func<string> getter, Action<string> setter)
		{
			return InsertItem(position, AppendStringInput(nameText, getter, setter));
		}

		public ColorValueController AppendColorInput(string nameText, Func<Color> getter, Action<Color> setter)
		{
			return AppendValueController<ColorValueController, Color>(Assets.ColorOption, nameText, getter, setter);
		}

		public ColorValueController PrependColorInput(string nameText, Func<Color> getter, Action<Color> setter)
		{
			return PrependItem(AppendColorInput(nameText, getter, setter));
		}

		public ColorValueController InsertColorInput(int position, string nameText, Func<Color> getter, Action<Color> setter)
		{
			return InsertItem(position, AppendColorInput(nameText, getter, setter));
		}

		public KeyboardShortcutValueController AppendKeyboardShortcutInput(string nameText, Func<KeyboardShortcut> getter, Action<KeyboardShortcut> setter)
		{
			return AppendValueController<KeyboardShortcutValueController, KeyboardShortcut>(Assets.KeyboardShortcutOption, nameText, getter, setter);
		}

		public KeyboardShortcutValueController PrependKeyboardShortcutInput(string nameText, Func<KeyboardShortcut> getter, Action<KeyboardShortcut> setter)
		{
			return PrependItem(AppendKeyboardShortcutInput(nameText, getter, setter));
		}

		public KeyboardShortcutValueController InsertKeyboardShortcutInput(int position, string nameText, Func<KeyboardShortcut> getter, Action<KeyboardShortcut> setter)
		{
			return InsertItem(position, AppendKeyboardShortcutInput(nameText, getter, setter));
		}

		public KeyCodeValueController AppendKeyCodeInput(string nameText, Func<KeyCode> getter, Action<KeyCode> setter)
		{
			return AppendValueController<KeyCodeValueController, KeyCode>(Assets.KeyCodeOption, nameText, getter, setter);
		}

		public KeyCodeValueController PrependKeyCodeInput(string nameText, Func<KeyCode> getter, Action<KeyCode> setter)
		{
			return PrependItem(AppendKeyCodeInput(nameText, getter, setter));
		}

		public KeyCodeValueController InsertKeyCodeInput(int position, string nameText, Func<KeyCode> getter, Action<KeyCode> setter)
		{
			return InsertItem(position, AppendKeyCodeInput(nameText, getter, setter));
		}

		public QuaternionValueController AppendQuaternionInput(string nameText, Func<Quaternion> getter, Action<Quaternion> setter)
		{
			return AppendValueController<QuaternionValueController, Quaternion>(Assets.QuaternionOption, nameText, getter, setter);
		}

		public QuaternionValueController PrependQuaternionInput(string nameText, Func<Quaternion> getter, Action<Quaternion> setter)
		{
			return PrependItem(AppendQuaternionInput(nameText, getter, setter));
		}

		public QuaternionValueController InsertQuaternionInput(int position, string nameText, Func<Quaternion> getter, Action<Quaternion> setter)
		{
			return InsertItem(position, AppendQuaternionInput(nameText, getter, setter));
		}

		public Vector2ValueController AppendVector2Input(string nameText, Func<Vector2> getter, Action<Vector2> setter)
		{
			return AppendValueController<Vector2ValueController, Vector2>(Assets.Vector2Option, nameText, getter, setter);
		}

		public Vector2ValueController PrependVector2Input(string nameText, Func<Vector2> getter, Action<Vector2> setter)
		{
			return PrependItem(AppendVector2Input(nameText, getter, setter));
		}

		public Vector2ValueController InsertVector2Input(int position, string nameText, Func<Vector2> getter, Action<Vector2> setter)
		{
			return InsertItem(position, AppendVector2Input(nameText, getter, setter));
		}

		public Vector3ValueController AppendVector3Input(string nameText, Func<Vector3> getter, Action<Vector3> setter)
		{
			return AppendValueController<Vector3ValueController, Vector3>(Assets.Vector3Option, nameText, getter, setter);
		}

		public Vector3ValueController PrependVector3Input(string nameText, Func<Vector3> getter, Action<Vector3> setter)
		{
			return PrependItem(AppendVector3Input(nameText, getter, setter));
		}

		public Vector3ValueController InsertVector3Input(int position, string nameText, Func<Vector3> getter, Action<Vector3> setter)
		{
			return InsertItem(position, AppendVector3Input(nameText, getter, setter));
		}

		public Vector4ValueController AppendVector4Input(string nameText, Func<Vector4> getter, Action<Vector4> setter)
		{
			return AppendValueController<Vector4ValueController, Vector4>(Assets.Vector4Option, nameText, getter, setter);
		}

		public Vector4ValueController PrependVector4Input(string nameText, Func<Vector4> getter, Action<Vector4> setter)
		{
			return PrependItem(AppendVector4Input(nameText, getter, setter));
		}

		public Vector4ValueController InsertVector4Input(int position, string nameText, Func<Vector4> getter, Action<Vector4> setter)
		{
			return InsertItem(position, AppendVector4Input(nameText, getter, setter));
		}

		public DropdownValueController AppendDropdown<T>(string nameText, Func<T> getter, Action<T> setter) where T : Enum
		{
			DropdownValueController component = Object.Instantiate<GameObject>(Assets.EnumDropdownOption, Root).GetComponent<DropdownValueController>();
			component.SetupFromValues(getter, setter);
			component.OnItemHovered += ClearInfoPanelContents;
			component.NameText = nameText;
			return component;
		}

		public DropdownValueController PrependDropdown<T>(string nameText, Func<T> getter, Action<T> setter) where T : Enum
		{
			return PrependItem(AppendDropdown(nameText, getter, setter));
		}

		public DropdownValueController InsertDropdown<T>(int position, string nameText, Func<T> getter, Action<T> setter) where T : Enum
		{
			return InsertItem(position, AppendDropdown(nameText, getter, setter));
		}

		public NumericInputFieldValueController AppendNumericInputField<T>(string nameText, Func<T> getter, Action<T> setter) where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
		{
			NumericInputFieldValueController component = Object.Instantiate<GameObject>(typeof(T).IsFloating() ? Assets.FloatingInputFieldOption : Assets.IntegralInputFieldOption, Root).GetComponent<NumericInputFieldValueController>();
			component.SetupFromValues(getter, setter);
			component.OnItemHovered += ClearInfoPanelContents;
			component.NameText = nameText;
			return component;
		}

		public NumericInputFieldValueController PrependNumericInputField<T>(string nameText, Func<T> getter, Action<T> setter) where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
		{
			return PrependItem(AppendNumericInputField(nameText, getter, setter));
		}

		public NumericInputFieldValueController InsertNumericInputField<T>(int position, string nameText, Func<T> getter, Action<T> setter) where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
		{
			return InsertItem(position, AppendNumericInputField(nameText, getter, setter));
		}

		public NumericSliderValueController AppendNumericSlider<T>(string nameText, Func<T> getter, Action<T> setter, float minValue, float maxValue) where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
		{
			if (minValue >= maxValue)
			{
				throw new ArgumentException("minValue must be < maxValue");
			}
			NumericSliderValueController component = Object.Instantiate<GameObject>(typeof(T).IsFloating() ? Assets.FloatingSliderOption : Assets.IntegralSliderOption, Root).GetComponent<NumericSliderValueController>();
			component.SetupFromValues(getter, setter);
			component.OnItemHovered += ClearInfoPanelContents;
			component.slider.minValue = minValue;
			component.slider.maxValue = maxValue;
			component.NameText = nameText;
			return component;
		}

		public NumericSliderValueController PrependNumericSlider<T>(string nameText, Func<T> getter, Action<T> setter, float minValue, float maxValue) where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
		{
			return PrependItem(AppendNumericSlider(nameText, getter, setter, minValue, maxValue));
		}

		public NumericSliderValueController InsertNumericSlider<T>(int position, string nameText, Func<T> getter, Action<T> setter, float minValue, float maxValue) where T : struct, IComparable, IComparable<T>, IConvertible, IEquatable<T>, IFormattable
		{
			return InsertItem(position, AppendNumericSlider(nameText, getter, setter, minValue, maxValue));
		}

		internal OptionListContext(OptionListPanel panel)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			m_panel = panel;
			m_infoPanel = panel.infoPanel;
			Root = panel.container.transform;
			foreach (Transform item in Root)
			{
				Transform val = item;
				m_originalChildren.Add(((Component)val).gameObject);
			}
		}

		public void SetInfoPanelContents(string title, string subtitle, string description)
		{
			m_infoPanel.SetContents(title, subtitle, description);
		}

		public void ClearInfoPanelContents()
		{
			m_infoPanel.ClearInfo();
		}

		public void ShowInfoPanelResetButton(Action resetAction)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			((Component)m_infoPanel.resetButton).gameObject.SetActive(true);
			((UnityEvent)m_infoPanel.resetButton.onClick).AddListener((UnityAction)delegate
			{
				resetAction?.Invoke();
			});
		}

		internal GameObject AppendControllerForOption(Option option)
		{
			GameObject val = Object.Instantiate<GameObject>(option.GetListItemPrefab(), Root);
			BoxedValueController controller = val.GetComponent<BoxedValueController>();
			controller.SetupFromOption(option);
			controller.NameText = option.Name;
			controller.OnItemHovered += delegate
			{
				m_infoPanel.ShowInfoFor(option);
				m_infoPanel.ShowResetButtonFor(controller);
			};
			return ((Component)controller).gameObject;
		}

		internal GameObject[] GetNewChildren()
		{
			if (Root.childCount == m_originalChildren.Count)
			{
				return Array.Empty<GameObject>();
			}
			List<GameObject> list = new List<GameObject>();
			for (int i = 0; i < Root.childCount; i++)
			{
				GameObject gameObject = ((Component)Root.GetChild(i)).gameObject;
				if (!m_originalChildren.Contains(gameObject))
				{
					list.Add(gameObject);
				}
			}
			return list.ToArray();
		}

		private int FindActualIndex(int index)
		{
			Transform[] array = (from Transform child in (IEnumerable)Root
				where ((Component)child).gameObject.activeSelf
				select child).ToArray();
			index = Math.Clamp(index, 0, array.Length - 1);
			return ((Component)array[index]).transform.GetSiblingIndex();
		}
	}
}

BepInEx/plugins/MONOLITH/MONOLITH.dll

Decompiled 41 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CombatSounds;
using ComputerysModdingUtilities;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using DorsthTweaks;
using EzCrosshair;
using FishNet;
using FishNet.Component.Utility;
using FishNet.Connection;
using FishNet.Managing;
using FishNet.Object;
using FishNet.Object.Synchronizing;
using HarmonyLib;
using HeathenEngineering.PhysKit;
using ModMenu.Api;
using ModMenu.Behaviours.OptionList.Dummies;
using ModMenu.Behaviours.OptionList.ValueControllers;
using Steamworks;
using TMPro;
using UltimateTweaks;
using Unity.Collections;
using Unity.Jobs.LowLevel.Unsafe;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Experimental.Rendering;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.LowLevel;
using UnityEngine.Networking;
using UnityEngine.PlayerLoop;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.SceneManagement;
using UnityEngine.Scripting;
using UnityEngine.UI;
using UnityStandardAssets.Effects;
using UnityStandardAssets.Water;
using VLB;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MONOLITH")]
[assembly: AssemblyDescription("Every Dorsth mod for STRAFTAT in one file. Dorsth was here.")]
[assembly: StraftatMod(true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
namespace TrueSens
{
	[BepInPlugin("dorsth.straftat.truesens", "TrueSens", "1.2.2")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "dorsth.straftat.truesens";

		public const string Name = "TrueSens";

		public const string Version = "1.2.2";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> On;

		internal static ConfigEntry<int> Dpi;

		internal static ConfigEntry<float> Cm360;

		internal static ConfigEntry<float> AdsMult;

		internal static ConfigEntry<float> ScopedMult;

		internal const float MinCm = 5f;

		internal const float MaxCm = 150f;

		internal const float MinMult = 0.1f;

		internal const float MaxMult = 3f;

		private static bool _swapped;

		private static float _sens;

		private static float _sensX;

		private static float _sensY;

		private void Awake()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Expected O, but got Unknown
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_027e: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			On = ((BaseUnityPlugin)this).Config.Bind<bool>("Sensitivity", "Enabled", true, "Set your sensitivity from your DPI and cm/360. Off: the game's own sensitivity settings.");
			Dpi = ((BaseUnityPlugin)this).Config.Bind<int>("Sensitivity", "Mouse DPI", 800, new ConfigDescription("The DPI your mouse is set to.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(100, 32000), Array.Empty<object>()));
			Cm360 = ((BaseUnityPlugin)this).Config.Bind<float>("Sensitivity", "cm/360", 30f, new ConfigDescription("How far you move your mouse, in cm, for a full turn.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 150f), Array.Empty<object>()));
			AdsMult = ((BaseUnityPlugin)this).Config.Bind<float>("Sensitivity", "ADS Multiplier", 1f, new ConfigDescription("Sensitivity while aiming down sights, times the zoom scaling. 1 matches your normal aim.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
			ScopedMult = ((BaseUnityPlugin)this).Config.Bind<float>("Sensitivity", "Scoped Multiplier", 1f, new ConfigDescription("Sensitivity while looking through a scope, times the zoom scaling. 1 matches your normal aim.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
			On.SettingChanged += delegate
			{
				if (!On.Value)
				{
					Restore();
				}
				SettingsMenu.RefreshAll();
				Report();
			};
			Dpi.SettingChanged += delegate
			{
				SettingsMenu.RefreshAll();
				Report();
			};
			Cm360.SettingChanged += delegate
			{
				SettingsMenu.RefreshAll();
				Report();
			};
			AdsMult.SettingChanged += delegate
			{
				SettingsMenu.RefreshAll();
			};
			ScopedMult.SettingChanged += delegate
			{
				SettingsMenu.RefreshAll();
			};
			Harmony val = new Harmony("dorsth.straftat.truesens");
			val.Patch((MethodBase)AccessTools.Method(typeof(FirstPersonController), "HandleMouseLook", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "LookPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(KillCam), "Update", (Type[])null, (Type[])null);
			if (methodInfo != null)
			{
				val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "KillCamPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "KillCamPostfix", (Type[])null), (HarmonyMethod)null);
			}
			try
			{
				SettingsMenu.Install(val);
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("The game's sensitivity sliders stay as they are: " + ex.Message));
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"TrueSens 1.2.2 loaded. Dorsth was here.");
			Report();
		}

		internal static float HipSens()
		{
			return 9144f / (Mathf.Max(5f, Cm360.Value) * (float)Mathf.Max(100, Dpi.Value));
		}

		private static void Report()
		{
			if (On.Value)
			{
				Log.LogInfo((object)("Sensitivity " + HipSens().ToString("0.####") + " for " + Dpi.Value + " dpi at " + Cm360.Value.ToString("0.##") + " cm/360"));
			}
		}

		internal static float ZoomFactor(float zoomFov, float hipFov)
		{
			if (zoomFov <= 0f || hipFov <= 0f || zoomFov >= hipFov)
			{
				return 1f;
			}
			return Mathf.Tan(zoomFov * 0.5f * ((float)Math.PI / 180f)) / Mathf.Tan(hipFov * 0.5f * ((float)Math.PI / 180f));
		}

		private static void LookPrefix(FirstPersonController __instance)
		{
			if (On.Value && ((NetworkBehaviour)__instance).IsOwner && (!((Object)(object)__instance.pauseManager != (Object)null) || !__instance.pauseManager.gamepad))
			{
				float num = (__instance.lookSpeedY = (__instance.lookSpeedX = HipSens())) * ZoomFactor(__instance.zoomFOV, __instance.defaultFOV);
				__instance.lookSpeedAimNoScope = num * AdsMult.Value;
				__instance.lookSpeedAim = num * ScopedMult.Value;
			}
		}

		private static void KillCamPrefix()
		{
			if (On.Value)
			{
				Settings instance = Settings.Instance;
				if (!((Object)(object)instance == (Object)null) && (!((Object)(object)PauseManager.Instance != (Object)null) || !PauseManager.Instance.gamepad))
				{
					_sens = instance.mouseSensitivity;
					_sensX = instance.horizontalSensitivity;
					_sensY = instance.verticalSensitivity;
					float verticalSensitivity = HipSens();
					instance.mouseSensitivity = (instance.horizontalSensitivity = (instance.verticalSensitivity = verticalSensitivity));
					_swapped = true;
				}
			}
		}

		private static void KillCamPostfix()
		{
			if (_swapped)
			{
				_swapped = false;
				Settings instance = Settings.Instance;
				if (!((Object)(object)instance == (Object)null))
				{
					instance.mouseSensitivity = _sens;
					instance.horizontalSensitivity = _sensX;
					instance.verticalSensitivity = _sensY;
				}
			}
		}

		private static void Restore()
		{
			try
			{
				Settings instance = Settings.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return;
				}
				FirstPersonController[] array = Object.FindObjectsOfType<FirstPersonController>();
				foreach (FirstPersonController val in array)
				{
					if (!((Object)(object)val == (Object)null) && ((NetworkBehaviour)val).IsOwner)
					{
						val.lookSpeedX = (instance.toggleTwoAxis ? instance.horizontalSensitivity : instance.mouseSensitivity);
						val.lookSpeedY = (instance.toggleTwoAxis ? instance.verticalSensitivity : instance.mouseSensitivity);
						val.lookSpeedAim = instance.mouseAimScopeSensitivity;
						val.lookSpeedAimNoScope = instance.mouseAimSensitivity;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Could not restore the game's sensitivity: " + ex.Message));
			}
		}
	}
	internal static class SettingsMenu
	{
		internal enum Kind
		{
			None,
			Cm,
			Ads,
			Scoped,
			Dpi,
			Sens
		}

		private static FieldRef<DisplayLoadValues, bool> sensFlag;

		private static FieldRef<DisplayLoadValues, bool> adsFlag;

		private static FieldRef<DisplayLoadValues, bool> scopedFlag;

		private static FieldRef<DisplayLoadValues, bool> twoAxisFlag;

		private static FieldRef<DisplayLoadValues, bool> xFlag;

		private static FieldRef<DisplayLoadValues, bool> yFlag;

		private static readonly List<Takeover> live = new List<Takeover>();

		private static readonly List<SwitchTakeover> switches = new List<SwitchTakeover>();

		private static Slider pressedNumber;

		internal static void Install(Harmony harmony)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			sensFlag = AccessTools.FieldRefAccess<DisplayLoadValues, bool>("mouseSensitivity");
			adsFlag = AccessTools.FieldRefAccess<DisplayLoadValues, bool>("mouseAimSensitivity");
			scopedFlag = AccessTools.FieldRefAccess<DisplayLoadValues, bool>("mouseAimScopeSensitivity");
			twoAxisFlag = AccessTools.FieldRefAccess<DisplayLoadValues, bool>("toggleTwoAxis");
			xFlag = AccessTools.FieldRefAccess<DisplayLoadValues, bool>("mouseXSensitivity");
			yFlag = AccessTools.FieldRefAccess<DisplayLoadValues, bool>("mouseYSensitivity");
			harmony.Patch((MethodBase)AccessTools.Method(typeof(DisplayLoadValues), "Start", (Type[])null, (Type[])null), new HarmonyMethod(typeof(SettingsMenu), "StartPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			HarmonyMethod val = new HarmonyMethod(typeof(SettingsMenu), "PressPrefix", (Type[])null);
			HarmonyMethod val2 = new HarmonyMethod(typeof(SettingsMenu), "DragPrefix", (Type[])null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Slider), "OnPointerDown", new Type[1] { typeof(PointerEventData) }, (Type[])null), val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Slider), "OnInitializePotentialDrag", new Type[1] { typeof(PointerEventData) }, (Type[])null), val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Slider), "OnDrag", new Type[1] { typeof(PointerEventData) }, (Type[])null), val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static bool PressPrefix(Slider __instance, PointerEventData eventData)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			pressedNumber = null;
			try
			{
				if (eventData == null || !Plugin.On.Value)
				{
					return true;
				}
				Takeover component = ((Component)__instance).GetComponent<Takeover>();
				if ((Object)(object)component == (Object)null || !component.OverNumber(eventData.position))
				{
					return true;
				}
				pressedNumber = __instance;
				return false;
			}
			catch
			{
				return true;
			}
		}

		private static bool DragPrefix(Slider __instance)
		{
			if ((Object)(object)pressedNumber == (Object)null)
			{
				return true;
			}
			if (!Input.GetMouseButton(0))
			{
				pressedNumber = null;
				return true;
			}
			return (Object)(object)pressedNumber != (Object)(object)__instance;
		}

		private static Kind KindOf(DisplayLoadValues d)
		{
			if (sensFlag.Invoke(d))
			{
				return Kind.Cm;
			}
			if (adsFlag.Invoke(d))
			{
				return Kind.Ads;
			}
			if (scopedFlag.Invoke(d))
			{
				return Kind.Scoped;
			}
			if (xFlag.Invoke(d))
			{
				return Kind.Dpi;
			}
			if (yFlag.Invoke(d))
			{
				return Kind.Sens;
			}
			return Kind.None;
		}

		private static bool StartPrefix(DisplayLoadValues __instance)
		{
			try
			{
				if (twoAxisFlag.Invoke(__instance))
				{
					Toggle component = ((Component)__instance).GetComponent<Toggle>();
					if ((Object)(object)component == (Object)null)
					{
						return true;
					}
					(((Component)__instance).gameObject.GetComponent<SwitchTakeover>() ?? ((Component)__instance).gameObject.AddComponent<SwitchTakeover>()).Init(component);
					return true;
				}
				Kind kind = KindOf(__instance);
				if (kind == Kind.None)
				{
					return true;
				}
				Slider component2 = ((Component)__instance).GetComponent<Slider>();
				if ((Object)(object)component2 == (Object)null)
				{
					return true;
				}
				(((Component)__instance).gameObject.GetComponent<Takeover>() ?? ((Component)__instance).gameObject.AddComponent<Takeover>()).Init(kind, component2);
				return !Plugin.On.Value;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Sensitivity setting left as it is: " + ex.Message));
				return true;
			}
		}

		internal static void RefreshAll()
		{
			for (int num = live.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)live[num] == (Object)null)
				{
					live.RemoveAt(num);
				}
				else
				{
					live[num].Refresh();
				}
			}
			for (int num2 = switches.Count - 1; num2 >= 0; num2--)
			{
				if ((Object)(object)switches[num2] == (Object)null)
				{
					switches.RemoveAt(num2);
				}
				else
				{
					switches[num2].Refresh();
				}
			}
		}

		internal static void Add(Takeover t)
		{
			if (!live.Contains(t))
			{
				live.Add(t);
			}
		}

		internal static void Remove(Takeover t)
		{
			live.Remove(t);
		}

		internal static void Add(SwitchTakeover t)
		{
			if (!switches.Contains(t))
			{
				switches.Add(t);
			}
		}

		internal static void Remove(SwitchTakeover t)
		{
			switches.Remove(t);
		}

		internal static string Fmt(float v, string f)
		{
			return v.ToString(f, CultureInfo.InvariantCulture);
		}

		internal static TextMeshProUGUI FindLabel(Transform from, Func<string, bool> match)
		{
			int num = 0;
			Transform val = from;
			while ((Object)(object)val != (Object)null && num < 5)
			{
				TextMeshProUGUI[] componentsInChildren = ((Component)val).GetComponentsInChildren<TextMeshProUGUI>(true);
				foreach (TextMeshProUGUI val2 in componentsInChildren)
				{
					if (!string.IsNullOrEmpty(((TMP_Text)val2).text) && match(((TMP_Text)val2).text.ToLowerInvariant()))
					{
						return val2;
					}
				}
				val = val.parent;
				num++;
			}
			return null;
		}
	}
	internal sealed class Takeover : MonoBehaviour
	{
		private SettingsMenu.Kind kind;

		private Slider slider;

		private TextMeshProUGUI label;

		private TextMeshProUGUI value;

		private Behaviour gameText;

		private string labelBefore;

		private float minBefore;

		private float maxBefore;

		private bool wholeBefore;

		private bool applied;

		private bool ready;

		private bool busy;

		private TypeIn typing;

		private readonly List<Graphic> hidden = new List<Graphic>();

		private Vector2 labelPos;

		private Vector2 labelSize;

		private Vector2 valuePos;

		private Vector2 valueSize;

		private bool moved;

		private TextAlignmentOptions alignBefore;

		private const float LabelX = -13.7f;

		private const float ValueX = 148.5f;

		private const float LabelY = 17.1f;

		private const float ValueY = 14.6f;

		private bool HasSlider
		{
			get
			{
				if (kind != SettingsMenu.Kind.Cm && kind != SettingsMenu.Kind.Ads)
				{
					return kind == SettingsMenu.Kind.Scoped;
				}
				return true;
			}
		}

		private bool Typeable => kind != SettingsMenu.Kind.Sens;

		public void Init(SettingsMenu.Kind k, Slider s)
		{
			if (!ready)
			{
				kind = k;
				slider = s;
				minBefore = s.minValue;
				maxBefore = s.maxValue;
				wholeBefore = s.wholeNumbers;
				ChangeTextValue componentInParent = ((Component)s).GetComponentInParent<ChangeTextValue>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					gameText = (Behaviour)(object)componentInParent;
					value = Traverse.Create((object)componentInParent).Field("textMesh").GetValue<TextMeshProUGUI>() ?? ((Component)componentInParent).GetComponentInChildren<TextMeshProUGUI>(true);
				}
				label = SettingsMenu.FindLabel(((Component)s).transform.parent, IsLabel);
				if ((Object)(object)label != (Object)null)
				{
					labelBefore = ((TMP_Text)label).text;
				}
				((UnityEvent<float>)(object)s.onValueChanged).AddListener((UnityAction<float>)Slid);
				if ((Object)(object)value != (Object)null && Typeable)
				{
					((Graphic)value).raycastTarget = true;
					typing = ((Component)value).gameObject.AddComponent<TypeIn>();
					typing.Setup(value, (kind == SettingsMenu.Kind.Dpi) ? "0123456789" : "0123456789.", ShowValue, TypedValue);
				}
				ready = true;
				SettingsMenu.Add(this);
				Refresh();
			}
		}

		private void OnDestroy()
		{
			SettingsMenu.Remove(this);
		}

		public bool OverNumber(Vector2 screen)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)typing != (Object)null)
			{
				return typing.Over(screen);
			}
			return false;
		}

		private bool IsLabel(string s)
		{
			if (!s.Contains("sensitivity"))
			{
				return false;
			}
			switch (kind)
			{
			case SettingsMenu.Kind.Cm:
				if (s.Contains("mouse") && !s.Contains("aim"))
				{
					return !s.Contains("sniper");
				}
				return false;
			case SettingsMenu.Kind.Ads:
				if (s.Contains("aim"))
				{
					return !s.Contains("sniper");
				}
				return false;
			case SettingsMenu.Kind.Scoped:
				if (!s.Contains("sniper"))
				{
					return s.Contains("scope");
				}
				return true;
			case SettingsMenu.Kind.Dpi:
				return s.Contains("horizontal");
			default:
				return s.Contains("vertical");
			}
		}

		private string Title()
		{
			return kind switch
			{
				SettingsMenu.Kind.Cm => "cm/360", 
				SettingsMenu.Kind.Ads => "ADS Multiplier", 
				SettingsMenu.Kind.Scoped => "Scoped Multiplier", 
				SettingsMenu.Kind.Dpi => "Mouse DPI", 
				_ => "Game Sensitivity", 
			};
		}

		public void Refresh()
		{
			if (!ready || (Object)(object)slider == (Object)null)
			{
				return;
			}
			busy = true;
			try
			{
				if (Plugin.On.Value)
				{
					Apply();
				}
				else
				{
					Revert();
				}
			}
			finally
			{
				busy = false;
			}
		}

		private void Apply()
		{
			//IL_017f: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: 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_01fe: 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_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			if (!applied)
			{
				for (int i = 0; i < ((UnityEventBase)slider.onValueChanged).GetPersistentEventCount(); i++)
				{
					((UnityEventBase)slider.onValueChanged).SetPersistentListenerState(i, (UnityEventCallState)0);
				}
				if ((Object)(object)gameText != (Object)null)
				{
					gameText.enabled = false;
				}
				applied = true;
			}
			if (HasSlider)
			{
				slider.wholeNumbers = false;
				if (kind == SettingsMenu.Kind.Cm)
				{
					slider.minValue = 5f;
					slider.maxValue = 100f;
				}
				else
				{
					slider.minValue = 0.1f;
					slider.maxValue = 3f;
				}
				slider.SetValueWithoutNotify(Current());
			}
			else if (hidden.Count == 0)
			{
				((Selectable)slider).interactable = false;
				Graphic[] componentsInChildren = ((Component)slider).GetComponentsInChildren<Graphic>(true);
				foreach (Graphic val in componentsInChildren)
				{
					if (((Behaviour)val).enabled && !(val is TMP_Text))
					{
						((Behaviour)val).enabled = false;
						hidden.Add(val);
					}
				}
			}
			if (!HasSlider && !moved && (Object)(object)label != (Object)null && (Object)(object)value != (Object)null)
			{
				moved = true;
				RectTransform rectTransform = ((TMP_Text)label).rectTransform;
				RectTransform rectTransform2 = ((TMP_Text)value).rectTransform;
				labelPos = rectTransform.anchoredPosition;
				labelSize = rectTransform.sizeDelta;
				valuePos = rectTransform2.anchoredPosition;
				valueSize = rectTransform2.sizeDelta;
				rectTransform.anchoredPosition = new Vector2(-13.7f, 17.1f);
				rectTransform.sizeDelta = new Vector2(302.5f, 19.9f);
				rectTransform2.anchoredPosition = new Vector2(148.5f, 14.6f);
				rectTransform2.sizeDelta = new Vector2(50.3f, 28.6f);
				alignBefore = ((TMP_Text)value).alignment;
				if (kind == SettingsMenu.Kind.Dpi)
				{
					((TMP_Text)value).alignment = (TextAlignmentOptions)4097;
					float x = ((Transform)rectTransform).localPosition.x;
					float x2 = rectTransform.pivot.x;
					Rect rect = rectTransform.rect;
					float num = x - x2 * ((Rect)(ref rect)).width;
					float x3 = ((TMP_Text)label).GetPreferredValues(Title()).x;
					Vector3 localPosition = ((Transform)rectTransform2).localPosition;
					float num2 = num + x3 + 14f;
					float x4 = rectTransform2.pivot.x;
					rect = rectTransform2.rect;
					((Transform)rectTransform2).localPosition = new Vector3(num2 + x4 * ((Rect)(ref rect)).width, localPosition.y, localPosition.z);
				}
			}
			if ((Object)(object)label != (Object)null)
			{
				((TMP_Text)label).text = Title();
			}
			if ((Object)(object)value != (Object)null && ((Object)(object)typing == (Object)null || !typing.Editing))
			{
				((TMP_Text)value).text = ShowValue();
			}
		}

		private void Revert()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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)
			if (!applied)
			{
				return;
			}
			applied = false;
			for (int i = 0; i < ((UnityEventBase)slider.onValueChanged).GetPersistentEventCount(); i++)
			{
				((UnityEventBase)slider.onValueChanged).SetPersistentListenerState(i, (UnityEventCallState)2);
			}
			foreach (Graphic item in hidden)
			{
				if ((Object)(object)item != (Object)null)
				{
					((Behaviour)item).enabled = true;
				}
			}
			hidden.Clear();
			if (moved)
			{
				moved = false;
				((TMP_Text)label).rectTransform.anchoredPosition = labelPos;
				((TMP_Text)label).rectTransform.sizeDelta = labelSize;
				((TMP_Text)value).rectTransform.anchoredPosition = valuePos;
				((TMP_Text)value).rectTransform.sizeDelta = valueSize;
				((TMP_Text)value).alignment = alignBefore;
			}
			((Selectable)slider).interactable = true;
			slider.minValue = minBefore;
			slider.maxValue = maxBefore;
			slider.wholeNumbers = wholeBefore;
			slider.SetValueWithoutNotify(PlayerPrefs.GetFloat(PrefKey(), slider.value));
			if ((Object)(object)label != (Object)null && labelBefore != null)
			{
				((TMP_Text)label).text = labelBefore;
			}
			if ((Object)(object)gameText != (Object)null)
			{
				gameText.enabled = true;
				((ChangeTextValue)gameText).ChangeIntValue(slider);
			}
		}

		private string PrefKey()
		{
			return kind switch
			{
				SettingsMenu.Kind.Cm => "mouseSensitivity", 
				SettingsMenu.Kind.Ads => "mouseAimSensitivity", 
				SettingsMenu.Kind.Scoped => "mouseAimScopeSensitivity", 
				SettingsMenu.Kind.Dpi => "mouseXSensitivity", 
				_ => "mouseYSensitivity", 
			};
		}

		private float Current()
		{
			return kind switch
			{
				SettingsMenu.Kind.Cm => Plugin.Cm360.Value, 
				SettingsMenu.Kind.Ads => Plugin.AdsMult.Value, 
				SettingsMenu.Kind.Scoped => Plugin.ScopedMult.Value, 
				SettingsMenu.Kind.Dpi => Plugin.Dpi.Value, 
				_ => Plugin.HipSens(), 
			};
		}

		private void Set(float v)
		{
			switch (kind)
			{
			case SettingsMenu.Kind.Cm:
				Plugin.Cm360.Value = Mathf.Clamp(Mathf.Round(v * 10f) / 10f, 5f, 150f);
				break;
			case SettingsMenu.Kind.Ads:
				Plugin.AdsMult.Value = Mathf.Clamp(Mathf.Round(v * 100f) / 100f, 0.1f, 3f);
				break;
			case SettingsMenu.Kind.Scoped:
				Plugin.ScopedMult.Value = Mathf.Clamp(Mathf.Round(v * 100f) / 100f, 0.1f, 3f);
				break;
			case SettingsMenu.Kind.Dpi:
				Plugin.Dpi.Value = Mathf.Clamp(Mathf.RoundToInt(v), 100, 32000);
				break;
			}
		}

		private void Slid(float v)
		{
			if (!busy && applied && HasSlider)
			{
				Set(v);
			}
		}

		private string ShowValue()
		{
			string text;
			switch (kind)
			{
			case SettingsMenu.Kind.Cm:
				text = SettingsMenu.Fmt(Plugin.Cm360.Value, "0.0");
				break;
			case SettingsMenu.Kind.Dpi:
				text = Plugin.Dpi.Value.ToString(CultureInfo.InvariantCulture);
				break;
			case SettingsMenu.Kind.Sens:
				return SettingsMenu.Fmt(Plugin.HipSens(), "0.###");
			default:
				text = SettingsMenu.Fmt(Current(), "0.00");
				break;
			}
			return "<u>" + text + "</u>";
		}

		private bool TypedValue(string text)
		{
			if (!float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return false;
			}
			Set(result);
			return true;
		}
	}
	internal sealed class SwitchTakeover : MonoBehaviour
	{
		private const string Note = "You must set your DPI below";

		private static readonly Color Box = Color.black;

		private static readonly Color Face = Color32.op_Implicit(new Color32((byte)181, (byte)247, (byte)183, byte.MaxValue));

		private Toggle toggle;

		private TextMeshProUGUI label;

		private TextMeshProUGUI smiley;

		private string labelBefore;

		private Transition transitionBefore;

		private Color boxBefore;

		private bool tickWasOn;

		private bool applied;

		private bool ready;

		public void Init(Toggle t)
		{
			if (!ready)
			{
				toggle = t;
				label = SettingsMenu.FindLabel(((Component)t).transform, (string s) => s.Contains("axis"));
				if ((Object)(object)label != (Object)null)
				{
					labelBefore = ((TMP_Text)label).text;
				}
				ready = true;
				SettingsMenu.Add(this);
				Refresh();
			}
		}

		private void OnDestroy()
		{
			SettingsMenu.Remove(this);
		}

		public void Refresh()
		{
			//IL_0145: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			if (!ready || (Object)(object)toggle == (Object)null)
			{
				return;
			}
			if (Plugin.On.Value)
			{
				if (!applied)
				{
					applied = true;
					transitionBefore = ((Selectable)toggle).transition;
					((Selectable)toggle).transition = (Transition)0;
					((Selectable)toggle).interactable = false;
					if ((Object)(object)toggle.graphic != (Object)null)
					{
						tickWasOn = ((Behaviour)toggle.graphic).enabled;
						((Behaviour)toggle.graphic).enabled = false;
					}
					if ((Object)(object)((Selectable)toggle).targetGraphic != (Object)null)
					{
						boxBefore = ((Selectable)toggle).targetGraphic.color;
						((Selectable)toggle).targetGraphic.color = Box;
					}
					MakeSmiley();
				}
				if ((Object)(object)smiley != (Object)null)
				{
					((Component)smiley).gameObject.SetActive(true);
				}
				if ((Object)(object)label != (Object)null)
				{
					((TMP_Text)label).text = "You must set your DPI below";
				}
			}
			else if (applied)
			{
				applied = false;
				((Selectable)toggle).interactable = true;
				((Selectable)toggle).transition = transitionBefore;
				if ((Object)(object)toggle.graphic != (Object)null)
				{
					((Behaviour)toggle.graphic).enabled = tickWasOn || ((Behaviour)toggle.graphic).enabled;
				}
				if ((Object)(object)((Selectable)toggle).targetGraphic != (Object)null)
				{
					((Selectable)toggle).targetGraphic.color = boxBefore;
				}
				if ((Object)(object)smiley != (Object)null)
				{
					((Component)smiley).gameObject.SetActive(false);
				}
				if ((Object)(object)label != (Object)null && labelBefore != null)
				{
					((TMP_Text)label).text = labelBefore;
				}
				if ((Object)(object)Settings.Instance != (Object)null)
				{
					toggle.SetIsOnWithoutNotify(Settings.Instance.toggleTwoAxis);
				}
			}
		}

		private void MakeSmiley()
		{
			//IL_002d: 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_0063: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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_01b1: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)smiley != (Object)null))
			{
				RectTransform val = (RectTransform)(((Object)(object)((Selectable)toggle).targetGraphic != (Object)null) ? ((object)((Selectable)toggle).targetGraphic.rectTransform) : ((object)(RectTransform)((Component)toggle).transform));
				GameObject val2 = new GameObject("TrueSens Smiley", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent((Transform)(object)val, false);
				smiley = val2.AddComponent<TextMeshProUGUI>();
				if ((Object)(object)label != (Object)null)
				{
					((TMP_Text)smiley).font = ((TMP_Text)label).font;
					((TMP_Text)smiley).fontSharedMaterial = ((TMP_Text)label).fontSharedMaterial;
					((TMP_Text)smiley).fontStyle = ((TMP_Text)label).fontStyle;
				}
				((Graphic)smiley).color = Face;
				bool flag = false;
				try
				{
					flag = (Object)(object)((TMP_Text)smiley).font != (Object)null && ((TMP_Text)smiley).font.HasCharacter('☻', true, true);
				}
				catch
				{
				}
				((TMP_Text)smiley).text = (flag ? "☻" : ":)");
				((TMP_Text)smiley).alignment = (TextAlignmentOptions)514;
				((TMP_Text)smiley).enableWordWrapping = false;
				((TMP_Text)smiley).enableAutoSizing = false;
				((TMP_Text)smiley).fontSize = 22f;
				((Graphic)smiley).raycastTarget = false;
				RectTransform rectTransform = ((TMP_Text)smiley).rectTransform;
				rectTransform.anchorMin = Vector2.zero;
				rectTransform.anchorMax = Vector2.one;
				rectTransform.offsetMin = new Vector2(-8f, -1f);
				rectTransform.offsetMax = new Vector2(8f, 7f);
				if (!flag)
				{
					((Transform)rectTransform).localEulerAngles = new Vector3(0f, 0f, -90f);
				}
			}
		}
	}
	internal sealed class TypeIn : MonoBehaviour
	{
		private TextMeshProUGUI text;

		private string allowed;

		private string typed = "";

		private Func<string> show;

		private Func<string, bool> commit;

		private bool editing;

		private bool fresh;

		private bool autoSized;

		public bool Editing => editing;

		public void Setup(TextMeshProUGUI t, string chars, Func<string> shown, Func<string, bool> typedIn)
		{
			text = t;
			allowed = chars;
			show = shown;
			commit = typedIn;
		}

		private bool Over()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Over(Vector2.op_Implicit(Input.mousePosition));
		}

		public bool Over(Vector2 screen)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)text == (Object)null || !((Behaviour)text).isActiveAndEnabled)
			{
				return false;
			}
			Canvas canvas = ((Graphic)text).canvas;
			Camera val = (((Object)(object)canvas != (Object)null && (int)canvas.renderMode != 0) ? canvas.worldCamera : null);
			RectTransform rectTransform = ((TMP_Text)text).rectTransform;
			Vector2 val2 = default(Vector2);
			if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, screen, val, ref val2))
			{
				return false;
			}
			Rect rect = rectTransform.rect;
			float num = Mathf.Max(((Rect)(ref rect)).width, ((TMP_Text)text).preferredWidth);
			if (!(val2.y >= ((Rect)(ref rect)).yMin - 6f) || !(val2.y <= ((Rect)(ref rect)).yMax + 6f) || !(val2.x >= ((Rect)(ref rect)).xMax - num - 10f) || !(val2.x <= ((Rect)(ref rect)).xMax + 10f))
			{
				return ((Rect)(ref rect)).Contains(val2);
			}
			return true;
		}

		private void Update()
		{
			if ((Object)(object)this.text == (Object)null || !((Behaviour)this.text).isActiveAndEnabled || !Plugin.On.Value)
			{
				if (editing)
				{
					Finish(keep: false);
				}
				return;
			}
			bool mouseButtonDown = Input.GetMouseButtonDown(0);
			if (!editing)
			{
				if (mouseButtonDown && Over())
				{
					editing = true;
					fresh = true;
					typed = "";
					HoldSize();
					Draw();
				}
				return;
			}
			if (mouseButtonDown && !Over())
			{
				Finish(keep: true);
				return;
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				Finish(keep: false);
				return;
			}
			string inputString = Input.inputString;
			if (inputString.Length == 0)
			{
				return;
			}
			string text = inputString;
			for (int i = 0; i < text.Length; i++)
			{
				char c = text[i];
				if (fresh && c != '\n' && c != '\r')
				{
					fresh = false;
					typed = "";
				}
				switch (c)
				{
				case '\b':
					if (typed.Length > 0)
					{
						typed = typed.Substring(0, typed.Length - 1);
					}
					continue;
				case '\n':
				case '\r':
					Finish(keep: true);
					return;
				case ',':
					if (allowed.IndexOf('.') >= 0 && typed.IndexOf('.') < 0)
					{
						typed += ".";
						continue;
					}
					break;
				}
				if (allowed.IndexOf(c) >= 0 && typed.Length < 7 && (c != '.' || typed.IndexOf('.') < 0))
				{
					typed += c;
				}
			}
			Draw();
		}

		private void Draw()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			string text = "<mark=#" + ColorUtility.ToHtmlStringRGB(((Graphic)this.text).color) + "40>";
			((TMP_Text)this.text).text = (fresh ? (text + show() + "</mark>") : (text + "<u>" + ((typed.Length > 0) ? typed : "\u00a0") + "</u></mark>"));
		}

		private void HoldSize()
		{
			if (((TMP_Text)text).enableAutoSizing)
			{
				float fontSize = ((TMP_Text)text).fontSize;
				((TMP_Text)text).enableAutoSizing = false;
				((TMP_Text)text).fontSize = fontSize;
				autoSized = true;
			}
		}

		private void Finish(bool keep)
		{
			editing = false;
			if (keep && !fresh && typed.Length > 0)
			{
				commit(typed);
			}
			fresh = false;
			if (autoSized)
			{
				autoSized = false;
				((TMP_Text)text).enableAutoSizing = true;
			}
			((TMP_Text)text).text = show();
		}

		private void OnDisable()
		{
			if (editing)
			{
				Finish(keep: false);
			}
		}
	}
}
namespace EzCrosshair
{
	internal static class Images
	{
		public static string Get(string name)
		{
			return name switch
			{
				"brackets" => "iVBORw0KGgoAAAANSUhEUgAAACAAAAAWCAYAAAChWZ5EAAAC/ElEQVR4nLWWT0gUYRjGfzO7C1ObNSGJ0KGFDIz8R1fbDkmwtBl0EUWCBVEPeti7UHvZ+wZKRkiCRRp0qG1gICyoDhIEq6symeKIBQNabZAx4Z/tsN+us+um4toDw8x88/H8nnn5vpkXsnIh4UHiEOXxeCTAnT+IhGubIzvgsE5ajJ84jABerzcLcueCrJPGI5ggkniQBFwKhUI1DQ0NfiA5PDz8LpFIlBSitr7W3X6r/TJwPjmZfPt45PEMsJVlyoDMOhKZakj+Jn9Xa6j1Tll5WcvZc2dPlkQHesI9x9Vy9WZrqPW2/4q/SwznmLJzcjQWbQs2B1uAilLBWekv9OxlRaA50BKNRducz/MCNAWaLgn4G2BMi2s/Sg4Q178DT4VnhWDsDBCNRRuBRgAtro31dPbMlArPKtwZntHj+lNx2yhYQGZlbgFHVUWtrzxWWWNMG4vLS8tz9ob9UwTccpopbsW1G8zesDfz7rFlIGV9tT6Zhrno8/lqVEWtBz4Cv3MVCF4PNpDZFUuAecCX3U2m8JYECyhYA9mJkUhkT7fYYKzX+GIYhmUYsQex3r3mC0+zcLxYgCVx7KrA9UAvUAVUBZoDewb4l6+7yMT9SRFn+8AOQPEKnBHHrtKf6/3APDCvv9T798Eq6lusAr5IJMJe6yDcEe6ng/2Agdwa8BWO5yqgvdQSQFqk3DHxEOQT3mnBAjIVkAE7ZacmrV/WdHVN9YWFxYWLilv5AGBv2GtOl8J9vg8dATh1+tRFX7XvjLVqzaTs1BTwB3AhAsiAPGFM3LNS1qaVsvShkaE6RVG8B3pXp9x4Bx4O1Jmrpm6umpsTxsSgALsAV94iHNfH3wMLwFWgO9gcLJkvPLqF54Jg5JQXoC/c90SLa69Kpjp07ca13LUW1171hfueOJ9n/gWOhuT1+Ov7K99WZoGpuc9za5SowbuDf9pD7c9GH43OJhPJt2T+LWkyn33RgbmQUPL6wUNpyVRVldlux3Jb3uPySFDYf/6/prRQefC/qb//SibWbnQAAAAASUVORK5CYII=", 
				"chunky plus" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAPUlEQVR4nMXOOwoAIAwE0Vnvf+e18IMhKFppFcjwomwDIKkN+ck2ZbPMNRCk5UII38UhpaDLn/84sVNzLVbxsxQK66rOnQAAAABJRU5ErkJggg==", 
				"circle" => "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAABhWlDQ1BJQ0MgUHJvZmlsZQAAeJx9kT1Iw0AcxV9TtaIVBTuIOmSoThZERRylikWwUNoKrTqYXPohNGlIUlwcBdeCgx+LVQcXZ10dXAVB8APEydFJ0UVK/F9SaBHjwXE/3t173L0DhFqJqWbbOKBqlpGMRcVMdkUMvKIbfejAEESJmXo8tZCG5/i6h4+vdxGe5X3uz9Gj5EwG+ETiWaYbFvE68fSmpXPeJw6xoqQQnxOPGXRB4keuyy6/cS44LPDMkJFOzhGHiMVCC8stzIqGSjxFHFZUjfKFjMsK5y3OaqnCGvfkLwzmtOUU12kOI4ZFxJGACBkVbKAECxFaNVJMJGk/6uEfdPwJcsnk2gAjxzzKUCE5fvA/+N2tmZ+ccJOCUaD9xbY/RoDALlCv2vb3sW3XTwD/M3ClNf3lGjDzSXq1qYWPgN5t4OK6qcl7wOUOMPCkS4bkSH6aQj4PvJ/RN2WB/luga9XtrbGP0wcgTV0t3QAHh8BogbLXPN7d2drbv2ca/f0AcCJypllzgSYAAABaSURBVHichY/RCcAgDESfDuMqQpw1ncCZLLhA+tEobSj0wUG4HCEHNwVQYLoO9/ZyABY0VkgBq7XaQkRWSPGTFvHAzPyQgQ7QWtvmY+4AJaV0xifdezX5rHkBA+Q5eLIiGpIAAAAASUVORK5CYII=", 
				"cross" => "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVR4nGP8//8/AxYAE2REl2DCphofoL0GFhziGG5H1oDua3TFKPJkOQmn9dhsxGXDf3SnkO0k2msAAAv8CBv+J3ZPAAAAAElFTkSuQmCC", 
				"dark diamond" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAABhGlDQ1BJQ0MgUHJvZmlsZQAAeJx9kT1Iw0AcxV9TRSkVBwuKOGRonexiRRxLFYtgobQVWnUwufQLmjQkKS6OgmvBwY/FqoOLs64OroIg+AHi6uKk6CIl/i8ptIjx4Lgf7+497t4BQqvGVLMvDqiaZWSSCTFfWBUHXhFAEKOIICYxU09lF3PwHF/38PH1LsqzvM/9OYaUoskAn0gcZ7phEW8Qz25aOud94hCrSArxOfGUQRckfuS67PIb57LDAs8MGbnMPHGIWCz3sNzDrGKoxDPEYUXVKF/Iu6xw3uKs1hqsc0/+wmBRW8lyneYEklhCCmmIkNFAFTVYiNKqkWIiQ/sJD/+440+TSyZXFYwcC6hDheT4wf/gd7dmKTbtJgUTQP+LbX9EgIFdoN207e9j226fAP5n4Err+ustYO6T9GZXCx8Bw9vAxXVXk/eAyx1g7EmXDMmR/DSFUgl4P6NvKgAjt0Bgze2ts4/TByBHXS3fAAeHwGSZstc93j3Y29u/Zzr9/QAHc3LiC+VReAAAAJNJREFUeJyNkDsOAjEMRMdQI9hF3jsgcQMQNbegpsqF01CCQpcWPQoShLIpGMmN5/lr+hGwkrSXlCXdzeyhVsAABCCVCMCmB52B6O7Z3TMQgQuwrpCX6ghkSXzSVDgAk4ATkNz9C9UonRNwWEh6zRaeaylg+mP0UPccgWvnmCPg7eVj5z3b6lsDu6RdefjNzJ7VewNyVrX/e0ljMwAAAABJRU5ErkJggg==", 
				"diamond" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAcklEQVR4nJWQywnEMAxEX1KH+9hCUohRGSlt+8hpzgYfjFEuMqxDWJIBgdA89FuYlYBP5F/gmFx3H1AGakQGUnhTpx1okoqkArSopV8oA83MuofMrAecB7wBVVLxi6JzBbaVF3o8+vExf98zmOVmjduHn8G4YXw9M5RzAAAAAElFTkSuQmCC", 
				"dot" => "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAZklEQVR4nIXPwQnDQAxE0bfuIBe3YNy4dotwMc41GFyCcogCJiHkg0CMhmHUMhO01mbcvDjxyEzKsGLgqBmYy2zGiIg9i4jYr6YFR35QScvkD1MV2nrv97dY+1Y3v0qu0C5pX2/CE/ZiPhIntsABAAAAAElFTkSuQmCC", 
				"outlined plus" => "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAVklEQVR4nN2SMQ7AMAgDz1X//2V3qLqkOKXKFm8IdIITIsdDrWromACwjT1yfgA62QBw8radUs4J8JfpFEnrJ4jJCc9mUvlDwO0gddc/sZMNAFlvU+IFejsTGMmz0YEAAAAASUVORK5CYII=", 
				"pinhole" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAbklEQVR4nJWQUQ3DMAwFT9NQhEB4mI0RpBCKJSD82IyG+5NMnaK22knvy6cn27BSRm5pQI60W8nM0swu5Qaku6eklJTuvshlNknKiaRzc3k9LT15Ax9gi4i91vod9N6JCIBtOP8d8yM/SefjlocfG0M/Yk1SZxgAAAAASUVORK5CYII=", 
				"plus" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAK0lEQVR4nGP8//8/AxqACTAiCzKhq8IFqK+QhQHhJnSAIk6SiYxoYoPN1wC5RgcU0AuUbwAAAABJRU5ErkJggg==", 
				"square" => "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAFklEQVR4nGP8////fwYkwMSABggLAAAGXQQE3kxYjAAAAABJRU5ErkJggg==", 
				"star" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAUklEQVR4nI2QUQrAMAxCdWfs7tjC7vj204yRpaNCQFRQYkAJIfgtHinUFnw/KEBAAzpf9OnJFCMr5OrfoCWdkkbhj+k5Nsb1tO/xcvW14PLuw29t+lWwzaChlAAAAABJRU5ErkJggg==", 
				_ => null, 
			};
		}
	}
	[BepInPlugin("dorsth.straftat.ezcrosshair", "ezCrosshair", "1.2.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class EzCrosshairPlugin : BaseUnityPlugin
	{
		public const string Guid = "dorsth.straftat.ezcrosshair";

		public const string Name = "ezCrosshair";

		public const string Version = "1.2.3";

		internal const string ModMenuGuid = "kestrel.straftat.modmenu";

		internal static readonly string[] Names = new string[12]
		{
			"dot", "square", "circle", "diamond", "dark diamond", "pinhole", "plus", "outlined plus", "chunky plus", "cross",
			"star", "brackets"
		};

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> On;

		internal static ConfigEntry<string> Pick;

		internal static ConfigEntry<Color> Tint;

		internal static ConfigEntry<bool> HitOn;

		internal static ConfigEntry<Color> HitTint;

		internal static ConfigEntry<float> Scale;

		internal static ConfigEntry<bool> ShowScoped;

		internal static ConfigEntry<KeyCode> MenuKey;

		internal static ConfigEntry<string> MenuSpot;

		private static bool _hidGame;

		private void Awake()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00c8: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogMessage((object)"Dorsth was here");
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			On = ((BaseUnityPlugin)this).Config.Bind<bool>("Crosshair", "Enabled", true, "Shows your crosshair instead of the game's.");
			Custom.Read(((BaseUnityPlugin)this).Config);
			Pick = ((BaseUnityPlugin)this).Config.Bind<string>("Crosshair", "Crosshair", (Array.IndexOf(Custom.All, Names[0]) >= 0) ? Names[0] : Custom.All[0], new ConfigDescription("Which crosshair: every PNG in " + Custom.Folder + ". Add your own there.", (AcceptableValueBase)(object)new AcceptableValueList<string>(Custom.All), Array.Empty<object>()));
			Tint = ((BaseUnityPlugin)this).Config.Bind<Color>("Crosshair", "Color", Color.white, "Color of the crosshair. White keeps its own colors; the dark outline stays dark.");
			HitOn = ((BaseUnityPlugin)this).Config.Bind<bool>("Crosshair", "Hit Color", false, "The crosshair turns the hit color for a moment when you hit someone.");
			HitTint = ((BaseUnityPlugin)this).Config.Bind<Color>("Crosshair", "Hit Color Value", new Color(1f, 0.25f, 0.25f, 1f), "The color the crosshair turns when you hit someone.");
			Scale = ((BaseUnityPlugin)this).Config.Bind<float>("Crosshair", "Scale", 1f, new ConfigDescription("Size of the crosshair: 1 is its own size on a 1080p screen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			ShowScoped = ((BaseUnityPlugin)this).Config.Bind<bool>("Crosshair", "Show While Scoped", false, "Keeps the crosshair on while you look through a scope.");
			MenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Menu", (KeyCode)283, "Opens the crosshair menu.");
			MenuSpot = ((BaseUnityPlugin)this).Config.Bind<string>("Keys", "Menu Window", "0,0", "Where the menu window is, from the middle of the screen. Drag its top bar to move it, double-click the bar to center it.");
			try
			{
				new Harmony("dorsth.straftat.ezcrosshair").Patch((MethodBase)AccessTools.Method(typeof(Crosshair), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(EzCrosshairPlugin), "GameCrosshairPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Couldn't hide the game's crosshair: " + ex));
			}
			((BaseUnityPlugin)this).Config.SettingChanged += delegate
			{
				Overlay.Dirty = true;
			};
			((Component)this).gameObject.AddComponent<Overlay>();
		}

		private static void GameCrosshairPostfix(Crosshair __instance)
		{
			Image image = __instance.image;
			if ((Object)(object)image == (Object)null)
			{
				return;
			}
			CanvasRenderer canvasRenderer = ((Graphic)image).canvasRenderer;
			if (On.Value)
			{
				_hidGame = true;
				if (canvasRenderer.GetAlpha() != 0f)
				{
					canvasRenderer.SetAlpha(0f);
				}
			}
			else if (_hidGame)
			{
				_hidGame = false;
				if (canvasRenderer.GetAlpha() == 0f)
				{
					canvasRenderer.SetAlpha(1f);
				}
			}
		}
	}
	internal static class Custom
	{
		internal const int Largest = 256;

		internal static readonly Dictionary<string, string> Files = new Dictionary<string, string>();

		internal static string[] All = EzCrosshairPlugin.Names;

		internal static string Folder => Path.Combine(Paths.PluginPath, "MONOLITH", "Crosshairs");

		internal static void Read(ConfigFile config)
		{
			try
			{
				Directory.CreateDirectory(Folder);
				ConfigEntry<bool> val = config.Bind<bool>("Internal", "Crosshair Files Written", false, "Set once the crosshairs that come with MONOLITH have been written to its Crosshairs folder.");
				string[] names;
				if (!val.Value)
				{
					names = EzCrosshairPlugin.Names;
					foreach (string text in names)
					{
						string path = Path.Combine(Folder, text + ".png");
						if (!File.Exists(path))
						{
							File.WriteAllBytes(path, Convert.FromBase64String(Images.Get(text)));
						}
					}
					val.Value = true;
				}
				string[] files = Directory.GetFiles(Folder, "*.png");
				Array.Sort(files, (IComparer<string>?)StringComparer.OrdinalIgnoreCase);
				names = files;
				foreach (string text2 in names)
				{
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text2);
					if (fileNameWithoutExtension.Length > 0)
					{
						Files[fileNameWithoutExtension] = text2;
					}
				}
				List<string> list = new List<string>();
				names = EzCrosshairPlugin.Names;
				foreach (string text3 in names)
				{
					if (Files.ContainsKey(text3))
					{
						list.Add(text3);
					}
				}
				int num = 0;
				names = files;
				for (int i = 0; i < names.Length; i++)
				{
					string fileNameWithoutExtension2 = Path.GetFileNameWithoutExtension(names[i]);
					if (fileNameWithoutExtension2.Length > 0 && !list.Contains(fileNameWithoutExtension2))
					{
						list.Add(fileNameWithoutExtension2);
						num++;
					}
				}
				if (list.Count > 0)
				{
					All = list.ToArray();
				}
				EzCrosshairPlugin.Log.LogInfo((object)(list.Count + " crosshairs in " + Folder + ((num > 0) ? (" (" + num + " of your own).") : ".")));
			}
			catch (Exception ex)
			{
				EzCrosshairPlugin.Log.LogWarning((object)("The crosshair folder was not read, the built-in ones are used: " + ex.Message));
			}
		}
	}
	internal static class Pictures
	{
		private static readonly Dictionary<string, Texture2D> Loaded = new Dictionary<string, Texture2D>();

		public static Texture2D Get(string name)
		{
			//IL_0030: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_00e9: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			if (Loaded.TryGetValue(name, out var value))
			{
				return value;
			}
			value = null;
			try
			{
				string text = Images.Get(name);
				if (Custom.Files.TryGetValue(name, out var value2))
				{
					value = new Texture2D(2, 2, (TextureFormat)4, false)
					{
						wrapMode = (TextureWrapMode)1,
						name = "ezCrosshair " + name
					};
					if (!ImageConversion.LoadImage(value, File.ReadAllBytes(value2)) || ((Texture)value).width > 256 || ((Texture)value).height > 256)
					{
						EzCrosshairPlugin.Log.LogWarning((object)("Crosshair " + name + " not used: not a picture this can read, or larger than " + 256 + " pixels."));
						Object.Destroy((Object)(object)value);
						value = null;
					}
					else
					{
						((Texture)value).filterMode = (FilterMode)0;
						Object.DontDestroyOnLoad((Object)(object)value);
					}
					Loaded[name] = value;
					return value;
				}
				if (text != null)
				{
					value = new Texture2D(2, 2, (TextureFormat)4, false)
					{
						wrapMode = (TextureWrapMode)1,
						name = "ezCrosshair " + name
					};
					if (!ImageConversion.LoadImage(value, Convert.FromBase64String(text)))
					{
						Object.Destroy((Object)(object)value);
						value = null;
					}
					else
					{
						((Texture)value).filterMode = (FilterMode)0;
						Object.DontDestroyOnLoad((Object)(object)value);
					}
				}
				else
				{
					EzCrosshairPlugin.Log.LogWarning((object)("No crosshair called " + name));
				}
			}
			catch (Exception ex)
			{
				EzCrosshairPlugin.Log.LogError((object)("Couldn't load crosshair " + name + ": " + ex.Message));
			}
			Loaded[name] = value;
			return value;
		}
	}
	internal sealed class Overlay : MonoBehaviour
	{
		private GameObject _root;

		private Canvas _canvas;

		private RawImage _image;

		private string _shown;

		private float _scale = -1f;

		private int _screenW;

		private int _screenH;

		internal static bool Dirty = true;

		private bool _showing;

		private bool _flash;

		private int _tick;

		private static bool _sceneHooked;

		private static bool _mainMenu;

		private void Make()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_00aa: 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)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			_root = new GameObject("ezCrosshair");
			Object.DontDestroyOnLoad((Object)(object)_root);
			_canvas = _root.AddComponent<Canvas>();
			_canvas.renderMode = (RenderMode)0;
			_canvas.pixelPerfect = true;
			_canvas.sortingOrder = 1;
			GameObject val = new GameObject("Crosshair", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(_root.transform, false);
			_image = val.AddComponent<RawImage>();
			((Graphic)_image).raycastTarget = false;
			RectTransform rectTransform = ((Graphic)_image).rectTransform;
			Vector2 anchorMin = (rectTransform.anchorMax = Vector2.zero);
			rectTransform.anchorMin = anchorMin;
			rectTransform.pivot = Vector2.zero;
			((Behaviour)_image).enabled = false;
			_shown = null;
		}

		private void LateUpdate()
		{
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_014f: 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)
			//IL_0163: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			Hits.Watch();
			bool flag = ShouldShow();
			if ((Object)(object)_image == (Object)null)
			{
				if (!flag)
				{
					return;
				}
				Make();
				_showing = false;
			}
			if (flag != _showing)
			{
				_showing = flag;
				((Behaviour)_image).enabled = flag;
				if (flag)
				{
					Dirty = true;
				}
			}
			if (!flag)
			{
				return;
			}
			bool flag2 = Hits.Flashing();
			if (flag2 != _flash)
			{
				_flash = flag2;
				Dirty = true;
			}
			if ((++_tick & 0xF) == 0)
			{
				Dirty = true;
			}
			if (!Dirty)
			{
				return;
			}
			Dirty = false;
			Canvas canvas = ((Graphic)Crosshair.Instance.image).canvas;
			int num = (((Object)(object)canvas != (Object)null) ? canvas.rootCanvas.sortingOrder : 0);
			if (_canvas.sortingOrder != num)
			{
				_canvas.sortingOrder = num;
			}
			Texture2D val = Pictures.Get(EzCrosshairPlugin.Pick.Value);
			if ((Object)(object)val == (Object)null)
			{
				((Behaviour)_image).enabled = false;
				_showing = false;
				return;
			}
			if ((Object)(object)_image.texture != (Object)(object)val)
			{
				_image.texture = (Texture)(object)val;
			}
			Color val2 = (flag2 ? EzCrosshairPlugin.HitTint.Value : EzCrosshairPlugin.Tint.Value);
			if (((Graphic)_image).color != val2)
			{
				((Graphic)_image).color = val2;
			}
			float num2 = Mathf.Clamp(EzCrosshairPlugin.Scale.Value, 0f, 2f);
			if (_shown != EzCrosshairPlugin.Pick.Value || num2 != _scale || Screen.width != _screenW || Screen.height != _screenH)
			{
				_shown = EzCrosshairPlugin.Pick.Value;
				_scale = num2;
				_screenW = Screen.width;
				_screenH = Screen.height;
				Vector2Int val3 = ScreenSize(val, num2);
				int x = ((Vector2Int)(ref val3)).x;
				int y = ((Vector2Int)(ref val3)).y;
				RectTransform rectTransform = ((Graphic)_image).rectTransform;
				float num3 = ((_canvas.scaleFactor > 0f) ? _canvas.scaleFactor : 1f);
				rectTransform.sizeDelta = new Vector2((float)x, (float)y) / num3;
				rectTransform.anchoredPosition = new Vector2(Mathf.Floor((float)(Screen.width - x) / 2f), Mathf.Floor((float)(Screen.height - y) / 2f)) / num3;
			}
		}

		public static Vector2Int ScreenSize(Texture2D tex, float scale)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			float num = scale * (float)Screen.height / 1080f;
			return new Vector2Int(Mathf.RoundToInt((float)((Texture)tex).width * num), Mathf.RoundToInt((float)((Texture)tex).height * num));
		}

		private static bool ShouldShow()
		{
			return WhyHidden() == null;
		}

		private static string WhyHidden()
		{
			if (!EzCrosshairPlugin.On.Value)
			{
				return "turned off";
			}
			Crosshair instance = Crosshair.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.image == (Object)null)
			{
				return "no game crosshair yet";
			}
			if (!((Behaviour)instance).isActiveAndEnabled)
			{
				return "the game's crosshair is switched off";
			}
			if ((Object)(object)instance.player == (Object)null)
			{
				return "no player";
			}
			if ((Object)(object)((Graphic)instance.image).canvas == (Object)null || !((Behaviour)((Graphic)instance.image).canvas).isActiveAndEnabled)
			{
				return "the game's HUD is switched off";
			}
			if (InMainMenu())
			{
				return "main menu";
			}
			if ((Object)(object)Camera.main != (Object)null)
			{
				return "dead or watching";
			}
			if (instance.canScopeAim && (Object)(object)instance.aimCrosshair != (Object)null && instance.player.isAiming && (Object)(object)instance.image.sprite == (Object)(object)instance.invisibleCrosshair && !EzCrosshairPlugin.ShowScoped.Value)
			{
				return "scoped";
			}
			return null;
		}

		public static bool InMainMenu()
		{
			//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)
			if (!_sceneHooked)
			{
				_sceneHooked = true;
				Scene activeScene = SceneManager.GetActiveScene();
				_mainMenu = ((Scene)(ref activeScene)).name == "MainMenu";
				SceneManager.activeSceneChanged += delegate(Scene from, Scene to)
				{
					_mainMenu = ((Scene)(ref to)).name == "MainMenu";
				};
			}
			return _mainMenu;
		}
	}
	internal static class Hits
	{
		private static readonly Type[] Holders = new Type[4]
		{
			typeof(Weapon),
			typeof(PredictedProjectile),
			typeof(ProximityMine),
			typeof(ShrapnelBallistic)
		};

		private const float Flash = 0.2f;

		private static float _until = -1f;

		private static readonly HashSet<string> MarkerNames = new HashSet<string>();

		private static readonly HashSet<string> NotMarkers = new HashSet<string>();

		private static bool _hooked;

		private static float _namesAt = -100f;

		private static int _lastId;

		private static void ReadNames()
		{
			Type[] holders = Holders;
			foreach (Type type in holders)
			{
				FieldInfo field = type.GetField("hitMarker", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field == null)
				{
					continue;
				}
				Object[] array = Resources.FindObjectsOfTypeAll(type);
				foreach (Object val in array)
				{
					GameObject val2 = (GameObject)((val != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
					if ((Object)(object)val2 != (Object)null)
					{
						MarkerNames.Add(((Object)val2).name + "(Clone)");
					}
				}
			}
		}

		public static bool Flashing()
		{
			if (EzCrosshairPlugin.HitOn.Value)
			{
				return Time.unscaledTime < _until;
			}
			return false;
		}

		public static void Watch()
		{
			if (!EzCrosshairPlugin.HitOn.Value)
			{
				return;
			}
			try
			{
				PauseManager instance = PauseManager.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					return;
				}
				Transform transform = ((Component)instance).transform;
				int childCount = transform.childCount;
				if (childCount == 0)
				{
					return;
				}
				Transform child = transform.GetChild(childCount - 1);
				int instanceID = ((Object)child).GetInstanceID();
				if (instanceID == _lastId)
				{
					return;
				}
				_lastId = instanceID;
				string name = ((Object)child).name;
				if (!name.EndsWith("(Clone)", StringComparison.Ordinal))
				{
					return;
				}
				if (!_hooked)
				{
					_hooked = true;
					SceneManager.sceneLoaded += delegate
					{
						NotMarkers.Clear();
					};
				}
				if (!MarkerNames.Contains(name))
				{
					if (NotMarkers.Contains(name) || Time.unscaledTime - _namesAt <= 0.5f)
					{
						return;
					}
					_namesAt = Time.unscaledTime;
					ReadNames();
					if (!MarkerNames.Contains(name))
					{
						NotMarkers.Add(name);
						return;
					}
				}
				_until = Time.unscaledTime + 0.2f;
			}
			catch
			{
			}
		}
	}
}
namespace CameraTweaks
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("dorsth.straftat.cameratweaks", "CameraTweaks", "1.1.7")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "dorsth.straftat.cameratweaks";

		public const string Name = "CameraTweaks";

		public const string Version = "1.1.7";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> NoTilt;

		internal static ConfigEntry<bool> NoFallShake;

		internal static ConfigEntry<bool> NoJumpShake;

		internal static ConfigEntry<bool> NoVaultShake;

		internal static ConfigEntry<bool> BetterRecoil;

		private void Awake()
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			SceneManager.sceneLoaded += delegate
			{
				Recoil.Forget();
			};
			NoTilt = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "NoTilt", true, "On: the camera stops rolling to the side when you strafe, slide, slide along a wall or move your mouse sideways.");
			NoFallShake = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "NoFallShake", true, "On: no camera shake or dip when you land.");
			NoJumpShake = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "NoJumpShake", true, "On: no camera shake when you jump out of a slide, wall jump or hit a ceiling.");
			NoVaultShake = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "NoVaultShake", false, "On: no camera shake when you vault over something.");
			BetterRecoil = ((BaseUnityPlugin)this).Config.Bind<bool>("Camera", "BetterRecoil", true, "On: the AR, AK and warden kick your aim instead of the camera. When you let go it comes back down by the kick you didn't pull down yourself, so taps and bursts come back to where you aimed and a pulled down spray doesn't swing below it.");
			Harmony val = new Harmony("dorsth.straftat.cameratweaks");
			Shakes.Patch(val);
			try
			{
				val.Patch((MethodBase)AccessTools.Method(typeof(FirstPersonController), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(SpeedFov), "Started", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("The sprint and slide FOV could not be switched off (game update?): " + ex.Message));
			}
			val.Patch((MethodBase)AccessTools.Method(typeof(FirstPersonController), "HandleCameraController", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Roll), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			string[] array = new string[2] { "CameraRevolverAnimation", "AltCameraRevolverAnimation" };
			foreach (string text in array)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(Weapon), text, (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					val.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Recoil), "Prefix", (Type[])null)
					{
						priority = 0
					}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CameraTweaks 1.1.7 loaded. Dorsth was here.");
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
		}

		private void Update()
		{
			Recoil.Tick();
		}
	}
	internal static class SpeedFov
	{
		private static FieldRef<FirstPersonController, float> Run;

		private static FieldRef<FirstPersonController, float> Slide;

		private static FieldRef<FirstPersonController, float> RunSlide;

		private static bool failed;

		internal static void Started(FirstPersonController __instance)
		{
			if (failed || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			try
			{
				if (Run == null)
				{
					Run = AccessTools.FieldRefAccess<FirstPersonController, float>("distToRunFov");
					Slide = AccessTools.FieldRefAccess<FirstPersonController, float>("distToSlideFov");
					RunSlide = AccessTools.FieldRefAccess<FirstPersonController, float>("distToRunSlideFov");
				}
				Run.Invoke(__instance) = 0f;
				Slide.Invoke(__instance) = 0f;
				RunSlide.Invoke(__instance) = 0f;
			}
			catch (Exception ex)
			{
				failed = true;
				Plugin.Log.LogWarning((object)("The sprint and slide FOV could not be switched off (game update?): " + ex.Message));
			}
		}
	}
	internal static class Roll
	{
		private static readonly FieldRef<FirstPersonController, float> Tilt = AccessTools.FieldRefAccess<FirstPersonController, float>("tiltAmount");

		private static readonly FieldRef<FirstPersonController, float> SlideTilt = AccessTools.FieldRefAccess<FirstPersonController, float>("slideTiltAmount");

		private static readonly FieldRef<FirstPersonController, float> Mouse = AccessTools.FieldRefAccess<FirstPersonController, float>("rotationAmount");

		private static bool known;

		private static float tilt;

		private static float slideTilt;

		private static float mouse;

		public static void Prefix(FirstPersonController __instance)
		{
			if (((NetworkBehaviour)__instance).IsOwner)
			{
				if (!known)
				{
					known = true;
					tilt = Tilt.Invoke(__instance);
					slideTilt = SlideTilt.Invoke(__instance);
					mouse = Mouse.Invoke(__instance);
				}
				Tilt.Invoke(__instance) = ((!Plugin.NoTilt.Value) ? tilt : 0f);
				SlideTilt.Invoke(__instance) = ((!Plugin.NoTilt.Value) ? slideTilt : 0f);
				Mouse.Invoke(__instance) = ((!Plugin.NoTilt.Value) ? mouse : 0f);
				if (Plugin.NoTilt.Value)
				{
					__instance.wallSlideLean = 0f;
				}
			}
		}
	}
	internal static class Shakes
	{
		private static readonly MethodInfo Punch = AccessTools.Method(typeof(ShortcutExtensions), "DOPunchRotation", new Type[5]
		{
			typeof(Transform),
			typeof(Vector3),
			typeof(float),
			typeof(int),
			typeof(float)
		}, (Type[])null);

		private static readonly MethodInfo LocalRotate = AccessTools.Method(typeof(ShortcutExtensions), "DOLocalRotate", new Type[4]
		{
			typeof(Transform),
			typeof(Vector3),
			typeof(float),
			typeof(RotateMode)
		}, (Type[])null);

		private static readonly Dictionary<string, string[]> Punches = new Dictionary<string, string[]>
		{
			{
				"OnControllerColliderHit",
				new string[2] { "CeilingHit", "CeilingHit" }
			},
			{
				"Jump",
				new string[4] { "WallJump", "JumpSlope", "JumpSlope", "JumpSlope" }
			},
			{
				"ApplyFinalMovements",
				new string[2] { "JumpSlope", "FallShake" }
			},
			{
				"CheckForVault",
				new string[1] { "Vault" }
			}
		};

		public static void Patch(Harmony h)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			HarmonyMethod val = new HarmonyMethod(typeof(Shakes), "Transpiler", (Type[])null);
			foreach (string key in Punches.Keys)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(FirstPersonController), key, (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					Plugin.Log.LogWarning((object)(key + " not found, its camera shake stays"));
				}
				else
				{
					h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod)
		{
			List<CodeInstruction> list = instructions.ToList();
			string name = __originalMethod.Name;
			string[] array = Punches[name];
			List<CodeInstruction> list2 = list.Where((CodeInstruction c) => CodeInstructionExtensions.Calls(c, Punch)).ToList();
			if (list2.Count != array.Length)
			{
				Plugin.Log.LogWarning((object)(name + ": " + list2.Count + " camera shakes where " + array.Length + " were expected, left as they are"));
				return list;
			}
			for (int num = 0; num < list2.Count; num++)
			{
				list2[num].opcode = OpCodes.Call;
				list2[num].operand = AccessTools.Method(typeof(Shakes), array[num], (Type[])null, (Type[])null);
			}
			if (name == "ApplyFinalMovements")
			{
				List<CodeInstruction> list3 = list.Where((CodeInstruction c) => CodeInstructionExtensions.Calls(c, LocalRotate)).ToList();
				if (list3.Count == 1)
				{
					list3[0].opcode = OpCodes.Call;
					list3[0].operand = AccessTools.Method(typeof(Shakes), "HighFall", (Type[])null, (Type[])null);
				}
				else
				{
					Plugin.Log.LogWarning((object)"ApplyFinalMovements: the high fall dip wasn't where it was expected, left as it is");
				}
			}
			return list;
		}

		private static Tweener Gate(bool on, Transform t, Vector3 p, float d, int v, float e)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!on)
			{
				return null;
			}
			return ShortcutExtensions.DOPunchRotation(t, p, d, v, e);
		}

		public static Tweener CeilingHit(Transform t, Vector3 p, float d, int v, float e)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return Gate(!Plugin.NoJumpShake.Value, t, p, d, v, e);
		}

		public static Tweener WallJump(Transform t, Vector3 p, float d, int v, float e)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return Gate(!Plugin.NoJumpShake.Value, t, p, d, v, e);
		}

		public static Tweener JumpSlope(Transform t, Vector3 p, float d, int v, float e)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return Gate(!Plugin.NoJumpShake.Value, t, p, d, v, e);
		}

		public static Tweener FallShake(Transform t, Vector3 p, float d, int v, float e)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return Gate(!Plugin.NoFallShake.Value, t, p, d, v, e);
		}

		public static Tweener Vault(Transform t, Vector3 p, float d, int v, float e)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return Gate(!Plugin.NoVaultShake.Value, t, p, d, v, e);
		}

		public static TweenerCore<Quaternion, Vector3, QuaternionOptions> HighFall(Transform t, Vector3 end, float d, RotateMode mode)
		{
			//IL_000f: 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)
			if (Plugin.NoFallShake.Value)
			{
				return null;
			}
			return ShortcutExtensions.DOLocalRotate(t, end, d, mode);
		}
	}
	internal static class Recoil
	{
		private static readonly FieldRef<Weapon, Vector3> Kick = AccessTools.FieldRefAccess<Weapon, Vector3>("recoil");

		private static FirstPersonController player;

		private static Weapon weapon;

		private static Vector2 left;

		private static Vector2 owed;

		private static float time = 0.1f;

		private static float lastPitch;

		private static float lastYaw;

		private static bool haveLast;

		internal static void Forget()
		{
			//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_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)
			player = null;
			weapon = null;
			left = (owed = Vector2.zero);
			haveLast = false;
		}

		public static bool Prefix(Weapon __instance, MethodBase __originalMethod, bool __runOriginal)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (!__runOriginal || !Plugin.BetterRecoil.Value || !__instance.akAnim || !Swings(__instance))
			{
				return true;
			}
			FirstPersonController playerController = __instance.playerController;
			if ((Object)(object)playerController == (Object)null || !((NetworkBehaviour)playerController).IsOwner)
			{
				return true;
			}
			Vector3 val = Kick.Invoke(__instance) * ((__originalMethod.Name == "AltCameraRevolverAnimation") ? 3f : 1f);
			if ((Object)(object)player != (Object)(object)playerController)
			{
				player = playerController;
				left = (owed = Vector2.zero);
				haveLast = false;
			}
			weapon = __instance;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0f - val.x, 0f - val.y);
			left += val2;
			owed += val2;
			time = Mathf.Max(0.01f, __instance.duration);
			return false;
		}

		private static bool Swings(Weapon w)
		{
			ItemBehaviour val = (((Object)(object)w.behaviour != (Object)null) ? w.behaviour : ((Component)w).GetComponent<ItemBehaviour>());
			switch (((Object)(object)val != (Object)null && val.weaponName != null) ? val.weaponName.Trim().ToLowerInvariant() : "")
			{
			case "ar":
			case "ak":
			case "warden":
				return true;
			default:
			{
				string name = ((Object)((Component)w).gameObject).name;
				if (!name.StartsWith("AR15", StringComparison.Ordinal) && !name.StartsWith("AK-K", StringComparison.Ordinal))
				{
					return name.StartsWith("Warden", StringComparison.Ordinal);
				}
				return true;
			}
			}
		}

		public static void Tick()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//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_0013: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: 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)
			if ((Object)(object)player == (Object)null)
			{
				left = (owed = Vector2.zero);
				haveLast = false;
				return;
			}
			float rotationX = player.rotationX;
			float y = ((Component)player).transform.eulerAngles.y;
			if (haveLast)
			{
				owed.x = Against(owed.x, rotationX - lastPitch);
				owed.y = Against(owed.y, Mathf.DeltaAngle(lastYaw, y));
			}
			Vector2 val = Vector2.zero;
			if (((Vector2)(ref left)).sqrMagnitude > 1E-08f)
			{
				float num = 1f - Mathf.Exp((0f - Time.deltaTime) * 3f / time);
				Vector2 val2 = left * num;
				left -= val2;
				val += val2;
			}
			else
			{
				left = Vector2.zero;
			}
			CameraShakeConstrains val3 = (((Object)(object)weapon != (Object)null) ? weapon.camAnimScript : null);
			if ((!((Object)(object)val3 != (Object)null) || val3.rotateBack) && ((Vector2)(ref owed)).sqrMagnitude > 1E-08f)
			{
				float num2 = (((Object)(object)val3 != (Object)null && val3.baseSpeed > 0f) ? val3.baseSpeed : 3f);
				Vector2 val4 = owed * Mathf.Min(1f, num2 * Time.deltaTime);
				owed -= val4;
				val -= val4;
			}
			else if (((Vector2)(ref owed)).sqrMagnitude <= 1E-08f)
			{
				owed = Vector2.zero;
			}
			if (((Vector2)(ref val)).sqrMagnitude > 1E-12f)
			{
				player.rotationX = Mathf.Clamp(player.rotationX + val.x, -90f, 90f);
				if (Mathf.Abs(val.y) > 1E-05f)
				{
					Transform transform = ((Component)player).transform;
					transform.rotation *= Quaternion.Euler(0f, val.y, 0f);
				}
			}
			lastPitch = player.rotationX;
			lastYaw = ((Component)player).transform.eulerAngles.y;
			haveLast = true;
		}

		private static float Against(float owed, float moved)
		{
			if (owed < 0f && moved > 0f)
			{
				return Mathf.Min(0f, owed + moved);
			}
			if (owed > 0f && moved < 0f)
			{
				return Mathf.Max(0f, owed + moved);
			}
			return owed;
		}
	}
}
namespace CombatSounds
{
	[BepInPlugin("dorsth.straftat.combatsounds", "CombatSounds", "1.1.4")]
	public sealed class CombatSoundsPlugin : BaseUnityPlugin
	{
		internal static bool Quiet;

		public const string Guid = "dorsth.straftat.combatsounds";

		public const string Name = "CombatSounds";

		public const string Version = "1.1.4";

		internal static ManualLogSource Log;

		internal static SoundSlot Hit;

		internal static SoundSlot HeadHit;

		internal static SoundSlot Kill;

		internal static SoundSlot MeleeKill;

		internal static ConfigEntry<int> GunVolume;

		private void Awake()
		{
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Expected O, but got Unknown
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogMessage((object)"Dorsth was here");
			SceneManager.sceneLoaded += delegate
			{
				GunSounds.Prune();
			};
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			if (string.Equals(Path.GetFullPath(directoryName).TrimEnd('\\', '/'), Path.GetFullPath(Paths.PluginPath).TrimEnd('\\', '/'), StringComparison.OrdinalIgnoreCase))
			{
				directoryName = Path.Combine(directoryName, "CombatSounds");
			}
			string directoryName2 = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			bool num = string.Equals(Path.GetFullPath(directoryName2).TrimEnd('\\', '/'), Path.GetFullPath(Paths.PluginPath).TrimEnd('\\', '/'), StringComparison.OrdinalIgnoreCase);
			string text = Path.Combine(Paths.PluginPath, "CombatSounds");
			string text2 = (num ? Path.Combine(directoryName2, Path.GetFileNameWithoutExtension(((BaseUnityPlugin)this).Info.Location)) : directoryName2);
			directoryName = text2;
			string[] array = new string[4]
			{
				text,
				text2,
				Path.Combine(Paths.PluginPath, "MONOLITH"),
				Path.Combine(Paths.PluginPath, "DorsthBundle")
			};
			foreach (string text3 in array)
			{
				if (Directory.Exists(Path.Combine(text3, "HitSounds")) && Directory.GetFiles(Path.Combine(text3, "HitSounds")).Length != 0)
				{
					directoryName = text3;
					break;
				}
			}
			Log.LogInfo((object)("Sounds from " + directoryName));
			string folder = Path.Combine(directoryName, "KillSounds");
			Hit = new SoundSlot(((BaseUnityPlugin)this).Config, SoundKind.Hit, "Hit Sound", Path.Combine(directoryName, "HitSounds"), "When you hit a player.");
			HeadHit = new SoundSlot(((BaseUnityPlugin)this).Config, SoundKind.HeadHit, "Head Hit Sound", Path.Combine(directoryName, "HeadHitSounds"), "When you hit a head.", Hit, "Same as Hit");
			Kill = new SoundSlot(((BaseUnityPlugin)this).Config, SoundKind.Kill, "Kill Sound", folder, "When you kill a player.");
			MeleeKill = new SoundSlot(((BaseUnityPlugin)this).Config, SoundKind.MeleeKill, "Melee Kill Sound", Path.Combine(directoryName, "MeleeKillSounds"), "When you kill with a melee weapon.", Kill, "Same as Kill");
			GunVolume = ((BaseUnityPlugin)this).Config.Bind<int>("Guns", "Gun Sound Volume", 100, new ConfigDescription("Shots, reloads, empty clicks and casings, yours and others'. 100 is normal.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			Harmony harmony = new Harmony("dorsth.straftat.combatsounds");
			try
			{
				Hooks.Install(harmony);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Couldn't hook the game's hit sounds, so the mod is off. (" + ex.Message + ")"));
			}
			try
			{
				GunSounds.Install(harmony);
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Couldn't hook the gun sounds, so Gun Sound Volume is off. (" + ex2.Message + ")"));
			}
		}
	}
	internal enum SoundKind
	{
		Hit,
		HeadHit,
		Kill,
		MeleeKill
	}
	internal sealed class SoundSlot
	{
		private const string Default = "Default";

		private const string None = "None";

		private static GameObject _speaker;

		private readonly ConfigEntry<string> _choice;

		private readonly ConfigEntry<int> _volume;

		private readonly Dictionary<string, string> _files = new Dictionary<string, string>();

		private readonly string _name;

		private readonly SoundKind _kind;

		private readonly SoundSlot _hit;

		private readonly string _same;

		private AudioSource _source;

		private AudioClip _clip;

		private AudioClip _louder;

		private AudioClip _louderOf;

		private string _sound;

		private bool _none;

		private bool _following;

		private int _loadId;

		private int _louderVolume;

		private float _nextPreview;

		private AudioClip _gameA;

		private AudioClip _gameB;

		private SoundSlot Pick
		{
			get
			{
				if (!_following)
				{
					return this;
				}
				return _hit.Pick;
			}
		}

		internal bool ReplacesGameSound
		{
			get
			{
				SoundSlot pick = Pick;
				if (!((Object)(object)pick._clip != (Object)null))
				{
					return pick._none;
				}
				return true;
			}
		}

		internal bool HasSound => (Object)(object)Pick._clip != (Object)null;

		internal SoundSlot(ConfigFile config, SoundKind kind, string name, string folder, string description, SoundSlot follows = null, string same = null)
		{
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			_kind = kind;
			_name = name;
			_hit = follows;
			_same = same;
			List<string> list = new List<string> { "Default", "None" };
			if (follows != null)
			{
				list.Add(same);
			}
			try
			{
				Directory.CreateDirectory(folder);
				string[] files = Directory.GetFiles(folder);
				Array.Sort(files, (IComparer<string>?)StringComparer.OrdinalIgnoreCase);
				string[] array = files;
				foreach (string text in array)
				{
					string text2 = Path.GetExtension(text).ToLowerInvariant();
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
					if ((!(text2 != ".wav") || !(text2 != ".ogg") || !(text2 != ".mp3")) && !list.Contains(fileNameWithoutExtension))
					{
						list.Add(fileNameWithoutExtension);
						_files[fileNameWithoutExtension] = text;
					}
				}
			}
			catch (Exception ex)
			{
				CombatSoundsPlugin.Log.LogWarning((object)("Couldn't read " + folder + ": " + ex.Message));
			}
			string text3 = (folder.StartsWith(Paths.GameRootPath, StringComparison.OrdinalIgnoreCase) ? folder.Substring(Paths.GameRootPath.Length).TrimStart('\\', '/') : folder);
			_choice = config.Bind<string>("Sounds", name, (follows != null) ? same : "Default", new ConfigDescription(description + " Default is the game's own. Add your own sounds in " + text3 + ".", (AcceptableValueBase)(object)new AcceptableValueList<string>(list.ToArray()), Array.Empty<object>()));
			_volume = config.Bind<int>("Sounds", name + " Volume", 100, new ConfigDescription("100 is normal, 200 is twice as loud.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>()));
			_choice.SettingChanged += delegate
			{
				Load(!CombatSoundsPlugin.Quiet);
			};
			_volume.SettingChanged += delegate
			{
				if (!CombatSoundsPlugin.Quiet && !(Time.unscaledTime < _nextPreview))
				{
					_nextPreview = Time.unscaledTime + 0.3f;
					Preview();
				}
			};
			Load(preview: false);
		}

		internal bool PlayGame(AudioSource audio, AudioClip clip)
		{
			int value = _volume.Value;
			if (value == 100 || (Object)(object)audio == (Object)null || (Object)(object)clip == (Object)null)
			{
				return false;
			}
			if (value > 0)
			{
				audio.PlayOneShot(clip, (float)value / 100f);
			}
			return true;
		}

		private void Preview()
		{
			if ((Object)(object)Pick._clip != (Object)null)
			{
				Play();
			}
			else
			{
				if (Pick._none)
				{
					return;
				}
				if ((Object)(object)_gameA == (Object)null)
				{
					Weapon[] array = Resources.FindObjectsOfTypeAll<Weapon>();
					foreach (Weapon val in array)
					{
						if (!((Object)(object)val == (Object)null) && _kind == SoundKind.MeleeKill == val is MeleeWeapon)
						{
							_gameA = ((_kind == SoundKind.HeadHit) ? val.headHitClip : ((_kind == SoundKind.Hit) ? val.bodyHitClip : val.deathClip));
							_gameB = ((_kind == SoundKind.HeadHit) ? val.bodyHitClip : null);
							if ((Object)(object)_gameA != (Object)null)
							{
								break;
							}
						}
					}
				}
				AudioClip gameA = _gameA;
				AudioClip gameB = _gameB;
				if (!((Object)(object)gameA == (Object)null))
				{
					if ((Object)(object)_source == (Object)null)
					{
						_source = NewSource();
					}
					float num = Mathf.Min((float)_volume.Value / 100f, 1f);
					_source.Stop();
					_source.PlayOneShot(gameA, num);
					if ((Object)(object)gameB != (Object)null)
					{
						_source.PlayOneShot(gameB, num);
					}
				}
			}
		}

		internal bool SameSound(SoundSlot other)
		{
			if (other != null)
			{
				return string.Equals(Pick._sound, other.Pick._sound, StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		internal void Play()
		{
			AudioClip clip = Pick._clip;
			if (!((Object)(object)clip == (Object)null))
			{
				if ((Object)(object)_source == (Object)null)
				{
					_source = NewSource();
				}
				int value = _volume.Value;
				_source.clip = ((value > 100) ? Louder(clip, value) : clip);
				_source.volume = ((value > 100) ? 1f : ((float)value / 100f));
				_source.Play();
			}
		}

		internal void Stop()
		{
			if ((Object)(object)_source != (Object)null)
			{
				_source.Stop();
			}
		}

		private static AudioSource NewSource()
		{
			//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_0024: Expected O, but got Unknown
			if ((Object)(object)_speaker == (Object)null)
			{
				_speaker = new GameObject("CombatSounds")
				{
					hideFlags = (HideFlags)61
				};
				Object.DontDestroyOnLoad((Object)(object)_speaker);
			}
			AudioSource obj = _speaker.AddComponent<AudioSource>();
			obj.playOnAwake = false;
			obj.spatialBlend = 0f;
			obj.priority = 0;
			bool flag = (obj.bypassReverbZones = true);
			bool bypassEffects = (obj.bypassListenerEffects = flag);
			obj.bypassEffects = bypassEffects;
			return obj;
		}

		private AudioClip Louder(AudioClip clip, int volume)
		{
			if (_louderVolume == volume && (Object)(object)_louderOf == (Object)(object)clip)
			{
				return _louder ?? clip;
			}
			_louderVolume = volume;
			_louderOf = clip;
			DropLouder();
			try
			{
				float[] array = new float[clip.samples * clip.channels];
				if (!clip.GetData(array, 0))
				{
					return clip;
				}
				float num = (float)volume / 100f;
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = Mathf.Clamp(array[i] * num, -1f, 1f);
				}
				_louder = AudioClip.Create(((Object)clip).name + " (louder)", clip.samples, clip.channels, clip.frequency, false);
				_louder.SetData(array, 0);
				return _louder;
			}
			catch (Exception ex)
			{
				CombatSoundsPlugin.Log.LogWarning((object)("Couldn't make " + ((Object)clip).name + " louder, so it plays at 100. (" + ex.Message + ")"));
				DropLouder();
				return clip;
			}
		}

		private void DropLouder()
		{
			if ((Object)(object)_louder != (Object)null)
			{
				Object.Destroy((Object)(object)_louder);
			}
			_louder = null;
		}

		private void Load(bool preview)
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			int id = ++_loadId;
			string choice = _choice.Value;
			_none = choice == "None";
			_following = _hit != null && choice == _same;
			if ((Object)(object)_clip != (Object)null)
			{
				Object.Destroy((Object)(object)_clip);
			}
			_clip = null;
			_sound = null;
			DropLouder();
			_louderVolume = 0;
			if (!_files.TryGetValue(choice, out var file))
			{
				if (preview)
				{
					Preview();
				}
				return;
			}
			string text = Path.GetExtension(file).ToLowerInvariant();
			AudioType val = (AudioType)((text == ".ogg") ? 14 : ((text == ".mp3") ? 13 : 20));
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(file), val);
			((AsyncOperation)request.SendWebRequest()).completed += delegate
			{
				try
				{
					AudioClip val2 = (string.IsNullOrEmpty(request.error) ? DownloadHandlerAudioClip.GetContent(request) : null);
					if (id != _loadId)
					{
						if ((Object)(object)val2 != (Object)null)
						{
							Object.Destroy((Object)(object)val2);
						}
					}
					else if ((Object)(object)val2 == (Object)null || val2.samples == 0)
					{
						CombatSoundsPlugin.Log.LogWarning((object)("Couldn't load " + Path.GetFileName(file) + " (" + (request.error ?? "not a sound Unity can play") + "), so the game's own " + _name.ToLowerInvariant() + " plays."));
					}
					else
					{
						((Object)val2).name = choice;
						_clip = val2;
						_sound = choice;
						if (preview)
						{
							Preview();
						}
					}
				}
				catch (Exception ex)
				{
					CombatSoundsPlugin.Log.LogWarning((object)("Couldn't load " + Path.GetFileName(file) + ": " + ex.Message));
				}
				finally
				{
					request.Dispose();
				}
			};
		}
	}
	internal static class Hooks
	{
		private static int _frame = -1;

		private static SoundSlot _hit;

		private static SoundSlot _kill;

		private static int _headLayerFrame = -1;

		private static int _meleeKillFrame = -1;

		private static bool _errorLogged;

		internal static void Install(Harmony harmony)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Settings), "IncreaseBodyshotsAmount", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Hooks), "HitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Settings), "IncreaseHeadshotsAmount", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Hooks), "HeadHitPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)AccessTools.Method(typeof(Settings), "IncreaseKillsAmount", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Hooks), "KillPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			HarmonyMethod val = new HarmonyMethod(typeof(Hooks), "GameSoundPrefix", (Type[])null);
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(Weapon).Assembly);
			foreach (Type type in typesFromAssembly)
			{
				if (typeof(Weapon).IsAssignableFrom(type))
				{
					MethodInfo methodInfo = AccessTools.DeclaredMethod(type, "LocalSound", new Type[1] { typeof(int) }, (Type[])null);
					if (methodInfo != null)
					{
						harmony.Patch((MethodBase)methodInfo, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					}
				}
			}
		}

		private static void HitPostfix()
		{
			Play(CombatSoundsPlugin.Hit, kill: false);
		}

		private static void HeadHitPostfix()
		{
			Play(CombatSoundsPlugin.HeadHit, kill: false);
		}

		private static void KillPostfix()
		{
			Play((_meleeKillFrame == Time.frameCount) ? CombatSoundsPlugin.MeleeKill : CombatSoundsPlugin.Kill, kill: true);
		}

		private static void Play(SoundSlot slot, bool kill)
		{
			try
			{
				int frameCount = Time.frameCount;
				if (frameCount != _frame)
				{
					_frame = frameCount;
					_hit = (_kill = null);
				}
				if (kill)
				{
					if (_kill == null)
					{
						_kill = slot;
						if (slot.HasSound && !slot.SameSound(_hit))
						{
							slot.Play();
						}
					}
				}
				else if (_hit != slot && _hit != CombatSoundsPlugin.HeadHit)
				{
					if (_hit != null)
					{
						_hit.Stop();
					}
					_hit = slot;
					if (slot.HasSound && !slot.SameSound(_kill))
					{
						slot.Play();
					}
				}
			}
			catch (Exception ex)
			{
				if (!_errorLogged)
				{
					_errorLogged = true;
					CombatSoundsPlugin.Log.LogError((object)("Error (further errors are not logged): " + ex));
				}
			}
		}

		private static bool GameSoundPrefix(Weapon __instance, int __0)
		{
			SoundSlot soundSlot;
			AudioClip clip;
			switch (__0)
			{
			case 0:
				_headLayerFrame = Time.frameCount;
				soundSlot = CombatSoundsPlugin.HeadHit;
				clip = (((Object)(object)__instance != (Object)null) ? __instance.headHitClip : null);
				break;
			case 1:
			{
				bool num2 = _headLayerFrame == Time.frameCount;
				_headLayerFrame = -1;
				soundSlot = (num2 ? CombatSoundsPlugin.HeadHit : CombatSoundsPlugin.Hit);
				clip = (((Object)(object)__instance != (Object)null) ? __instance.bodyHitClip : null);
				break;
			}
			case 2:
			{
				bool num = __instance is MeleeWeapon;
				if (num)
				{
					_meleeKillFrame = Time.frameCount;
				}
				soundSlot = (num ? CombatSoundsPlugin.MeleeKill : CombatSoundsPlugin.Kill);
				clip = (((Object)(object)__instance != (Object)null) ? __instance.deathClip : null);
				break;
			}
			default:
				return true;
			}
			try
			{
				if (soundSlot.ReplacesGameSound)
				{
					return false;
				}
				return !soundSlot.PlayGame(((Object)(object)__instance != (Object)null) ? __instance.audio : null, clip);
			}
			catch
			{
				return true;
			}
		}
	}
	internal static class GunSounds
	{
		private static readonly Dictionary<AudioSource, float> Noted = new Dictionary<AudioSource, float>();

		private static FieldRef<SetEffectVolume, AudioSource> _effectFrom;

		private static FieldRef<SetEffectVolume, AudioSource> _effectTo;

		private static FieldRef<SetPlayerVolume, AudioSource> _playerFrom;

		private static FieldRef<SetPlayerVolume, AudioSource> _playerTo;

		private static bool _errorLogged;

		private static int _pruneAt = 256;

		private static readonly List<AudioSource> Gone = new List<AudioSource>();

		private static float Scale => (float)CombatSoundsPlugin.GunVolume.Value / 100f;

		internal static void Install(Harmony harmony)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_00da: Unknow