Decompiled source of HotbarPlus v1.6.6

plugins/HotbarPlus.dll

Decompiled 19 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using HotbarPlus.Compatibility;
using HotbarPlus.Config;
using HotbarPlus.Input;
using HotbarPlus.Networking;
using HotbarPlus.Patches;
using LethalCompanyInputUtils.Api;
using ReservedItemSlotCore;
using ReservedItemSlotCore.Config;
using ReservedItemSlotCore.Data;
using TooManyEmotes;
using TooManyEmotes.Patches;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyTitle("HotbarPlus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HotbarPlus")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c0d59e18-2e2d-4afe-accf-897512d423ad")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HotbarPlus
{
	[BepInPlugin("FlipMods.HotbarPlus", "HotbarPlus", "1.6.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance;

		private Harmony _harmony;

		private static ManualLogSource logger;

		internal static GameObject energyBarPrefab;

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			instance = this;
			CreateCustomLogger();
			ConfigSettings.BindConfigSettings();
			Keybinds.InitKeybinds();
			LoadEnergyBarPrefab();
			_harmony = new Harmony("HotbarPlus");
			PatchAll();
			Log("HotbarPlus loaded");
		}

		private bool LoadEnergyBarPrefab()
		{
			bool flag;
			try
			{
				string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)instance).Info.Location), "Assets/energy_bar");
				AssetBundle val = AssetBundle.LoadFromFile(text);
				energyBarPrefab = val.LoadAsset<GameObject>("EnergyBar");
				flag = (Object)(object)energyBarPrefab != (Object)null;
			}
			catch
			{
				flag = false;
			}
			if (!flag)
			{
				LogError("Failed to load energy bar prefab from Asset Bundle.");
			}
			return flag;
		}

		private void PatchAll()
		{
			IEnumerable<Type> enumerable;
			try
			{
				enumerable = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				enumerable = ex.Types.Where((Type t) => t != null);
			}
			foreach (Type item in enumerable)
			{
				_harmony.PatchAll(item);
			}
		}

		private void CreateCustomLogger()
		{
			try
			{
				logger = Logger.CreateLogSource($"{((BaseUnityPlugin)this).Info.Metadata.Name}-{((BaseUnityPlugin)this).Info.Metadata.Version}");
			}
			catch
			{
				logger = ((BaseUnityPlugin)this).Logger;
			}
		}

		public static void Log(string message)
		{
			logger.LogInfo((object)message);
		}

		public static void LogError(string message)
		{
			logger.LogError((object)message);
		}

		public static void LogWarning(string message)
		{
			logger.LogWarning((object)message);
		}

		public static bool IsModLoaded(string guid)
		{
			return Chainloader.PluginInfos.ContainsKey(guid);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FlipMods.HotbarPlus";

		public const string PLUGIN_NAME = "HotbarPlus";

		public const string PLUGIN_VERSION = "1.6.6";
	}
}
namespace HotbarPlus.UI
{
	internal class EnergyBarData
	{
		public GameObject gameObject;

		public Slider slider;

		public Image energyBarImage;

		public Transform transform => gameObject.transform;

		public RectTransform rectTransform
		{
			get
			{
				Transform obj = transform;
				return (RectTransform)(object)((obj is RectTransform) ? obj : null);
			}
		}

		public EnergyBarData(GameObject gameObject)
		{
			this.gameObject = gameObject;
			slider = gameObject.GetComponentInChildren<Slider>();
			Transform obj = transform.Find("FillMask/Fill");
			energyBarImage = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
			if (!Object.op_Implicit((Object)(object)energyBarImage))
			{
				Plugin.LogWarning("Failed to find image for energy bar. This is okay.");
			}
		}

		public void SetEnergyBarColor(Color color)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)energyBarImage))
			{
				((Graphic)energyBarImage).color = color;
			}
		}
	}
	[HarmonyPatch]
	internal static class EnergyBarManager
	{
		internal static Dictionary<Image, EnergyBarData> energyBarSlidersDict = new Dictionary<Image, EnergyBarData>();

		public static Color energyBarColor = new Color(200f, 200f, 0f, 0.75f);

		private static PlayerControllerB localPlayerController => StartOfRound.Instance?.localPlayerController;

		[HarmonyPatch(typeof(HUDManager), "Awake")]
		[HarmonyPrefix]
		private static void Init(HUDManager __instance)
		{
			energyBarSlidersDict?.Clear();
		}

		[HarmonyPatch(typeof(StartOfRound), "ResetShip")]
		[HarmonyPrefix]
		private static void OnResetShip()
		{
			ResetEnergyBars();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "SpawnPlayerAnimation")]
		[HarmonyPrefix]
		private static void OnPlayerRespawn(PlayerControllerB __instance)
		{
			if (!((Object)(object)__instance != (Object)(object)localPlayerController))
			{
				ResetEnergyBars();
			}
		}

		private static void ResetEnergyBars()
		{
			Plugin.Log("Resetting energy bars.");
			foreach (EnergyBarData value in energyBarSlidersDict.Values)
			{
				Object.DestroyImmediate((Object)(object)value.gameObject);
			}
			energyBarSlidersDict?.Clear();
		}

		[HarmonyPatch(typeof(HUDManager), "Update")]
		[HarmonyPostfix]
		private static void UpdateEnergyBars(HUDManager __instance)
		{
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)localPlayerController == (Object)null || __instance?.itemSlotIconFrames == null || localPlayerController.isPlayerDead)
			{
				return;
			}
			for (int i = 0; i < __instance.itemSlotIconFrames.Length; i++)
			{
				Image val = __instance.itemSlotIconFrames[i];
				if (!Object.op_Implicit((Object)(object)val) || i < 0 || i >= localPlayerController.ItemSlots.Length)
				{
					continue;
				}
				GrabbableObject val2 = localPlayerController.ItemSlots[i];
				if (!energyBarSlidersDict.TryGetValue(val, out var value))
				{
					Transform obj = ((Component)val).transform.Find("EnergyBar");
					GameObject val3 = ((obj != null) ? ((Component)obj).gameObject : null);
					if (!Object.op_Implicit((Object)(object)val3))
					{
						val3 = Object.Instantiate<GameObject>(Plugin.energyBarPrefab);
					}
					((Object)val3).name = "EnergyBar";
					val3.transform.SetParent(((Component)val).transform);
					value = new EnergyBarData(val3);
					value.rectTransform.anchorMin = new Vector2(1f, 0.5f);
					value.rectTransform.anchorMax = new Vector2(1f, 0.5f);
					value.rectTransform.pivot = new Vector2(0.5f, 0.5f);
					value.SetEnergyBarColor(energyBarColor);
					energyBarSlidersDict.Add(val, value);
				}
				float num = ((Graphic)val).rectTransform.sizeDelta.x / HUDPatcher.defaultItemFrameSize.x;
				((Transform)value.rectTransform).localScale = Vector3.one / 36f * num;
				value.rectTransform.anchoredPosition3D = new Vector3(-4f * num, 0f, 0f);
				value.transform.localEulerAngles = new Vector3(0f, 0f, 90f);
				if (!Object.op_Implicit((Object)(object)value.gameObject))
				{
					energyBarSlidersDict.Remove(val);
				}
				else if (ConfigSettings.disableEnergyBars.Value || !Object.op_Implicit((Object)(object)val2) || !val2.itemProperties.requiresBattery || val2.insertedBattery == null || (ReservedItemSlots_Compat.Enabled && ((Object)val).name.ToLower().Contains("reserved") && ReservedItemSlots_Compat.ShouldDisableEnergyBarsReservedItemSlots()))
				{
					if (value.gameObject.activeSelf)
					{
						value.gameObject.SetActive(false);
					}
				}
				else
				{
					value.gameObject.SetActive(true);
					value.slider.value = Mathf.Clamp(val2.insertedBattery.charge, 0f, 1f);
				}
			}
		}
	}
}
namespace HotbarPlus.Patches
{
	[HarmonyPatch]
	public class HUDPatcher
	{
		internal static float hotbarSlotSize = 40f;

		internal static Vector2 defaultItemFrameSize;

		internal static Vector2 defaultItemIconSize;

		internal static float defaultItemSlotPosY;

		internal static float currentOverrideHotbarSpacing;

		internal static float currentOverrideHotbarHudScale;

		[HarmonyPatch(typeof(HUDManager), "Awake")]
		[HarmonyPostfix]
		private static void Init(HUDManager __instance)
		{
			//IL_000e: 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_0025: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			defaultItemFrameSize = ((Graphic)__instance.itemSlotIconFrames[0]).rectTransform.sizeDelta;
			defaultItemIconSize = ((Graphic)__instance.itemSlotIcons[0]).rectTransform.sizeDelta;
			defaultItemSlotPosY = ((Graphic)__instance.itemSlotIconFrames[0]).rectTransform.anchoredPosition.y;
			if (ConfigSettings.centerInventoryUIFix.Value)
			{
				HUDElement inventory = __instance.Inventory;
				object obj;
				if (inventory == null)
				{
					obj = null;
				}
				else
				{
					CanvasGroup canvasGroup = inventory.canvasGroup;
					obj = ((canvasGroup != null) ? ((Component)canvasGroup).transform : null);
				}
				RectTransform val = (RectTransform)((obj is RectTransform) ? obj : null);
				if ((Object)(object)val != (Object)null)
				{
					val.pivot = new Vector2(0.5f, 0.5f);
					val.anchorMin = new Vector2(0.5f, 0.5f);
					val.anchorMax = new Vector2(0.5f, 0.5f);
					val.anchoredPosition3D = new Vector3(0f, val.anchoredPosition3D.y, val.anchoredPosition3D.z);
				}
			}
		}

		public static void ResizeHotbarSlotsHUD()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: 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_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			List<Image> list = new List<Image>(HUDManager.Instance.itemSlotIconFrames);
			List<Image> list2 = new List<Image>(HUDManager.Instance.itemSlotIcons);
			float num = (hotbarSlotSize + (float)ConfigSettings.overrideHotbarSpacing.Value) * ConfigSettings.overrideHotbarHudSize.Value;
			float num2 = defaultItemSlotPosY + 36f * ((ConfigSettings.overrideHotbarHudSize.Value - 1f) / 2f);
			Vector3 eulerAngles = ((Transform)((Graphic)list[0]).rectTransform).eulerAngles;
			Vector3 eulerAngles2 = ((Transform)((Graphic)list2[0]).rectTransform).eulerAngles;
			for (int i = 0; i < Mathf.Max(SyncManager.hotbarSize, PlayerPatcher.vanillaHotbarSize); i++)
			{
				if (i >= SyncManager.hotbarSize)
				{
					Object.Destroy((Object)(object)list[SyncManager.hotbarSize]);
					Object.Destroy((Object)(object)list2[SyncManager.hotbarSize]);
					list.RemoveAt(SyncManager.hotbarSize);
					list2.RemoveAt(SyncManager.hotbarSize);
					continue;
				}
				if (i >= PlayerPatcher.vanillaHotbarSize)
				{
					list.Insert(i, Object.Instantiate<Image>(list[0], ((Component)list[0]).transform.parent));
					((Component)list[i]).transform.SetSiblingIndex(((Component)list[i - 1]).transform.GetSiblingIndex() + 1);
					list2.Insert(i, ((Component)((Component)list[i]).transform.GetChild(0)).GetComponent<Image>());
					list[i].fillMethod = list[0].fillMethod;
					list[i].sprite = list[0].sprite;
					((Graphic)list[i]).material = ((Graphic)list[0]).material;
					if (Plugin.IsModLoaded("xuxiaolan.hotbarrd"))
					{
						list[i].overrideSprite = list[0].overrideSprite;
					}
				}
				((Object)list[i]).name = $"Slot{i}";
				((Graphic)list[i]).rectTransform.anchoredPosition = Vector2.up * num2;
				((Transform)((Graphic)list[i]).rectTransform).eulerAngles = eulerAngles;
				((Object)list2[i]).name = "Icon";
				((Transform)((Graphic)list2[i]).rectTransform).eulerAngles = eulerAngles2;
			}
			float num3 = num * (float)(SyncManager.hotbarSize - 1);
			float num4 = num3 / 2f;
			for (int j = 0; j < SyncManager.hotbarSize; j++)
			{
				float num5 = (float)j * num - num4;
				((Graphic)list[j]).rectTransform.anchoredPosition = new Vector2(num5, num2);
				((Graphic)list[j]).rectTransform.sizeDelta = defaultItemFrameSize * ConfigSettings.overrideHotbarHudSize.Value;
				((Graphic)list2[j]).rectTransform.sizeDelta = defaultItemIconSize * ConfigSettings.overrideHotbarHudSize.Value;
			}
			HUDManager.Instance.itemSlotIconFrames = list.ToArray();
			HUDManager.Instance.itemSlotIcons = list2.ToArray();
			currentOverrideHotbarSpacing = ConfigSettings.overrideHotbarSpacing.Value;
			currentOverrideHotbarHudScale = ConfigSettings.overrideHotbarHudSize.Value;
		}

		[HarmonyPatch(typeof(HUDManager), "PingHUDElement")]
		[HarmonyPrefix]
		public static void PingHUDElement(HUDElement element, ref float startAlpha, ref float endAlpha, HUDManager __instance)
		{
			if (element != __instance.Inventory || endAlpha != 0.13f)
			{
				return;
			}
			if (startAlpha == 0.13f && StartOfRound.Instance.localPlayerController.twoHanded)
			{
				endAlpha = 1f;
				return;
			}
			endAlpha = Mathf.Clamp(ConfigSettings.overrideFadeHudAlpha.Value, 0f, 1f);
			if (startAlpha == 0.13f)
			{
				startAlpha = endAlpha;
			}
		}
	}
	[HarmonyPatch]
	public class PlayerPatcher
	{
		public static int vanillaHotbarSize = -1;

		public static int postInitialHotbarSize = -1;

		public static int newHotbarSize = -1;

		private static PlayerControllerB localPlayerController => StartOfRound.Instance?.localPlayerController;

		[HarmonyPatch(typeof(PlayerControllerB), "Awake")]
		[HarmonyPostfix]
		public static void GetInitialHotbarSize(PlayerControllerB __instance)
		{
			if (vanillaHotbarSize == -1)
			{
				vanillaHotbarSize = __instance.ItemSlots.Length;
			}
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void InitializeLocalPlayer(PlayerControllerB __instance)
		{
			((Component)HUDManager.Instance.itemSlotIconFrames[Mathf.Max(__instance.currentItemSlot, 0)]).GetComponent<Animator>().SetBool("selectedSlot", true);
			HUDManager.Instance.PingHUDElement(HUDManager.Instance.Inventory, 0.1f, 0.13f, 0.13f);
		}

		public static void ResizeInventory()
		{
			postInitialHotbarSize = localPlayerController.ItemSlots.Length;
			newHotbarSize = Mathf.Max(SyncManager.hotbarSize + (postInitialHotbarSize - vanillaHotbarSize), 0);
			Plugin.LogWarning("Resizing inventory to: " + newHotbarSize + ". Previous: " + postInitialHotbarSize);
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				val.ItemSlots = (GrabbableObject[])(object)new GrabbableObject[newHotbarSize];
			}
		}

		public static int CallGetNextItemSlot(PlayerControllerB __instance, bool forward, int index)
		{
			int currentItemSlot = __instance.currentItemSlot;
			__instance.currentItemSlot = index;
			MethodInfo method = ((object)__instance).GetType().GetMethod("NextItemSlot", BindingFlags.Instance | BindingFlags.NonPublic);
			index = (int)method.Invoke(__instance, new object[1] { forward });
			__instance.currentItemSlot = currentItemSlot;
			return index;
		}

		public static void CallSwitchToItemSlot(PlayerControllerB __instance, int index, GrabbableObject fillSlotWithItem = null)
		{
			MethodInfo method = ((object)__instance).GetType().GetMethod("SwitchToItemSlot", BindingFlags.Instance | BindingFlags.NonPublic);
			method.Invoke(__instance, new object[2] { index, fillSlotWithItem });
			SetTimeSinceSwitchingSlots(__instance, 0f);
		}

		public static float GetTimeSinceSwitchingSlots(PlayerControllerB playerController)
		{
			return (float)Traverse.Create((object)playerController).Field("timeSinceSwitchingSlots").GetValue();
		}

		public static void SetTimeSinceSwitchingSlots(PlayerControllerB playerController, float value)
		{
			Traverse.Create((object)playerController).Field("timeSinceSwitchingSlots").SetValue((object)value);
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchSwitchItemInterval(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			if (!ConfigSettings.disableFasterHotbarSwapping.Value && !GeneralImprovements_Compat.Enabled)
			{
				for (int i = 0; i < list.Count; i++)
				{
					if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 0.3f)
					{
						list[i].operand = ConfigSettings.minSwapItemInterval;
						break;
					}
				}
			}
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ActivateItem_performed")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchActivateItemInterval(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			if (!ConfigSettings.disableFasterItemActivate.Value && !GeneralImprovements_Compat.Enabled)
			{
				for (int i = 0; i < list.Count; i++)
				{
					if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 0.075f)
					{
						list[i].operand = ConfigSettings.minActivateItemInterval;
						break;
					}
				}
			}
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Discard_performed")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchDiscardItemInterval(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			if (!ConfigSettings.disableFasterItemDropping.Value)
			{
				for (int i = 0; i < list.Count; i++)
				{
					if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 0.2f)
					{
						list[i].operand = ConfigSettings.minDiscardItemInterval;
					}
				}
			}
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "Interact_performed")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchInteractInterval(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			if (!GeneralImprovements_Compat.Enabled)
			{
				for (int i = 0; i < list.Count; i++)
				{
					if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 0.2f)
					{
						list[i].operand = ConfigSettings.minInteractInterval;
						break;
					}
				}
			}
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "PerformEmote")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> PatchPerformEmoteInterval(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldc_R4 && (float)list[i].operand == 0.5f)
				{
					list[i].operand = ConfigSettings.minUseEmoteInterval;
					break;
				}
			}
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> InvertHotbarScrollDirection(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			if (ConfigSettings.invertHotbarScrollDirectionConfig.Value)
			{
				for (int i = 1; i < list.Count; i++)
				{
					if (list[i].opcode == OpCodes.Ble_Un && list[i - 1].opcode == OpCodes.Ldc_R4 && (float)list[i - 1].operand == 0f)
					{
						list[i].opcode = OpCodes.Bge_Un;
						break;
					}
				}
			}
			return list.AsEnumerable();
		}
	}
	[HarmonyPatch]
	public class QuickDrop
	{
		public static float timeDroppedItem;

		public static bool droppingItem = false;

		private static HashSet<int> checkedSlots = new HashSet<int>();

		public static PlayerControllerB localPlayerController => StartOfRound.Instance?.localPlayerController;

		[HarmonyPatch(typeof(PlayerControllerB), "DiscardHeldObject")]
		[HarmonyPostfix]
		private static void PerformQuickDiscard(PlayerControllerB __instance)
		{
			if (droppingItem || (Object)(object)__instance != (Object)(object)localPlayerController || !ConfigSettings.useItemQuickDropConfig.Value || !SyncManager.isSynced || (ReservedItemSlots_Compat.Enabled && ReservedItemSlots_Compat.IsItemSlotReserved(localPlayerController.currentItemSlot)))
			{
				return;
			}
			checkedSlots.Clear();
			int num = PlayerPatcher.CallGetNextItemSlot(__instance, forward: true, __instance.currentItemSlot);
			while (num != __instance.currentItemSlot && !checkedSlots.Contains(num))
			{
				checkedSlots.Add(num);
				GrabbableObject val = __instance.ItemSlots[num];
				if ((Object)(object)val != (Object)null)
				{
					break;
				}
				num = PlayerPatcher.CallGetNextItemSlot(__instance, forward: true, num);
			}
			if (num != __instance.currentItemSlot && num >= 0 && num < __instance.ItemSlots.Length)
			{
				Plugin.Log("On discard item. Auto swapping to held item at slot: " + num + ". Prev slot: " + __instance.currentItemSlot);
				droppingItem = true;
				localPlayerController.playerBodyAnimator.SetBool("cancelGrab", false);
				PlayerPatcher.SetTimeSinceSwitchingSlots(__instance, 0f);
				__instance.playerBodyAnimator.ResetTrigger("SwitchHoldAnimation");
				((MonoBehaviour)__instance).StartCoroutine(SwitchToItemSlotAfterDelay(__instance, num));
			}
		}

		private static IEnumerator SwitchToItemSlotAfterDelay(PlayerControllerB __instance, int slot)
		{
			int oldSlot = __instance.currentItemSlot;
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)__instance.currentlyHeldObjectServer == (Object)null || __instance.currentItemSlot != oldSlot));
			if (__instance.currentItemSlot == oldSlot)
			{
				SyncManager.SwapHotbarSlot(slot);
			}
			else
			{
				Plugin.LogWarning("Failed to perform item quick drop. Current selected item slot was updated before drop animation could complete. (this is okay)");
			}
			droppingItem = false;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ScrollMouse_performed")]
		[HarmonyPrefix]
		private static bool PreventItemSwappingDroppingItem(CallbackContext context, PlayerControllerB __instance)
		{
			if ((Object)(object)__instance == (Object)(object)localPlayerController && droppingItem)
			{
				return false;
			}
			return true;
		}
	}
}
namespace HotbarPlus.Networking
{
	[HarmonyPatch]
	public class SyncManager
	{
		public static bool isSynced;

		private static PlayerControllerB localPlayerController => StartOfRound.Instance?.localPlayerController;

		public static int hotbarSize { get; private set; }

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		public static void ResetValues()
		{
			isSynced = false;
			hotbarSize = 4;
		}

		[HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void Init()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			isSynced = false;
			if (NetworkManager.Singleton.IsServer)
			{
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("HotbarPlus.OnRequestSyncServerRpc", new HandleNamedMessageDelegate(OnRequestSyncServerRpc));
				hotbarSize = ConfigSettings.hotbarSize.Value;
				OnSyncedWithServer();
			}
			else if (NetworkManager.Singleton.IsClient)
			{
				NetworkManager.Singleton.CustomMessagingManager.RegisterNamedMessageHandler("HotbarPlus.OnRequestSyncClientRpc", new HandleNamedMessageDelegate(OnRequestSyncClientRpc));
				RequestSyncWithServer();
			}
		}

		private static void RequestSyncWithServer()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log("Requesting sync with server.");
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("HotbarPlus.OnRequestSyncServerRpc", 0uL, new FastBufferWriter(0, (Allocator)2, -1), (NetworkDelivery)3);
		}

		private static void OnRequestSyncServerRpc(ulong clientId, FastBufferReader reader)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				Plugin.Log("Received request for sync from Client: " + clientId);
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(4, (Allocator)2, -1);
				int num = hotbarSize;
				((FastBufferWriter)(ref val)).WriteValue<int>(ref num, default(ForPrimitives));
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("HotbarPlus.OnRequestSyncClientRpc", clientId, val, (NetworkDelivery)3);
			}
		}

		private static void OnRequestSyncClientRpc(ulong clientId, FastBufferReader reader)
		{
			//IL_0026: 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)
			if (NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer)
			{
				int num = default(int);
				((FastBufferReader)(ref reader)).ReadValue<int>(ref num, default(ForPrimitives));
				Plugin.Log("Received sync from Server. Hotbar size: " + num);
				hotbarSize = num;
				OnSyncedWithServer();
			}
		}

		private static void OnSyncedWithServer()
		{
			isSynced = true;
			PlayerPatcher.ResizeInventory();
			HUDPatcher.ResizeHotbarSlotsHUD();
			Keybinds.OnSetHotbarSize();
		}

		private static void SendHotbarSlotChange(int hotbarSlot)
		{
			if (NetworkManager.Singleton.IsClient && hotbarSlot != localPlayerController.currentItemSlot)
			{
				Plugin.Log("Sending hotbar swap slot: " + hotbarSlot);
				int num = localPlayerController.currentItemSlot - hotbarSlot;
				bool flag = num > 0;
				for (int i = 0; i < Mathf.Abs(num); i++)
				{
					MethodInfo method = ((object)localPlayerController).GetType().GetMethod("SwitchItemSlotsServerRpc", BindingFlags.Instance | BindingFlags.NonPublic);
					method.Invoke(localPlayerController, new object[1] { flag });
				}
			}
		}

		public static void SwapHotbarSlot(int hotbarIndex)
		{
			if (hotbarIndex < hotbarSize)
			{
				SendHotbarSlotChange(hotbarIndex);
				CallSwitchToItemSlotMethod(localPlayerController, hotbarIndex);
			}
		}

		public static void CallSwitchToItemSlotMethod(PlayerControllerB playerController, int hotbarIndex)
		{
			if (hotbarIndex >= 0 && hotbarIndex < hotbarSize && playerController.currentItemSlot != hotbarIndex)
			{
				if ((Object)(object)playerController == (Object)(object)localPlayerController)
				{
					ShipBuildModeManager.Instance.CancelBuildMode(true);
					playerController.playerBodyAnimator.SetBool("GrabValidated", false);
				}
				MethodInfo method = ((object)playerController).GetType().GetMethod("SwitchToItemSlot", BindingFlags.Instance | BindingFlags.NonPublic);
				method.Invoke(playerController, new object[2] { hotbarIndex, null });
				PlayerPatcher.SetTimeSinceSwitchingSlots(playerController, 0f);
				if ((Object)(object)playerController.currentlyHeldObjectServer != (Object)null)
				{
					((Component)playerController.currentlyHeldObjectServer).gameObject.GetComponent<AudioSource>().PlayOneShot(playerController.currentlyHeldObjectServer.itemProperties.grabSFX, 0.6f);
				}
			}
		}
	}
}
namespace HotbarPlus.Input
{
	internal class IngameKeybinds : LcInputActions
	{
		internal static IngameKeybinds Instance = new IngameKeybinds();

		[InputAction("<Keyboard>/1", Name = "[HB+] Quick Slot 1")]
		public InputAction QuickHotbarSlotHotkey1 { get; set; }

		[InputAction("<Keyboard>/2", Name = "[HB+] Quick Slot 2")]
		public InputAction QuickHotbarSlotHotkey2 { get; set; }

		[InputAction("<Keyboard>/3", Name = "[HB+] Quick Slot 3")]
		public InputAction QuickHotbarSlotHotkey3 { get; set; }

		[InputAction("<Keyboard>/4", Name = "[HB+] Quick Slot 4")]
		public InputAction QuickHotbarSlotHotkey4 { get; set; }

		[InputAction("<Keyboard>/5", Name = "[HB+] Quick Slot 5")]
		public InputAction QuickHotbarSlotHotkey5 { get; set; }

		[InputAction("<Keyboard>/6", Name = "[HB+] Quick Slot 6")]
		public InputAction QuickHotbarSlotHotkey6 { get; set; }

		internal static InputActionAsset GetAsset()
		{
			return ((LcInputActions)Instance).Asset;
		}
	}
	internal class InputUtilsCompat
	{
		internal static InputActionAsset Asset => IngameKeybinds.GetAsset();

		internal static bool Enabled => Plugin.IsModLoaded("com.rune580.LethalCompanyInputUtils");

		public static InputAction QuickHotbarSlotHotkey1 => IngameKeybinds.Instance.QuickHotbarSlotHotkey1;

		public static InputAction QuickHotbarSlotHotkey2 => IngameKeybinds.Instance.QuickHotbarSlotHotkey2;

		public static InputAction QuickHotbarSlotHotkey3 => IngameKeybinds.Instance.QuickHotbarSlotHotkey3;

		public static InputAction QuickHotbarSlotHotkey4 => IngameKeybinds.Instance.QuickHotbarSlotHotkey4;

		public static InputAction QuickHotbarSlotHotkey5 => IngameKeybinds.Instance.QuickHotbarSlotHotkey5;

		public static InputAction QuickHotbarSlotHotkey6 => IngameKeybinds.Instance.QuickHotbarSlotHotkey6;
	}
	[HarmonyPatch]
	public class Keybinds
	{
		private static bool setHotbarSize;

		public static InputActionAsset Asset;

		public static InputActionMap ActionMap;

		public static InputAction quickHotbarSlotHotkey1;

		public static InputAction quickHotbarSlotHotkey2;

		public static InputAction quickHotbarSlotHotkey3;

		public static InputAction quickHotbarSlotHotkey4;

		public static InputAction quickHotbarSlotHotkey5;

		public static InputAction quickHotbarSlotHotkey6;

		private static PlayerControllerB localPlayerController => StartOfRound.Instance?.localPlayerController;

		public static void InitKeybinds()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			setHotbarSize = false;
			if (ConfigSettings.useHotbarNumberHotkeysConfig.Value)
			{
				if (InputUtilsCompat.Enabled)
				{
					Asset = InputUtilsCompat.Asset;
					quickHotbarSlotHotkey1 = InputUtilsCompat.QuickHotbarSlotHotkey1;
					quickHotbarSlotHotkey2 = InputUtilsCompat.QuickHotbarSlotHotkey2;
					quickHotbarSlotHotkey3 = InputUtilsCompat.QuickHotbarSlotHotkey3;
					quickHotbarSlotHotkey4 = InputUtilsCompat.QuickHotbarSlotHotkey4;
					quickHotbarSlotHotkey5 = InputUtilsCompat.QuickHotbarSlotHotkey5;
					quickHotbarSlotHotkey6 = InputUtilsCompat.QuickHotbarSlotHotkey6;
				}
				else
				{
					Asset = ScriptableObject.CreateInstance<InputActionAsset>();
					ActionMap = new InputActionMap("HotbarPlus");
					InputActionSetupExtensions.AddActionMap(Asset, ActionMap);
					quickHotbarSlotHotkey1 = InputActionSetupExtensions.AddAction(ActionMap, "[HB+] Quick Slot 1", (InputActionType)0, "<Keyboard>/1", "Press", (string)null, (string)null, (string)null);
					quickHotbarSlotHotkey2 = InputActionSetupExtensions.AddAction(ActionMap, "[HB+] Quick Slot 2", (InputActionType)0, "<Keyboard>/2", "Press", (string)null, (string)null, (string)null);
					quickHotbarSlotHotkey3 = InputActionSetupExtensions.AddAction(ActionMap, "[HB+] Quick Slot 3", (InputActionType)0, "<Keyboard>/3", "Press", (string)null, (string)null, (string)null);
					quickHotbarSlotHotkey4 = InputActionSetupExtensions.AddAction(ActionMap, "[HB+] Quick Slot 4", (InputActionType)0, "<Keyboard>/4", "Press", (string)null, (string)null, (string)null);
					quickHotbarSlotHotkey5 = InputActionSetupExtensions.AddAction(ActionMap, "[HB+] Quick Slot 5", (InputActionType)0, "<Keyboard>/5", "Press", (string)null, (string)null, (string)null);
					quickHotbarSlotHotkey6 = InputActionSetupExtensions.AddAction(ActionMap, "[HB+] Quick Slot 6", (InputActionType)0, "<Keyboard>/6", "Press", (string)null, (string)null, (string)null);
				}
			}
		}

		public static void OnSetHotbarSize()
		{
			setHotbarSize = true;
		}

		[HarmonyPatch(typeof(StartOfRound), "OnEnable")]
		[HarmonyPostfix]
		public static void OnEnable()
		{
			if (ConfigSettings.useHotbarNumberHotkeysConfig.Value)
			{
				Asset.Enable();
				quickHotbarSlotHotkey1.performed += OnPressItemSlotHotkeyAction1;
				quickHotbarSlotHotkey2.performed += OnPressItemSlotHotkeyAction2;
				quickHotbarSlotHotkey3.performed += OnPressItemSlotHotkeyAction3;
				quickHotbarSlotHotkey4.performed += OnPressItemSlotHotkeyAction4;
				quickHotbarSlotHotkey5.performed += OnPressItemSlotHotkeyAction5;
				quickHotbarSlotHotkey6.performed += OnPressItemSlotHotkeyAction6;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "OnDisable")]
		[HarmonyPostfix]
		public static void OnDisable()
		{
			if (ConfigSettings.useHotbarNumberHotkeysConfig.Value)
			{
				Asset.Disable();
				quickHotbarSlotHotkey1.performed -= OnPressItemSlotHotkeyAction1;
				quickHotbarSlotHotkey2.performed -= OnPressItemSlotHotkeyAction2;
				quickHotbarSlotHotkey3.performed -= OnPressItemSlotHotkeyAction3;
				quickHotbarSlotHotkey4.performed -= OnPressItemSlotHotkeyAction4;
				quickHotbarSlotHotkey5.performed -= OnPressItemSlotHotkeyAction5;
				quickHotbarSlotHotkey6.performed -= OnPressItemSlotHotkeyAction6;
			}
		}

		private static void OnPressItemSlotHotkeyAction1(CallbackContext context)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			OnPressItemSlotHotkeyAction(context, 0);
		}

		private static void OnPressItemSlotHotkeyAction2(CallbackContext context)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			OnPressItemSlotHotkeyAction(context, 1);
		}

		private static void OnPressItemSlotHotkeyAction3(CallbackContext context)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			OnPressItemSlotHotkeyAction(context, 2);
		}

		private static void OnPressItemSlotHotkeyAction4(CallbackContext context)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			OnPressItemSlotHotkeyAction(context, 3);
		}

		private static void OnPressItemSlotHotkeyAction5(CallbackContext context)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			OnPressItemSlotHotkeyAction(context, 4);
		}

		private static void OnPressItemSlotHotkeyAction6(CallbackContext context)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			OnPressItemSlotHotkeyAction(context, 5);
		}

		private static void OnPressItemSlotHotkeyAction(CallbackContext context, int slot)
		{
			if (!((Object)(object)localPlayerController == (Object)null) && ((NetworkBehaviour)localPlayerController).IsOwner && localPlayerController.isPlayerControlled && SyncManager.isSynced && ((CallbackContext)(ref context)).performed && ConfigSettings.useHotbarNumberHotkeysConfig.Value && setHotbarSize && slot >= 0 && slot < SyncManager.hotbarSize && !(bool)Traverse.Create((object)localPlayerController).Field("throwingObject").GetValue() && !localPlayerController.isTypingChat && !localPlayerController.inTerminalMenu && !localPlayerController.quickMenuManager.isMenuOpen && !localPlayerController.isPlayerDead && !localPlayerController.isGrabbingObjectAnimation && !localPlayerController.activatingItem && !localPlayerController.inSpecialInteractAnimation && !localPlayerController.twoHanded && !localPlayerController.jetpackControls && !localPlayerController.disablingJetpackControls && !(PlayerPatcher.GetTimeSinceSwitchingSlots(localPlayerController) < ((!ConfigSettings.disableFasterHotbarSwapping.Value) ? ConfigSettings.minSwapItemInterval : 0.3f)))
			{
				SyncManager.SwapHotbarSlot(slot);
			}
		}
	}
}
namespace HotbarPlus.Config
{
	public static class ConfigSettings
	{
		public static ConfigEntry<int> hotbarSize;

		public static ConfigEntry<bool> useHotbarNumberHotkeysConfig;

		public static ConfigEntry<bool> invertHotbarScrollDirectionConfig;

		public static ConfigEntry<bool> useItemQuickDropConfig;

		public static ConfigEntry<bool> disableFasterHotbarSwapping;

		public static ConfigEntry<bool> disableFasterItemDropping;

		public static ConfigEntry<bool> disableFasterItemActivate;

		public static ConfigEntry<bool> applyFormattingToReservedItemSlots;

		public static ConfigEntry<bool> disableEnergyBars;

		public static ConfigEntry<bool> centerInventoryUIFix;

		public static ConfigEntry<int> overrideHotbarSpacing;

		public static ConfigEntry<float> overrideFadeHudAlpha;

		public static ConfigEntry<float> overrideHotbarHudSize;

		public static Dictionary<string, ConfigEntryBase> currentConfigEntries = new Dictionary<string, ConfigEntryBase>();

		public static float minSwapItemInterval = 0.05f;

		public static float minActivateItemInterval = 0.05f;

		public static float minDiscardItemInterval = 0.05f;

		public static float minInteractInterval = 0.05f;

		public static float minUseEmoteInterval = 0.25f;

		public static List<ConfigEntryBase> configEntries = new List<ConfigEntryBase>();

		public static void BindConfigSettings()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Expected O, but got Unknown
			Plugin.Log("BindingConfigs");
			hotbarSize = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "NumHotbarSlots", 4, new ConfigDescription("[Host only] The amount of hotbar slots player will have. This will sync with other clients who have the mod.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())));
			useHotbarNumberHotkeysConfig = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Client-side", "UseHotbarNumberHotkeys", true, "Use the quick item selection numerical hotkeys."));
			invertHotbarScrollDirectionConfig = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Client-side", "InvertHotbarScrollDirection", true, "Inverts the direction in which you scroll on the hotbar. Will not affect the terminal scrolling direction."));
			useItemQuickDropConfig = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Client-side", "UseItemQuickDropConfig", true, "If enabled, dropping an item will automatically swap to the next item for easier chain dropping. This may not work if the host does not have the mod. This is for stability reasons, and to help reduce de-sync."));
			disableFasterHotbarSwapping = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Client-side", "UseDefaultItemSwapInterval", false, "If true, the interval (delay) between swapping items will not be reduced by this mod."));
			disableFasterItemDropping = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Client-side", "UseDefaultItemDropInterval", false, "If true, the interval (delay) between dropping items will not be reduced by this mod."));
			disableFasterItemActivate = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Client-side", "UseDefaultItemActivateInterval", false, "If true, the interval (delay) between activating items will not be reduced by this mod."));
			disableEnergyBars = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("UI", "DisableEnergyBars", false, "Disables/hides the energy bars for items in the HUD."));
			centerInventoryUIFix = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("UI", "CenterInventoryUIFix", true, "Fixes the Inventory UI alignment to keep the HUD elements centered across all window sizes. Disable this if it's conflicting with other mods."));
			overrideHotbarSpacing = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("UI", "OverrideHotbarHudSpacing", 10, new ConfigDescription("The spacing between each hotbar slot UI element.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())));
			overrideHotbarHudSize = AddConfigEntry<float>(((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("UI", "OverrideHotbarHudSize", 1f, new ConfigDescription("Scales the hotbar slot HUD elements by a multiplier. HUD spacing/position should be scaled automatically.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())));
			overrideFadeHudAlpha = AddConfigEntry<float>(((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("UI", "OverrideFadeHudAlpha", 0.13f, new ConfigDescription("Sets the alpha for when the hotbar hud fades. Default = 0.13 | Fade completely: 0 | Never fade: 1", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())));
			TryRemoveOldConfigSettings();
		}

		public static ConfigEntry<T> AddConfigEntry<T>(ConfigEntry<T> configEntry)
		{
			currentConfigEntries.Add(((ConfigEntryBase)configEntry).Definition.Key, (ConfigEntryBase)(object)configEntry);
			return configEntry;
		}

		public static void TryRemoveOldConfigSettings()
		{
			HashSet<string> hashSet = new HashSet<string>();
			HashSet<string> hashSet2 = new HashSet<string>();
			foreach (ConfigEntryBase value in currentConfigEntries.Values)
			{
				hashSet.Add(value.Definition.Section);
				hashSet2.Add(value.Definition.Key);
			}
			try
			{
				ConfigFile config = ((BaseUnityPlugin)Plugin.instance).Config;
				string configFilePath = config.ConfigFilePath;
				if (!File.Exists(configFilePath))
				{
					return;
				}
				string text = File.ReadAllText(configFilePath);
				string[] array = File.ReadAllLines(configFilePath);
				string text2 = "";
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = array[i].Replace("\n", "");
					if (array[i].Length <= 0)
					{
						continue;
					}
					if (array[i].StartsWith("["))
					{
						if (text2 != "" && !hashSet.Contains(text2))
						{
							text2 = "[" + text2 + "]";
							int num = text.IndexOf(text2);
							int num2 = text.IndexOf(array[i]);
							text = text.Remove(num, num2 - num);
						}
						text2 = array[i].Replace("[", "").Replace("]", "").Trim();
					}
					else
					{
						if (!(text2 != ""))
						{
							continue;
						}
						if (i <= array.Length - 4 && array[i].StartsWith("##"))
						{
							int j;
							for (j = 1; i + j < array.Length && array[i + j].Length > 3; j++)
							{
							}
							if (hashSet.Contains(text2))
							{
								int num3 = array[i + j - 1].IndexOf("=");
								string item = array[i + j - 1].Substring(0, num3 - 1);
								if (!hashSet2.Contains(item))
								{
									int num4 = text.IndexOf(array[i]);
									int num5 = text.IndexOf(array[i + j - 1]) + array[i + j - 1].Length;
									text = text.Remove(num4, num5 - num4);
								}
							}
							i += j - 1;
						}
						else if (array[i].Length > 3)
						{
							text = text.Replace(array[i], "");
						}
					}
				}
				if (!hashSet.Contains(text2))
				{
					text2 = "[" + text2 + "]";
					int num6 = text.IndexOf(text2);
					text = text.Remove(num6, text.Length - num6);
				}
				while (text.Contains("\n\n\n"))
				{
					text = text.Replace("\n\n\n", "\n\n");
				}
				File.WriteAllText(configFilePath, text);
				config.Reload();
			}
			catch
			{
			}
		}
	}
}
namespace HotbarPlus.Compatibility
{
	internal static class GeneralImprovements_Compat
	{
		public static bool Enabled => Plugin.IsModLoaded("ShaosilGaming.GeneralImprovements");
	}
	internal static class ReservedItemSlots_Compat
	{
		public static bool Enabled => Plugin.IsModLoaded("FlipMods.ReservedItemSlotCore");

		public static bool IsToggledInReservedItemSlots()
		{
			if (!Enabled)
			{
				return false;
			}
			return ReservedHotbarManager.isToggledInReservedSlots;
		}

		public static bool IsItemSlotReserved(int index)
		{
			if (!Enabled)
			{
				return false;
			}
			return ReservedPlayerData.localPlayerData.IsReservedItemSlot(index);
		}

		public static bool ShouldDisableEnergyBarsReservedItemSlots()
		{
			if (!Enabled)
			{
				return false;
			}
			try
			{
				return ConfigSettings.disableHotbarPlusEnergyBars.Value;
			}
			catch
			{
				return false;
			}
		}
	}
	internal static class TooManyEmotes_Compat
	{
		public static bool Enabled => Plugin.IsModLoaded("FlipMods.TooManyEmotes");

		public static bool IsLocalPlayerPerformingCustomEmote()
		{
			if ((Object)(object)EmoteControllerPlayer.emoteControllerLocal != (Object)null && ((EmoteController)EmoteControllerPlayer.emoteControllerLocal).IsPerformingCustomEmote())
			{
				return true;
			}
			return false;
		}

		public static bool CanMoveWhileEmoting()
		{
			return ThirdPersonEmoteController.allowMovingWhileEmoting;
		}
	}
}