Decompiled source of ReservedUtilitySlot v1.0.6

ReservedUtilitySlot.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ReservedItemSlotCore.Config;
using ReservedItemSlotCore.Data;
using ReservedUtilitySlot.Config;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ReservedUtilitySlot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ReservedUtilitySlot")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bdec4763-b8c7-4814-ad3d-43fa8d7ee121")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ReservedUtilitySlot
{
	[BepInPlugin("FlipMods.ReservedUtilitySlot", "ReservedUtilitySlot", "1.0.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance;

		private static ManualLogSource logger;

		private Harmony _harmony;

		public static ReservedItemSlotData mainUtilitySlotData;

		public static List<ReservedItemSlotData> allUtilitySlotData = new List<ReservedItemSlotData>();

		public static ReservedItemData ladderData;

		public static ReservedItemData lockpickerData;

		public static ReservedItemData jetpackData;

		public static ReservedItemData stunGrenadeData;

		public static ReservedItemData homemadeFlashbangData;

		public static ReservedItemData tzpInhalantData;

		public static ReservedItemData radarBoosterData;

		public static ReservedItemData weedKillerData;

		public static ReservedItemData remoteRadarData;

		public static ReservedItemData utilityBeltData;

		public static ReservedItemData hackingToolData;

		public static ReservedItemData pingerData;

		public static ReservedItemData portableTeleData;

		public static ReservedItemData advancedPortableTeleData;

		public static ReservedItemData peeperData;

		public static ReservedItemData medkitData;

		public static ReservedItemData binocularsData;

		public static ReservedItemData mapperData;

		public static List<ReservedItemData> additionalItemData = new List<ReservedItemData>();

		public static ReservedItemSlotData keySlotData;

		public static ReservedItemData keyData;

		public static List<ReservedItemData> additionalKeyItemData = new List<ReservedItemData>();

		private void Awake()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			instance = this;
			CreateCustomLogger();
			ConfigSettings.BindConfigSettings();
			CreateReservedItemSlots();
			CreateAdditionalReservedItemSlots();
			_harmony = new Harmony("ReservedUtilitySlot");
			PatchAll();
			Log("ReservedUtilitySlot loaded");
		}

		private void CreateReservedItemSlots()
		{
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Expected O, but got Unknown
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00c9: 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)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_0171: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_01ef: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: 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_0235: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: 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_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_026d: 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_0277: 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_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Expected O, but got Unknown
			//IL_0297: 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_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Expected O, but got Unknown
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: 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_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Expected O, but got Unknown
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Expected O, but got Unknown
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Expected O, but got Unknown
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Expected O, but got Unknown
			if (!ConfigSettings.disableUtilitySlot.Value)
			{
				for (int i = 0; i < ConfigSettings.numUtilitySlots.Value; i++)
				{
					string text = "utility" + ((i > 0) ? (i + 1).ToString() : "");
					ReservedItemSlotData val = ReservedItemSlotData.CreateReservedItemSlotData(text, ConfigSettings.overrideItemSlotPriority.Value + i, Mathf.Max(ConfigSettings.overridePurchasePrice.Value + ConfigSettings.overrideExtraAmmoSlotPriceIncrease.Value * i, 0));
					if (mainUtilitySlotData == null)
					{
						mainUtilitySlotData = val;
					}
					if (ladderData == null)
					{
						ladderData = val.AddItemToReservedItemSlot(new ReservedItemData("Extension ladder", (PlayerBone)0, default(Vector3), default(Vector3)));
						jetpackData = val.AddItemToReservedItemSlot(new ReservedItemData("Jetpack", (PlayerBone)0, default(Vector3), default(Vector3)));
						stunGrenadeData = val.AddItemToReservedItemSlot(new ReservedItemData("Stun grenade", (PlayerBone)0, default(Vector3), default(Vector3)));
						homemadeFlashbangData = val.AddItemToReservedItemSlot(new ReservedItemData("Homemade flashbang", (PlayerBone)0, default(Vector3), default(Vector3)));
						tzpInhalantData = val.AddItemToReservedItemSlot(new ReservedItemData("TZP-Inhalant", (PlayerBone)0, default(Vector3), default(Vector3)));
						radarBoosterData = val.AddItemToReservedItemSlot(new ReservedItemData("Radar-booster", (PlayerBone)0, default(Vector3), default(Vector3)));
						lockpickerData = val.AddItemToReservedItemSlot(new ReservedItemData("Lockpicker", (PlayerBone)0, default(Vector3), default(Vector3)));
						weedKillerData = val.AddItemToReservedItemSlot(new ReservedItemData("Weed killer", (PlayerBone)0, default(Vector3), default(Vector3)));
						remoteRadarData = val.AddItemToReservedItemSlot(new ReservedItemData("Remote Radar", (PlayerBone)0, default(Vector3), default(Vector3)));
						utilityBeltData = val.AddItemToReservedItemSlot(new ReservedItemData("Utility Belt", (PlayerBone)0, default(Vector3), default(Vector3)));
						hackingToolData = val.AddItemToReservedItemSlot(new ReservedItemData("Hacking Tool", (PlayerBone)0, default(Vector3), default(Vector3)));
						pingerData = val.AddItemToReservedItemSlot(new ReservedItemData("Pinger", (PlayerBone)0, default(Vector3), default(Vector3)));
						portableTeleData = val.AddItemToReservedItemSlot(new ReservedItemData("Portable Tele", (PlayerBone)0, default(Vector3), default(Vector3)));
						advancedPortableTeleData = val.AddItemToReservedItemSlot(new ReservedItemData("Advanced Portable Tele", (PlayerBone)0, default(Vector3), default(Vector3)));
						peeperData = val.AddItemToReservedItemSlot(new ReservedItemData("Peeper", (PlayerBone)0, default(Vector3), default(Vector3)));
						medkitData = val.AddItemToReservedItemSlot(new ReservedItemData("Medkit", (PlayerBone)0, default(Vector3), default(Vector3)));
						binocularsData = val.AddItemToReservedItemSlot(new ReservedItemData("Binoculars", (PlayerBone)0, default(Vector3), default(Vector3)));
						mapperData = val.AddItemToReservedItemSlot(new ReservedItemData("Mapper", (PlayerBone)0, default(Vector3), default(Vector3)));
					}
					else
					{
						val.AddItemToReservedItemSlot(ladderData);
						val.AddItemToReservedItemSlot(jetpackData);
						val.AddItemToReservedItemSlot(stunGrenadeData);
						val.AddItemToReservedItemSlot(homemadeFlashbangData);
						val.AddItemToReservedItemSlot(tzpInhalantData);
						val.AddItemToReservedItemSlot(radarBoosterData);
						val.AddItemToReservedItemSlot(lockpickerData);
						val.AddItemToReservedItemSlot(weedKillerData);
						val.AddItemToReservedItemSlot(remoteRadarData);
						val.AddItemToReservedItemSlot(utilityBeltData);
						val.AddItemToReservedItemSlot(hackingToolData);
						val.AddItemToReservedItemSlot(pingerData);
						val.AddItemToReservedItemSlot(portableTeleData);
						val.AddItemToReservedItemSlot(advancedPortableTeleData);
						val.AddItemToReservedItemSlot(peeperData);
						val.AddItemToReservedItemSlot(medkitData);
						val.AddItemToReservedItemSlot(binocularsData);
						val.AddItemToReservedItemSlot(mapperData);
					}
					allUtilitySlotData.Add(val);
				}
			}
			if (!ConfigSettings.addKeySlot.Value)
			{
				return;
			}
			keySlotData = ReservedItemSlotData.CreateReservedItemSlotData("key_slot", ConfigSettings.overrideKeySlotPriority.Value, ConfigSettings.overrideKeySlotPrice.Value);
			keyData = keySlotData.AddItemToReservedItemSlot(new ReservedItemData("Key", (PlayerBone)0, default(Vector3), default(Vector3)));
			if (ConfigSettings.moveLockpickerToKeySlot.Value)
			{
				if (!ConfigSettings.disableUtilitySlot.Value)
				{
					keySlotData.AddItemToReservedItemSlot(lockpickerData);
					mainUtilitySlotData.RemoveItemFromReservedItemSlot(lockpickerData.itemName);
				}
				else
				{
					keySlotData.AddItemToReservedItemSlot(new ReservedItemData("Lockpicker", (PlayerBone)0, default(Vector3), default(Vector3)));
				}
			}
		}

		private void CreateAdditionalReservedItemSlots()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: 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_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			string[] array = ConfigSettings.ParseAdditionalItems();
			string[] array2 = array;
			foreach (string text in array2)
			{
				if (mainUtilitySlotData.ContainsItem(text))
				{
					continue;
				}
				LogWarning("Adding additional item to reserved item slot. Item: " + text);
				ReservedItemData val = new ReservedItemData(text, (PlayerBone)0, default(Vector3), default(Vector3));
				additionalItemData.Add(val);
				foreach (ReservedItemSlotData allUtilitySlotDatum in allUtilitySlotData)
				{
					if (!allUtilitySlotDatum.ContainsItem(text))
					{
						allUtilitySlotDatum.AddItemToReservedItemSlot(val);
					}
				}
			}
			string[] array3 = ConfigSettings.ParseRemoveItems();
			string[] array4 = array3;
			foreach (string text2 in array4)
			{
				if (!mainUtilitySlotData.ContainsItem(text2))
				{
					continue;
				}
				LogWarning("Removing item from reserved item slot. Item: " + text2);
				foreach (ReservedItemSlotData allUtilitySlotDatum2 in allUtilitySlotData)
				{
					if (allUtilitySlotDatum2.ContainsItem(text2))
					{
						allUtilitySlotDatum2.RemoveItemFromReservedItemSlot(text2);
					}
				}
			}
			if (keySlotData == null)
			{
				return;
			}
			string[] array5 = ConfigSettings.ParseAdditionalKeyItems();
			string[] array6 = array5;
			foreach (string text3 in array6)
			{
				if (!keySlotData.ContainsItem(text3))
				{
					LogWarning("Adding additional item to reserved key item slot. Item: " + text3);
					ReservedItemData val2 = new ReservedItemData(text3, (PlayerBone)0, default(Vector3), default(Vector3));
					additionalKeyItemData.Add(val2);
					keySlotData.AddItemToReservedItemSlot(val2);
				}
			}
		}

		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(string.Format("{0}-{1}", "ReservedUtilitySlot", "1.0.6"));
			}
			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.ReservedUtilitySlot";

		public const string PLUGIN_NAME = "ReservedUtilitySlot";

		public const string PLUGIN_VERSION = "1.0.6";
	}
}
namespace ReservedUtilitySlot.Config
{
	public static class ConfigSettings
	{
		public static ConfigEntry<int> numUtilitySlots;

		public static ConfigEntry<int> overrideItemSlotPriority;

		public static ConfigEntry<int> overridePurchasePrice;

		public static ConfigEntry<int> overrideExtraAmmoSlotPriceIncrease;

		public static ConfigEntry<string> additionalItemsInSlot;

		public static ConfigEntry<string> removeItemsFromSlot;

		public static ConfigEntry<bool> disableUtilitySlot;

		public static ConfigEntry<bool> addKeySlot;

		public static ConfigEntry<int> overrideKeySlotPriority;

		public static ConfigEntry<int> overrideKeySlotPrice;

		public static ConfigEntry<string> addAdditionalItemsToKeySlot;

		public static ConfigEntry<bool> moveLockpickerToKeySlot;

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

		public static void BindConfigSettings()
		{
			Plugin.Log("BindingConfigs");
			numUtilitySlots = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "NumUtilitySlots", 1, "[Host only] Sets the amount of reserved utility slots. Consider changing the priority if the priority of additional utility slots conflicts with other slots."));
			overrideItemSlotPriority = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "UtilitySlotPriorityOverride", 80, "[Host only] Manually set the priority for this item slot. Higher priority slots will come first in the reserved item slots, which will appear below the other slots. Negative priority items will appear on the left side of the screen, this is disabled in the core mod's config."));
			overridePurchasePrice = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "UtilitySlotPriceOverride", 200, "[Host only] Manually set the price for this item in the store. Setting 0 will force this item to be unlocked immediately after the game starts."));
			overrideExtraAmmoSlotPriceIncrease = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "ExtraUtilitySlotsPriceIncreaseOverride", 20, "[Host only] If multiple utility slots are added, and purchasing slots is enabled, the price for each additional utility slot will go up by this amount."));
			additionalItemsInSlot = AddConfigEntry<string>(((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Server-side", "AdditionalItemsInSlot", "", "[Host only] Syntax: \"Item1,Item name2\" (without quotes). When adding items, use the item's name as it appears in game. Include spaces if there are spaces in the item name. Adding items that do not exist, or that are from a mod which is not enabled will not cause any problems. As of now, additional items added to reserved item slots cannot be seen on players while holstered.\nNOTE: IF YOU ARE USING A TRANSLATION MOD, YOU MAY NEED TO ADD THE TRANSLATED NAME OF ANY ITEM YOU WANT IN THIS SLOT."));
			removeItemsFromSlot = AddConfigEntry<string>(((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Server-side", "RemoveItemsFromSlot", "", "[Host only] Syntax: \"Item1,Item name2\" (without quotes). Removes the specified items from this reserved item slot.When removing items, use the item's name as it appears in game. Include spaces if there are spaces in the item name. Adding items that do not exist, or that are from a mod which is not enabled will not cause any problems.\nCURRENT ITEMS IN SLOT: \"Extension ladder\", \"Lockpicker\", \"Jetpack\", \"Stun grenade\", \"Homemade flashbang\", \"TZP-Inhalant\", \"Radar-booster\", \"Remote Radar\", \"Utility Belt\", \"Hacking Tool\", \"Pinger\", \"Portable Tele\", \"Advanced Portable Tele\", \"Peeper\", \"Medkit\", \"Binoculars\", \"Mapper\", \"Toothpaste\" (you got a problem with toothpaste??)"));
			disableUtilitySlot = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Server-side", "DisableUtilitySlot", false, "[Host only] Disables the utility slot. Use this if you only want the reserved key slot."));
			addKeySlot = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Server-side", "AddKeySlot", false, "[Host only] Adds a reserved item slot for the key item. By default, the slot will appear on the left side of the screen, unless given a positive item slot priority."));
			overrideKeySlotPriority = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "KeySlotPriorityOverride", -40, "[Host only] Manually set the priority for the key item slot. Higher priority slots will come first in the reserved item slots, which will appear below the other slots. Negative priority items will appear on the left side of the screen, this is disabled in the core mod's config."));
			overrideKeySlotPrice = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Server-side", "KeySlotPriceOverride", 50, "[Host only] Manually set the price for the key item in the store. Setting 0 will force this item to be unlocked immediately after the game starts."));
			moveLockpickerToKeySlot = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Server-side", "MoveLockpickerToKeySlot", false, "[Host only] Moves the lockpicker to the key slot. This setting will do nothing if the reserved key slot is disabled in the config."));
			addAdditionalItemsToKeySlot = AddConfigEntry<string>(((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("Server-side", "AdditionalItemsInKeySlot", "", "[Host only] Syntax: \"Item1,Item name2\" (without quotes). When adding items, use the item's name as it appears in game. Include spaces if there are spaces in the item name. Adding items that do not exist, or that are from a mod which is not enabled will not cause any problems.\nNOTE: IF YOU ARE USING A TRANSLATION MOD, YOU MAY NEED TO ADD THE TRANSLATED NAME OF ANY ITEM YOU WANT IN THIS SLOT."));
			additionalItemsInSlot.Value = additionalItemsInSlot.Value.Replace(", ", ",");
			removeItemsFromSlot.Value = removeItemsFromSlot.Value.Replace(", ", ",");
			TryRemoveOldConfigSettings();
		}

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

		public static string[] ParseAdditionalItems()
		{
			return ConfigSettings.ParseItemNames(additionalItemsInSlot.Value);
		}

		public static string[] ParseRemoveItems()
		{
			return ConfigSettings.ParseItemNames(removeItemsFromSlot.Value);
		}

		public static string[] ParseAdditionalKeyItems()
		{
			return ConfigSettings.ParseItemNames(addAdditionalItemsToKeySlot.Value);
		}

		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
			{
			}
		}
	}
}