Decompiled source of FurtherUpgrades v1.1.2

FurtherUpgrades.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Utils;
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("FurtherUpgrades")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FurtherUpgrades")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace FurtherUpgrades;

public static class Configs
{
	public static ConfigEntry<bool> EnableCompatibilityWithWarfareMods;

	public static ConfigEntry<int> MaterialsRequiredPerLevel;

	public static ConfigEntry<int> UpgradeRequiredLevelDivisor;

	public static ConfigEntry<int> BlackForge;

	public static ConfigEntry<int> Forge;

	public static ConfigEntry<int> GaldrTable;

	public static ConfigEntry<int> Workbench;

	public static ConfigEntry<int> ArmorChests;

	public static ConfigEntry<int> ArmorHelmets;

	public static ConfigEntry<int> ArmorLegs;

	public static ConfigEntry<int> ArmorShoulders;

	public static ConfigEntry<int> Axes;

	public static ConfigEntry<int> Bows;

	public static ConfigEntry<int> Clubs;

	public static ConfigEntry<int> Crossbows;

	public static ConfigEntry<int> Knives;

	public static ConfigEntry<int> Pickaxes;

	public static ConfigEntry<int> Polearms;

	public static ConfigEntry<int> Shields;

	public static ConfigEntry<int> Spears;

	public static ConfigEntry<int> StavesBlood;

	public static ConfigEntry<int> StavesElemental;

	public static ConfigEntry<int> Swords;

	public static ConfigEntry<int> Tools;

	public static ConfigEntry<int> Unarmed;

	public static ConfigEntry<string> CustomItemList;

	public static ConfigEntry<string> IgnoreItemList;

	public static ConfigEntry<string> CustomStations;

	public static ConfigurationManagerAttributes IsAdminOnly = new ConfigurationManagerAttributes
	{
		IsAdminOnly = true
	};

	public static ConfigurationManagerAttributes IsAdminOnlyAndAdvanced = new ConfigurationManagerAttributes
	{
		IsAdminOnly = true,
		IsAdvanced = true
	};

	public static void SetupConfigs(ConfigFile config)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Expected O, but got Unknown
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Expected O, but got Unknown
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Expected O, but got Unknown
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Expected O, but got Unknown
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Expected O, but got Unknown
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Expected O, but got Unknown
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Expected O, but got Unknown
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Expected O, but got Unknown
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Expected O, but got Unknown
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Expected O, but got Unknown
		//IL_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_0352: Expected O, but got Unknown
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Expected O, but got Unknown
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c8: Expected O, but got Unknown
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0403: Expected O, but got Unknown
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_043e: Expected O, but got Unknown
		//IL_046f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0479: Expected O, but got Unknown
		//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b4: Expected O, but got Unknown
		//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ef: Expected O, but got Unknown
		//IL_0519: Unknown result type (might be due to invalid IL or missing references)
		//IL_0523: Expected O, but got Unknown
		//IL_054d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0557: Expected O, but got Unknown
		//IL_0581: Unknown result type (might be due to invalid IL or missing references)
		//IL_058b: Expected O, but got Unknown
		//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bf: Expected O, but got Unknown
		//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ed: Expected O, but got Unknown
		//IL_0609: Unknown result type (might be due to invalid IL or missing references)
		//IL_0613: Expected O, but got Unknown
		//IL_063b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0641: Expected O, but got Unknown
		//IL_065d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0667: Expected O, but got Unknown
		//IL_068f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0695: Expected O, but got Unknown
		//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06bb: Expected O, but got Unknown
		EnableCompatibilityWithWarfareMods = config.Bind<bool>("General", GenerateConfigKey("EnableCompatibilityWithWarfareMods"), true, new ConfigDescription("Enable compatibility with 'Warfare' mods by replacing their modified method that obtains the required station level for upgrading an item. Disable this in case of issues.", (AcceptableValueBase)null, new object[1] { IsAdminOnly }));
		MaterialsRequiredPerLevel = config.Bind<int>("General", GenerateConfigKey("MaterialsRequiredPerLevel", "%"), 50, new ConfigDescription("Determines the amount of materials required per level (compared to the default game values). Only applicable to items with a modified maximum level.", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[10] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 }), new object[1] { IsAdminOnly }));
		UpgradeRequiredLevelDivisor = config.Bind<int>("General", GenerateConfigKey("UpgradeRequiredLevelDivisor"), 1, new ConfigDescription("Determines how many times an item can be upgraded per one station extension level (e.g. a value of '2' would mean that an item will require a new extension every 2 upgrades, not 1 as per default).", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[3] { 1, 2, 3 }), new object[1] { IsAdminOnly }));
		ArmorChests = config.Bind<int>("Max Item Levels", GenerateConfigKey("ArmorChests"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		ArmorHelmets = config.Bind<int>("Max Item Levels", GenerateConfigKey("ArmorHelmets"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		ArmorLegs = config.Bind<int>("Max Item Levels", GenerateConfigKey("ArmorLegs"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		ArmorShoulders = config.Bind<int>("Max Item Levels", GenerateConfigKey("ArmorLegs"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Axes = config.Bind<int>("Max Item Levels", GenerateConfigKey("Axes"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Bows = config.Bind<int>("Max Item Levels", GenerateConfigKey("Bows"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Clubs = config.Bind<int>("Max Item Levels", GenerateConfigKey("Clubs"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Crossbows = config.Bind<int>("Max Item Levels", GenerateConfigKey("Crossbows"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Knives = config.Bind<int>("Max Item Levels", GenerateConfigKey("Knives"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Pickaxes = config.Bind<int>("Max Item Levels", GenerateConfigKey("Pickaxes"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Polearms = config.Bind<int>("Max Item Levels", GenerateConfigKey("Polearms"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Shields = config.Bind<int>("Max Item Levels", GenerateConfigKey("Shields"), 5, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Spears = config.Bind<int>("Max Item Levels", GenerateConfigKey("Spears"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		StavesBlood = config.Bind<int>("Max Item Levels", GenerateConfigKey("StavesBlood"), 0, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		StavesElemental = config.Bind<int>("Max Item Levels", GenerateConfigKey("StavesElemental"), 0, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Swords = config.Bind<int>("Max Item Levels", GenerateConfigKey("Swords"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Tools = config.Bind<int>("Max Item Levels", GenerateConfigKey("Tools"), 5, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		Unarmed = config.Bind<int>("Max Item Levels", GenerateConfigKey("Unarmed"), 7, new ConfigDescription("Determines the maximum level this type of item can be upgraded to. Enter '0' to use the game default value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), new object[1] { IsAdminOnly }));
		BlackForge = config.Bind<int>("Max Station Levels", GenerateConfigKey("BlackForge"), 5, new ConfigDescription("An item upgrade requiring a station level higher than this value will be capped to this level (e.g. upgrading an armor piece to level 10 will require only up to the specified station level). This value should ideally reflect the highest possible obtainable station level in the game. Enter '0' to disable the cap.", (AcceptableValueBase)null, new object[1] { IsAdminOnlyAndAdvanced }));
		Forge = config.Bind<int>("Max Station Levels", GenerateConfigKey("Forge"), 7, new ConfigDescription("An item upgrade requiring a station level higher than this value will be capped to this level (e.g. upgrading an armor piece to level 10 will require only up to the specified station level). This value should ideally reflect the highest possible obtainable station level in the game. Enter '0' to disable the cap.", (AcceptableValueBase)null, new object[1] { IsAdminOnlyAndAdvanced }));
		GaldrTable = config.Bind<int>("Max Station Levels", GenerateConfigKey("GaldrTable"), 4, new ConfigDescription("An item upgrade requiring a station level higher than this value will be capped to this level (e.g. upgrading an armor piece to level 10 will require only up to the specified station level). This value should ideally reflect the highest possible obtainable station level in the game. Enter '0' to disable the cap.", (AcceptableValueBase)null, new object[1] { IsAdminOnlyAndAdvanced }));
		Workbench = config.Bind<int>("Max Station Levels", GenerateConfigKey("Workbench"), 5, new ConfigDescription("An item upgrade requiring a station level higher than this value will be capped to this level (e.g. upgrading an armor piece to level 10 will require only up to the specified station level). This value should ideally reflect the highest possible obtainable station level in the game. Enter '0' to disable the cap.", (AcceptableValueBase)null, new object[1] { IsAdminOnlyAndAdvanced }));
		string text = GenerateConfigKey("CustomItemList");
		string empty = string.Empty;
		object[] array = new object[1];
		ConfigurationManagerAttributes val = new ConfigurationManagerAttributes();
		val.IsAdminOnly = true;
		val.CustomDrawer = TextAreaDrawer;
		array[0] = val;
		CustomItemList = config.Bind<string>("Specific Items", text, empty, new ConfigDescription("Sets max levels for specific items (overrides the generic categories). Format: item_token_1:max_level,item_token_2:max_level,(...). Example: $item_spear_bronze:10,$item_bow_finewood:20 (bronze spear will be upgradable to level 10, and finewood bow to level 20). Please refer to https://valheim-modding.github.io/Jotunn/data/objects/item-list.html for a list of tokens. Prefabs should also work (instead of tokens).", (AcceptableValueBase)null, array));
		string text2 = GenerateConfigKey("IgnoreItemList");
		string empty2 = string.Empty;
		object[] array2 = new object[1];
		val = new ConfigurationManagerAttributes();
		val.IsAdminOnly = true;
		val.CustomDrawer = TextAreaDrawer;
		array2[0] = val;
		IgnoreItemList = config.Bind<string>("Specific Items", text2, empty2, new ConfigDescription("Keeps the vanilla default maximum level for the specified items (overrides the generic categories). Format: item_token_1,item_token_2,(...). Example: $item_spear_bronze,$item_bow_finewood (bronze spear and finewood bow will be upgradable to the default maximum value, which should be 4, regardless of the global settings for bows and spears). Please refer to https://valheim-modding.github.io/Jotunn/data/objects/item-list.html for a list of tokens. Prefabs should also work (instead of tokens).", (AcceptableValueBase)null, array2));
		string text3 = GenerateConfigKey("CustomStations");
		object[] array3 = new object[1];
		val = new ConfigurationManagerAttributes();
		val.IsAdminOnly = true;
		val.CustomDrawer = TextAreaDrawer;
		array3[0] = val;
		CustomStations = config.Bind<string>("Specific Stations", text3, "FletcherTable_TW:5", new ConfigDescription("Allows items that require a custom/modded crafting station to also be upgraded past their default maximum level. Format: station_token_1:max_level,station_token_2:max_level,(...). Example: $piece_workbench:2,$piece_forge:2 (these stations will only require a maximum level of 2, meaning, one extension only, to upgrade items past level 2). It is recommended that you specify the default maximum possible levels that you can obtain with these stations by using extensions. Prefabs should also work (instead of tokens).", (AcceptableValueBase)null, array3));
	}

	public static string GenerateConfigKey(string key)
	{
		return GenerateConfigKey(key, null);
	}

	public static string GenerateConfigKey(string key, string unit)
	{
		key = string.Concat(key.Select((char x) => char.IsUpper(x) ? (" " + x) : x.ToString())).TrimStart(new char[1] { ' ' });
		if (!string.IsNullOrEmpty(unit))
		{
			key += $" ({unit})";
		}
		return key;
	}

	public static ConfigurationManagerAttributes SetOrder(int order, bool isAdminOnly = true)
	{
		//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_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		return new ConfigurationManagerAttributes
		{
			Order = order,
			IsAdminOnly = isAdminOnly
		};
	}

	private static void TextAreaDrawer(ConfigEntryBase entry)
	{
		GUILayout.ExpandHeight(true);
		GUILayout.ExpandWidth(true);
		entry.BoxedValue = GUILayout.TextArea((string)entry.BoxedValue, (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.ExpandWidth(true),
			GUILayout.ExpandHeight(true)
		});
	}
}
[BepInPlugin("FurtherUpgrades", "FurtherUpgrades", "1.1.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class FurtherUpgrades : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Recipe), "GetRequiredStationLevel")]
	public class Recipe_GetRequiredStationLevel_Patch
	{
		public static bool Prefix(Recipe __instance, int quality, ref int __result)
		{
			if (!hasWarfareMod.HasValue)
			{
				hasWarfareMod = Harmony.HasAnyPatches("Therzie.Warfare") || Harmony.HasAnyPatches("Therzie.WarfareFireAndIce");
				if (hasWarfareMod.Value && Configs.EnableCompatibilityWithWarfareMods.Value)
				{
					harmony.Unpatch((MethodBase)AccessTools.Method(typeof(Recipe), "GetRequiredStationLevel", (Type[])null, (Type[])null), (HarmonyPatchType)2, "org.bepinex.helpers.ItemManager");
					Logger.LogInfo((object)"Unpatched method 'GetRequiredStationLevel' from 'org.bepinex.helpers.ItemManager' used by mods 'Therzie.Warfare' and 'Therzie.WarfareFireAndIce'.");
				}
			}
			CraftingStation craftingStation = __instance.GetRequiredStation(quality);
			if ((Object)(object)craftingStation != (Object)null)
			{
				int num = Mathf.CeilToInt((float)quality / (float)Configs.UpgradeRequiredLevelDivisor.Value) + (__instance.m_minStationLevel - 1);
				if (craftingStation.m_name == "$piece_workbench")
				{
					if (Configs.Workbench.Value > 0 && num > Configs.Workbench.Value)
					{
						__result = Configs.Workbench.Value;
						return false;
					}
				}
				else if (craftingStation.m_name == "$piece_forge")
				{
					if (Configs.Forge.Value > 0 && num > Configs.Forge.Value)
					{
						__result = Configs.Forge.Value;
						return false;
					}
				}
				else if (craftingStation.m_name == "$piece_blackforge")
				{
					if (Configs.BlackForge.Value > 0 && num > Configs.BlackForge.Value)
					{
						__result = Configs.BlackForge.Value;
						return false;
					}
				}
				else if (craftingStation.m_name == "$piece_magetable")
				{
					if (Configs.GaldrTable.Value > 0 && num > Configs.GaldrTable.Value)
					{
						__result = Configs.GaldrTable.Value;
						return false;
					}
				}
				else
				{
					KeyValuePair<string, int> keyValuePair = CustomStations.FirstOrDefault((KeyValuePair<string, int> x) => ((Object)((Component)craftingStation).gameObject).name.StartsWith(x.Key) || craftingStation.m_name == x.Key);
					if (keyValuePair.Key != null && num > keyValuePair.Value)
					{
						__result = keyValuePair.Value;
						return false;
					}
				}
				__result = num;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static class ItemDrop_Awake_Patch
	{
		private static void Postfix(ItemDrop __instance)
		{
			ApplyItemCustomChanges(__instance);
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	private static class ItemDrop_SlowUpdate_Patch
	{
		private static void Postfix(ref ItemDrop __instance)
		{
			ApplyItemCustomChanges(__instance);
		}
	}

	public const string PluginGUID = "FurtherUpgrades";

	public const string PluginName = "FurtherUpgrades";

	public const string PluginVersion = "1.1.2";

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

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

	public static readonly List<string> IgnoredItems = new List<string>();

	private static readonly List<string> modifiedItems = new List<string>();

	private static bool? hasWarfareMod;

	private static Harmony harmony;

	private void Awake()
	{
		Configs.SetupConfigs(((BaseUnityPlugin)this).Config);
		LoadCustomStations();
		LoadCustomItemList();
		LoadIgnoreItemList();
		harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "FurtherUpgrades");
	}

	private void OnDestroy()
	{
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchSelf();
		}
	}

	public static void LoadCustomStations()
	{
		if (string.IsNullOrEmpty(Configs.CustomStations.Value))
		{
			return;
		}
		string[] array = Configs.CustomStations.Value.Split(new char[1] { ',' });
		string[] array2 = array;
		foreach (string text in array2)
		{
			string[] array3 = text.Trim().Split(new char[1] { ':' });
			if (array3.Length < 2)
			{
				Logger.LogError((object)"Custom Stations not in the expected format. Please see the documentation and adhere to the correct format.");
				CustomStations.Clear();
				return;
			}
			string text2 = array3[0].Trim();
			int result;
			bool flag = int.TryParse(array3[1].Trim(), out result);
			if (text2.Length == 0 || !flag)
			{
				Logger.LogError((object)"Custom Stations not in the expected format. Please see the documentation and adhere to the correct format.");
				CustomStations.Clear();
				return;
			}
			if (result <= 0)
			{
				Logger.LogError((object)"Max Station Level cannot be equal or lower than 0.");
				CustomStations.Clear();
				return;
			}
			CustomStations.Add(text2, result);
		}
		Logger.LogInfo((object)"Custom Stations loaded successfully.");
	}

	public static void LoadCustomItemList()
	{
		if (string.IsNullOrEmpty(Configs.CustomItemList.Value))
		{
			return;
		}
		string[] array = Configs.CustomItemList.Value.Split(new char[1] { ',' });
		string[] array2 = array;
		foreach (string text in array2)
		{
			string[] array3 = text.Trim().Split(new char[1] { ':' });
			if (array3.Length < 2)
			{
				Logger.LogError((object)"Custom Item List not in the expected format. Please see the documentation and adhere to the correct format.");
				CustomItems.Clear();
				return;
			}
			string text2 = array3[0].Trim();
			int result;
			bool flag = int.TryParse(array3[1].Trim(), out result);
			if (text2.Length == 0 || !flag)
			{
				Logger.LogError((object)"Custom Item List not in the expected format. Please see the documentation and adhere to the correct format.");
				CustomItems.Clear();
				return;
			}
			if (result <= 0)
			{
				Logger.LogError((object)"Max Item Level cannot be equal or lower than 0.");
				CustomItems.Clear();
				return;
			}
			CustomItems.Add(text2, result);
		}
		Logger.LogInfo((object)"Custom Item List loaded successfully.");
	}

	public static void LoadIgnoreItemList()
	{
		if (string.IsNullOrEmpty(Configs.IgnoreItemList.Value))
		{
			return;
		}
		string[] array = Configs.IgnoreItemList.Value.Split(new char[1] { ',' });
		string[] array2 = array;
		foreach (string text in array2)
		{
			if (string.IsNullOrEmpty(text))
			{
				Logger.LogError((object)"Ignore Item List not in the expected format. Please see the documentation and adhere to the correct format.");
				IgnoredItems.Clear();
				return;
			}
			IgnoredItems.Add(text.Trim());
		}
		Logger.LogInfo((object)"Ignore Item List loaded successfully.");
	}

	private static void ApplyItemCustomChanges(ItemDrop item)
	{
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Invalid comparison between Unknown and I4
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Invalid comparison between Unknown and I4
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Invalid comparison between Unknown and I4
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Invalid comparison between Unknown and I4
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Invalid comparison between Unknown and I4
		//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f6: Invalid comparison between Unknown and I4
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Invalid comparison between Unknown and I4
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Invalid comparison between Unknown and I4
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Invalid comparison between Unknown and I4
		//IL_0530: Unknown result type (might be due to invalid IL or missing references)
		//IL_0536: Invalid comparison between Unknown and I4
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Invalid comparison between Unknown and I4
		//IL_0570: Unknown result type (might be due to invalid IL or missing references)
		//IL_0577: Invalid comparison between Unknown and I4
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Invalid comparison between Unknown and I4
		//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b7: Invalid comparison between Unknown and I4
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Invalid comparison between Unknown and I4
		//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f8: Invalid comparison between Unknown and I4
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Invalid comparison between Unknown and I4
		//IL_062f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0636: Invalid comparison between Unknown and I4
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Invalid comparison between Unknown and I4
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Invalid comparison between Unknown and I4
		//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Invalid comparison between Unknown and I4
		//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f4: Invalid comparison between Unknown and I4
		//IL_042e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Invalid comparison between Unknown and I4
		//IL_046e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0474: Invalid comparison between Unknown and I4
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b5: Invalid comparison between Unknown and I4
		SharedData info = item.m_itemData.m_shared;
		if (IgnoredItems.Contains(info.m_name) || ((Object)(object)item.m_itemData.m_dropPrefab != (Object)null && IgnoredItems.Contains(((Object)item.m_itemData.m_dropPrefab).name)))
		{
			return;
		}
		string text = CustomItems.Keys.FirstOrDefault((string x) => x == info.m_name);
		if (text == null && (Object)(object)item.m_itemData.m_dropPrefab != (Object)null)
		{
			text = CustomItems.Keys.FirstOrDefault((string x) => x == ((Object)item.m_itemData.m_dropPrefab).name);
		}
		if (text == null)
		{
			if (info.m_maxQuality <= 1)
			{
				return;
			}
			if ((int)info.m_itemType == 4)
			{
				if ((int)info.m_skillType == 8 && Configs.Bows.Value > 0)
				{
					UpdateItemData(item, Configs.Bows.Value);
					return;
				}
				if ((int)info.m_skillType == 14 && Configs.Crossbows.Value > 0)
				{
					UpdateItemData(item, Configs.Crossbows.Value);
					return;
				}
			}
			if ((int)info.m_itemType == 3 || (int)info.m_itemType == 14 || (int)info.m_itemType == 22 || (int)info.m_itemType == 15)
			{
				if ((int)info.m_skillType == 7 && Configs.Axes.Value > 0)
				{
					UpdateItemData(item, Configs.Axes.Value);
					return;
				}
				if ((int)info.m_skillType == 10 && Configs.StavesBlood.Value > 0)
				{
					UpdateItemData(item, Configs.StavesBlood.Value);
					return;
				}
				if ((int)info.m_skillType == 8 && Configs.Bows.Value > 0)
				{
					UpdateItemData(item, Configs.Bows.Value);
					return;
				}
				if ((int)info.m_skillType == 3 && Configs.Clubs.Value > 0)
				{
					UpdateItemData(item, Configs.Clubs.Value);
					return;
				}
				if ((int)info.m_skillType == 14 && Configs.Crossbows.Value > 0)
				{
					UpdateItemData(item, Configs.Crossbows.Value);
					return;
				}
				if ((int)info.m_skillType == 9 && Configs.StavesElemental.Value > 0)
				{
					UpdateItemData(item, Configs.StavesElemental.Value);
					return;
				}
				if ((int)info.m_skillType == 2 && Configs.Knives.Value > 0)
				{
					UpdateItemData(item, Configs.Knives.Value);
					return;
				}
				if ((int)info.m_skillType == 12 && Configs.Pickaxes.Value > 0)
				{
					UpdateItemData(item, Configs.Pickaxes.Value);
					return;
				}
				if ((int)info.m_skillType == 4 && Configs.Polearms.Value > 0)
				{
					UpdateItemData(item, Configs.Polearms.Value);
					return;
				}
				if ((int)info.m_skillType == 5 && Configs.Spears.Value > 0)
				{
					UpdateItemData(item, Configs.Spears.Value);
					return;
				}
				if ((int)info.m_skillType == 1 && Configs.Swords.Value > 0)
				{
					UpdateItemData(item, Configs.Swords.Value);
					return;
				}
				if ((int)info.m_skillType == 11 && Configs.Unarmed.Value > 0)
				{
					UpdateItemData(item, Configs.Unarmed.Value);
					return;
				}
			}
			if ((int)info.m_itemType == 7 && Configs.ArmorChests.Value > 0)
			{
				UpdateItemData(item, Configs.ArmorChests.Value);
			}
			else if ((int)info.m_itemType == 6 && Configs.ArmorHelmets.Value > 0)
			{
				UpdateItemData(item, Configs.ArmorHelmets.Value);
			}
			else if ((int)info.m_itemType == 11 && Configs.ArmorLegs.Value > 0)
			{
				UpdateItemData(item, Configs.ArmorLegs.Value);
			}
			else if ((int)info.m_itemType == 5 && Configs.Shields.Value > 0)
			{
				UpdateItemData(item, Configs.Shields.Value);
			}
			else if ((int)info.m_itemType == 17 && Configs.ArmorShoulders.Value > 0)
			{
				UpdateItemData(item, Configs.ArmorShoulders.Value);
			}
			else if ((int)info.m_itemType == 19 && Configs.Tools.Value > 0)
			{
				UpdateItemData(item, Configs.Tools.Value);
			}
		}
		else
		{
			UpdateItemData(item, CustomItems[text]);
		}
	}

	private static void UpdateItemData(ItemDrop item, int maxQuality)
	{
		if (!((Object)(object)ObjectDB.instance != (Object)null) || ObjectDB.instance.m_recipes == null || modifiedItems.Contains(item.m_itemData.m_shared.m_name))
		{
			return;
		}
		Recipe val = ((IEnumerable<Recipe>)ObjectDB.instance.m_recipes).FirstOrDefault((Func<Recipe, bool>)((Recipe x) => x.m_item?.m_itemData.m_shared.m_name == item.m_itemData.m_shared.m_name));
		if (!((Object)(object)val != (Object)null))
		{
			return;
		}
		val.m_item.m_itemData.m_shared.m_maxQuality = (item.m_itemData.m_shared.m_maxQuality = maxQuality);
		bool flag = false;
		Requirement[] resources = val.m_resources;
		foreach (Requirement val2 in resources)
		{
			if (val2.m_amountPerLevel > 0)
			{
				if (val2.m_amountPerLevel > 1)
				{
					val2.m_amountPerLevel = Math.Max(Mathf.FloorToInt((float)val2.m_amountPerLevel * ((float)Configs.MaterialsRequiredPerLevel.Value / 100f)), 1);
				}
				flag = true;
			}
		}
		if (!flag)
		{
			Requirement[] resources2 = val.m_resources;
			foreach (Requirement val3 in resources2)
			{
				if (val3.m_amount > 1)
				{
					val3.m_amountPerLevel = Math.Max(Mathf.FloorToInt((float)val3.m_amount * 0.5f * ((float)Configs.MaterialsRequiredPerLevel.Value / 100f)), 1);
				}
			}
		}
		modifiedItems.Add(item.m_itemData.m_shared.m_name);
	}
}