Decompiled source of MasterCrafting v1.0.3

MasterCrafting.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using MasterCrafting;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MasterCrafting")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod that adds an Artisanship skill granting permanent stat bonuses to crafted items")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("MasterCrafting")]
[assembly: AssemblyTitle("MasterCrafting")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[HarmonyPatch]
internal class MasterCraftingPatches
{
	private const string MasterCraftingPowerKey = "MasterCrafting_Power";

	private const string MasterCraftingEffectKey = "MasterCrafting_Effect";

	private static readonly Dictionary<string, int> CraftingStationXP = new Dictionary<string, int>
	{
		{ "piece_workbench", 22 },
		{ "forge", 45 },
		{ "piece_artisanstation", 55 },
		{ "blackforge", 65 },
		{ "galdr_table", 65 }
	};

	[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
	[HarmonyPostfix]
	private static void DoCraftingPostfix(InventoryGui __instance, Player player)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: 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_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance.m_craftRecipe == (Object)null || (Object)(object)player == (Object)null)
		{
			return;
		}
		CraftingStation currentCraftingStation = player.GetCurrentCraftingStation();
		if ((Object)(object)currentCraftingStation == (Object)null)
		{
			return;
		}
		int craftingStationXP = GetCraftingStationXP(currentCraftingStation);
		if (craftingStationXP > 0)
		{
			((Character)player).RaiseSkill(MasterCraftingPlugin.ArtisanshipSkillType, (float)craftingStationXP);
		}
		ItemData itemData = __instance.m_craftRecipe.m_item.m_itemData;
		if (itemData == null)
		{
			return;
		}
		float skillLevel = ((Character)player).GetSkillLevel(MasterCraftingPlugin.ArtisanshipSkillType);
		float num = Mathf.Min(skillLevel / 100f, 1f);
		ItemData val = FindCraftedItem(player, itemData, __instance.m_craftUpgradeItem);
		if (val == null)
		{
			return;
		}
		if (val.m_customData.TryGetValue("MasterCrafting_Power", out var value))
		{
			float num2 = float.Parse(value, CultureInfo.InvariantCulture);
			if (num > num2)
			{
				val.m_customData["MasterCrafting_Power"] = num.ToString("F4", CultureInfo.InvariantCulture);
			}
		}
		else
		{
			val.m_customData["MasterCrafting_Power"] = num.ToString("F4", CultureInfo.InvariantCulture);
		}
		float num3 = MasterCraftingPlugin.MasterworkBaseChance.Value + MasterCraftingPlugin.MasterworkChancePerLevel.Value * skillLevel;
		if (Random.value < num3)
		{
			int maxQuality = val.m_shared.m_maxQuality;
			if (maxQuality > 1 && val.m_quality < maxQuality)
			{
				val.m_quality = Mathf.Min(val.m_quality + 1, maxQuality);
				Vector3 val2 = ((Component)currentCraftingStation).transform.position + Vector3.up;
				DamageText.instance.ShowText((TextType)7, val2, "Masterwork!", true);
			}
		}
		if (!MasterCraftingPlugin.EnableBonusEffects.Value || !CanHaveBonusEffect(val) || val.m_customData.ContainsKey("MasterCrafting_Effect") || !(skillLevel >= (float)MasterCraftingPlugin.MinimumSkillLevelForEffects.Value))
		{
			return;
		}
		float procChance = MasterCraftingEffects.GetProcChance(skillLevel);
		if (Random.value < procChance)
		{
			List<string> availableEffects = MasterCraftingEffects.GetAvailableEffects(skillLevel, val);
			if (availableEffects.Count > 0)
			{
				string text = availableEffects[Random.Range(0, availableEffects.Count)];
				val.m_customData["MasterCrafting_Effect"] = text;
				string effectDisplayName = MasterCraftingEffects.GetEffectDisplayName(text);
				Vector3 val3 = ((Component)currentCraftingStation).transform.position + Vector3.up;
				DamageText.instance.ShowText((TextType)7, val3, "Effect: " + effectDisplayName, true);
			}
		}
	}

	private static bool CanHaveBonusEffect(ItemData item)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: 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_0027: Invalid comparison between Unknown and I4
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Invalid comparison between Unknown and I4
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Invalid comparison between Unknown and I4
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Invalid comparison between Unknown and I4
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Invalid comparison between Unknown and I4
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Invalid comparison between Unknown and I4
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Invalid comparison between Unknown and I4
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Invalid comparison between Unknown and I4
		if (item == null || item.m_shared == null)
		{
			return false;
		}
		ItemType itemType = item.m_shared.m_itemType;
		return (int)itemType == 3 || (int)itemType == 14 || (int)itemType == 22 || (int)itemType == 4 || (int)itemType == 6 || (int)itemType == 7 || (int)itemType == 11 || (int)itemType == 17;
	}

	private static ItemData FindCraftedItem(Player player, ItemData template, ItemData upgradeItem)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		List<ItemData> list = new List<ItemData>();
		((Humanoid)player).GetInventory().GetAllItems(template.m_shared.m_name, list);
		if (upgradeItem != null)
		{
			foreach (ItemData item in list)
			{
				if (item.m_gridPos == upgradeItem.m_gridPos)
				{
					return item;
				}
			}
		}
		else if (list.Count > 0)
		{
			return list[list.Count - 1];
		}
		return null;
	}

	private static int GetCraftingStationXP(CraftingStation station)
	{
		if ((Object)(object)station == (Object)null)
		{
			return 0;
		}
		string text = ((Object)station).name.ToLower();
		foreach (KeyValuePair<string, int> item in CraftingStationXP)
		{
			if (text.Contains(item.Key))
			{
				return item.Value;
			}
		}
		return 0;
	}

	[HarmonyPatch(typeof(ItemData), "GetDamage", new Type[]
	{
		typeof(int),
		typeof(float)
	})]
	[HarmonyPostfix]
	private static void GetDamagePostfix(ItemData __instance, ref DamageTypes __result)
	{
		if (__instance.m_customData.TryGetValue("MasterCrafting_Power", out var value) && float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
		{
			float num = 1f + result * MasterCraftingPlugin.DamageBonusPerLevel.Value;
			num = Mathf.Clamp(num, 1f, 2f);
			((DamageTypes)(ref __result)).Modify(num);
		}
	}

	[HarmonyPatch(typeof(ItemData), "GetArmor", new Type[]
	{
		typeof(int),
		typeof(float)
	})]
	[HarmonyPostfix]
	private static void GetArmorPostfix(ItemData __instance, ref float __result)
	{
		if (__instance.m_customData.TryGetValue("MasterCrafting_Power", out var value) && float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
		{
			float num = 1f + result * MasterCraftingPlugin.ArmorBonusPerLevel.Value;
			num = Mathf.Clamp(num, 1f, 2f);
			__result *= num;
		}
	}

	[HarmonyPatch(typeof(ItemData), "GetMaxDurability", new Type[] { typeof(int) })]
	[HarmonyPostfix]
	private static void GetMaxDurabilityPostfix(ItemData __instance, ref float __result)
	{
		if (__instance.m_customData.TryGetValue("MasterCrafting_Power", out var value) && float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
		{
			float num = 1f + result * MasterCraftingPlugin.DurabilityBonusPerLevel.Value;
			num = Mathf.Clamp(num, 1f, 2f);
			__result *= num;
		}
	}

	[HarmonyPatch(typeof(ItemData), "GetBlockPower", new Type[]
	{
		typeof(int),
		typeof(float)
	})]
	[HarmonyPostfix]
	private static void GetBlockPowerPostfix(ItemData __instance, ref float __result)
	{
		if (__instance.m_customData.TryGetValue("MasterCrafting_Power", out var value) && float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
		{
			float num = 1f + result * MasterCraftingPlugin.ArmorBonusPerLevel.Value;
			num = Mathf.Clamp(num, 1f, 2f);
			__result *= num;
		}
	}

	[HarmonyPatch(typeof(Attack), "GetAttackStamina")]
	[HarmonyPostfix]
	private static void GetAttackStaminaPostfix(Attack __instance, ref float __result)
	{
		if (__instance.m_weapon != null && __instance.m_weapon.m_customData.TryGetValue("MasterCrafting_Power", out var value) && float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
		{
			float num = result * MasterCraftingPlugin.EfficiencyBonusPerLevel.Value;
			num = Mathf.Clamp(num, 0f, 1f);
			__result *= 1f - num;
		}
	}

	[HarmonyPatch(typeof(Attack), "GetAttackEitr")]
	[HarmonyPostfix]
	private static void GetAttackEitrPostfix(Attack __instance, ref float __result)
	{
		if (__instance.m_weapon != null && __instance.m_weapon.m_customData.TryGetValue("MasterCrafting_Power", out var value) && float.TryParse(value, NumberStyles.Any, CultureInfo.InvariantCulture, out var result))
		{
			float num = result * MasterCraftingPlugin.EfficiencyBonusPerLevel.Value;
			num = Mathf.Clamp(num, 0f, 1f);
			__result *= 1f - num;
		}
	}

	[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
	{
		typeof(ItemData),
		typeof(int),
		typeof(bool),
		typeof(float),
		typeof(int)
	})]
	[HarmonyPostfix]
	private static void GetTooltipPostfix(ItemData item, int qualityLevel, bool crafting, float worldLevel, int stackOverride, ref string __result)
	{
		if (item != null && item.m_customData.TryGetValue("MasterCrafting_Power", out var _))
		{
			__result += "\n<color=orange>MasterCrafted</color>";
			if (item.m_customData.TryGetValue("MasterCrafting_Effect", out var value2))
			{
				string effectDisplayName = MasterCraftingEffects.GetEffectDisplayName(value2);
				__result = __result + "\nEffect: " + effectDisplayName;
			}
		}
	}

	[HarmonyPatch(typeof(Humanoid), "EquipItem", new Type[]
	{
		typeof(ItemData),
		typeof(bool)
	})]
	[HarmonyPostfix]
	private static void EquipItemPostfix(Humanoid __instance, ItemData item, bool triggerEquipEffects)
	{
		if (!triggerEquipEffects || item == null || !item.m_customData.TryGetValue("MasterCrafting_Effect", out var value))
		{
			return;
		}
		if (MasterCraftingEffects.IsHeatResistanceEffect(value))
		{
			float heatResistanceValue = MasterCraftingEffects.GetHeatResistanceValue(value);
			if (heatResistanceValue > 0f)
			{
				item.m_shared.m_heatResistanceModifier = heatResistanceValue;
			}
			return;
		}
		StatusEffect effectByName = MasterCraftingEffects.GetEffectByName(value);
		if ((Object)(object)effectByName == (Object)null)
		{
			MasterCraftingPlugin.Logger.LogWarning((object)("Could not find effect: " + value));
			return;
		}
		SEMan sEMan = ((Character)__instance).GetSEMan();
		if (sEMan != null)
		{
			sEMan.AddStatusEffect(effectByName, false, 0, 0f);
		}
	}

	[HarmonyPatch(typeof(Humanoid), "UnequipItem", new Type[]
	{
		typeof(ItemData),
		typeof(bool)
	})]
	[HarmonyPostfix]
	private static void UnequipItemPostfix(Humanoid __instance, ItemData item, bool triggerEquipEffects)
	{
		if (!triggerEquipEffects || item == null || !item.m_customData.TryGetValue("MasterCrafting_Effect", out var value))
		{
			return;
		}
		if (MasterCraftingEffects.IsHeatResistanceEffect(value))
		{
			item.m_shared.m_heatResistanceModifier = 0f;
			return;
		}
		StatusEffect effectByName = MasterCraftingEffects.GetEffectByName(value);
		if (!((Object)(object)effectByName == (Object)null))
		{
			SEMan sEMan = ((Character)__instance).GetSEMan();
			if (sEMan != null)
			{
				sEMan.RemoveStatusEffect(effectByName, false);
			}
		}
	}
}
namespace MasterCrafting
{
	public class MasterCraftingEffects
	{
		public static StatusEffect ResistFire;

		public static StatusEffect SlowFall;

		public static StatusEffect SneakSkill;

		public static StatusEffect MeadStrength;

		public static StatusEffect MeadBzerker;

		public static StatusEffect MeadBugRepellent;

		public static StatusEffect MeadSwimmer;

		public static StatusEffect MeadHasty;

		public static StatusEffect MeadLightfoot;

		public static StatusEffect MeadFrostResist;

		public static StatusEffect MeadPoisonResist;

		public static StatusEffect MeadTamer;

		public static StatusEffect MeadEitrLingering;

		public static StatusEffect MeadStaminaLingering;

		public static StatusEffect MeadHealthLingering;

		public static StatusEffect SetEffect_BerserkerArmor;

		public static StatusEffect SetEffect_RootArmor;

		public static StatusEffect SetEffect_WolfArmor;

		public static StatusEffect SetEffect_FenringArmor;

		public static StatusEffect SetEffect_MageArmor;

		public static StatusEffect SetEffect_BerserkerUndeadArmor;

		public static StatusEffect SetEffect_AshlandsMediumArmor;

		public static StatusEffect WindRun;

		public static StatusEffect BeltStrength;

		private static List<string> tier50GeneralEffects = new List<string>();

		private static List<string> tier60GeneralEffects = new List<string>();

		private static List<string> tier70GeneralEffects = new List<string>();

		private static List<string> tier80GeneralEffects = new List<string>();

		private static List<string> tier50ArmorEffects = new List<string>();

		private static List<string> tier60ArmorEffects = new List<string>();

		private static List<string> tier70ArmorEffects = new List<string>();

		private static List<string> tier80ArmorEffects = new List<string>();

		public static void Initialize()
		{
			CreateCustomEffects();
			CloneMeadEffects();
			CloneSetEffects();
			CloneOtherEffects();
			BuildEffectPools();
			RegisterStatusEffects();
			AddLocalizations();
		}

		private static void CreateCustomEffects()
		{
			//IL_003d: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			ResistFire = CloneEffect("Potion_frostresist", "MasterCrafting_ResistFire");
			StatusEffect resistFire = ResistFire;
			SE_Stats val = (SE_Stats)(object)((resistFire is SE_Stats) ? resistFire : null);
			if (val != null)
			{
				val.m_mods.Clear();
				val.m_mods.Add(new DamageModPair
				{
					m_type = (DamageType)32,
					m_modifier = (DamageModifier)1
				});
			}
			SlowFall = CloneEffect("Potion_frostresist", "MasterCrafting_SlowFall");
			StatusEffect slowFall = SlowFall;
			SE_Stats val2 = (SE_Stats)(object)((slowFall is SE_Stats) ? slowFall : null);
			if (val2 != null)
			{
				val2.m_mods.Clear();
				val2.m_fallDamageModifier = -0.5f;
			}
			SneakSkill = CloneEffect("Potion_frostresist", "MasterCrafting_SneakSkill");
			StatusEffect sneakSkill = SneakSkill;
			SE_Stats val3 = (SE_Stats)(object)((sneakSkill is SE_Stats) ? sneakSkill : null);
			if (val3 != null)
			{
				val3.m_mods.Clear();
				val3.m_skillLevel = (SkillType)101;
				val3.m_skillLevelModifier = 15f;
			}
		}

		private static void CloneMeadEffects()
		{
			MeadStrength = CloneEffect("Potion_strength", "MasterCrafting_MeadStrength");
			MeadBzerker = CloneEffect("Potion_bzerker", "MasterCrafting_MeadBzerker");
			MeadBugRepellent = CloneEffect("Potion_BugRepellent", "MasterCrafting_MeadBugRepellent");
			MeadSwimmer = CloneEffect("Potion_swimmer", "MasterCrafting_MeadSwimmer");
			MeadHasty = CloneEffect("Potion_hasty", "MasterCrafting_MeadHasty");
			MeadLightfoot = CloneEffect("Potion_LightFoot", "MasterCrafting_MeadLightfoot");
			MeadFrostResist = CloneEffect("Potion_frostresist", "MasterCrafting_MeadFrostResist");
			MeadPoisonResist = CloneEffect("Potion_poisonresist", "MasterCrafting_MeadPoisonResist");
			MeadTamer = CloneEffect("Potion_tamer", "MasterCrafting_MeadTamer");
			MeadEitrLingering = CloneEffect("Potion_eitr_lingering", "MasterCrafting_MeadEitrLingering");
			MeadStaminaLingering = CloneEffect("Potion_stamina_lingering", "MasterCrafting_MeadStaminaLingering");
			MeadHealthLingering = CloneEffect("Potion_health_lingering", "MasterCrafting_MeadHealthLingering");
		}

		private static void CloneSetEffects()
		{
			SetEffect_BerserkerArmor = CloneEffect("SetEffect_BerserkerArmor", "MasterCrafting_SetEffect_BerserkerArmor");
			SetEffect_RootArmor = CloneEffect("SetEffect_RootArmor", "MasterCrafting_SetEffect_RootArmor");
			SetEffect_WolfArmor = CloneEffect("SetEffect_WolfArmor", "MasterCrafting_SetEffect_WolfArmor");
			SetEffect_FenringArmor = CloneEffect("SetEffect_FenringArmor", "MasterCrafting_SetEffect_FenringArmor");
			SetEffect_MageArmor = CloneEffect("SetEffect_MageArmor", "MasterCrafting_SetEffect_MageArmor");
			SetEffect_BerserkerUndeadArmor = CloneEffect("SetEffect_BerserkerUndeadArmor", "MasterCrafting_SetEffect_BerserkerUndeadArmor");
			SetEffect_AshlandsMediumArmor = CloneEffect("SetEffect_AshlandsMediumArmor", "MasterCrafting_SetEffect_AshlandsMediumArmor");
		}

		private static void CloneOtherEffects()
		{
			WindRun = CloneEffect("WindRun", "MasterCrafting_WindRun");
			BeltStrength = CloneEffect("BeltStrength", "MasterCrafting_BeltStrength");
		}

		private static StatusEffect CloneEffect(string originalName, string cloneName)
		{
			StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(originalName));
			if ((Object)(object)statusEffect == (Object)null)
			{
				MasterCraftingPlugin.Logger.LogWarning((object)("Could not find original effect: " + originalName));
				return null;
			}
			StatusEffect val = Object.Instantiate<StatusEffect>(statusEffect);
			((Object)val).name = cloneName;
			val.m_name = "$se_" + cloneName;
			val.m_ttl = 0f;
			return val;
		}

		private static void BuildEffectPools()
		{
			tier50GeneralEffects.Add("MasterCrafting_MeadHealthLingering");
			tier50GeneralEffects.Add("MasterCrafting_MeadHasty");
			tier50GeneralEffects.Add("MasterCrafting_MeadTamer");
			tier50ArmorEffects.Add("MasterCrafting_SetEffect_BerserkerArmor");
			tier50ArmorEffects.Add("MasterCrafting_MeadSwimmer");
			tier50ArmorEffects.AddRange(tier50GeneralEffects);
			tier60GeneralEffects.AddRange(tier50GeneralEffects);
			tier60GeneralEffects.Add("MasterCrafting_SneakSkill");
			tier60GeneralEffects.Add("MasterCrafting_MeadStrength");
			tier60GeneralEffects.Add("MasterCrafting_MeadBzerker");
			tier60GeneralEffects.Add("MasterCrafting_MeadFrostResist");
			tier60GeneralEffects.Add("MasterCrafting_MeadPoisonResist");
			tier60ArmorEffects.Add("MasterCrafting_SetEffect_RootArmor");
			tier60ArmorEffects.Add("MasterCrafting_SetEffect_WolfArmor");
			tier60ArmorEffects.Add("MasterCrafting_SetEffect_FenringArmor");
			tier60ArmorEffects.AddRange(tier60GeneralEffects);
			tier70GeneralEffects.AddRange(tier60GeneralEffects);
			tier70GeneralEffects.Add("MasterCrafting_WindRun");
			tier70GeneralEffects.Add("MasterCrafting_BeltStrength");
			tier70GeneralEffects.Add("MasterCrafting_ResistFire");
			tier70GeneralEffects.Add("MasterCrafting_SlowFall");
			tier70GeneralEffects.Add("MasterCrafting_MeadBugRepellent");
			tier70GeneralEffects.Add("MasterCrafting_MeadLightfoot");
			tier70GeneralEffects.Add("MasterCrafting_MeadEitrLingering");
			tier70ArmorEffects.Add("MasterCrafting_SetEffect_MageArmor");
			tier70ArmorEffects.Add("MasterCrafting_SetEffect_BerserkerUndeadArmor");
			tier70ArmorEffects.AddRange(tier70GeneralEffects);
			tier80GeneralEffects.AddRange(tier70GeneralEffects);
			tier80GeneralEffects.Add("MasterCrafting_HeatResist20");
			tier80GeneralEffects.Add("MasterCrafting_HeatResist40");
			tier80GeneralEffects.Add("MasterCrafting_MeadStaminaLingering");
			tier80ArmorEffects.Add("MasterCrafting_SetEffect_AshlandsMediumArmor");
			tier80ArmorEffects.AddRange(tier80GeneralEffects);
		}

		public static List<string> GetAvailableEffects(float skillLevel, ItemData item)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			if (item == null || item.m_shared == null)
			{
				return new List<string>();
			}
			bool flag = (int)item.m_shared.m_itemType == 6 || (int)item.m_shared.m_itemType == 7 || (int)item.m_shared.m_itemType == 11 || (int)item.m_shared.m_itemType == 17;
			if (skillLevel >= 90f)
			{
				return flag ? tier80ArmorEffects : tier80GeneralEffects;
			}
			if (skillLevel >= 80f)
			{
				return flag ? tier80ArmorEffects : tier80GeneralEffects;
			}
			if (skillLevel >= 70f)
			{
				return flag ? tier70ArmorEffects : tier70GeneralEffects;
			}
			if (skillLevel >= 60f)
			{
				return flag ? tier60ArmorEffects : tier60GeneralEffects;
			}
			if (skillLevel >= 50f)
			{
				return flag ? tier50ArmorEffects : tier50GeneralEffects;
			}
			return new List<string>();
		}

		public static float GetProcChance(float skillLevel)
		{
			if (skillLevel >= 100f)
			{
				return MasterCraftingPlugin.EffectProcChanceTier90.Value;
			}
			if (skillLevel >= 90f)
			{
				return MasterCraftingPlugin.EffectProcChanceTier90.Value;
			}
			if (skillLevel >= 80f)
			{
				return MasterCraftingPlugin.EffectProcChanceTier80.Value;
			}
			if (skillLevel >= 70f)
			{
				return MasterCraftingPlugin.EffectProcChanceTier70.Value;
			}
			if (skillLevel >= 60f)
			{
				return MasterCraftingPlugin.EffectProcChanceTier60.Value;
			}
			if (skillLevel >= 50f)
			{
				return MasterCraftingPlugin.EffectProcChanceTier50.Value;
			}
			return 0f;
		}

		public static StatusEffect GetEffectByName(string name)
		{
			return (StatusEffect)(name switch
			{
				"MasterCrafting_ResistFire" => ResistFire, 
				"MasterCrafting_SlowFall" => SlowFall, 
				"MasterCrafting_SneakSkill" => SneakSkill, 
				"MasterCrafting_MeadStrength" => MeadStrength, 
				"MasterCrafting_MeadBzerker" => MeadBzerker, 
				"MasterCrafting_MeadBugRepellent" => MeadBugRepellent, 
				"MasterCrafting_MeadSwimmer" => MeadSwimmer, 
				"MasterCrafting_MeadHasty" => MeadHasty, 
				"MasterCrafting_MeadLightfoot" => MeadLightfoot, 
				"MasterCrafting_MeadFrostResist" => MeadFrostResist, 
				"MasterCrafting_MeadPoisonResist" => MeadPoisonResist, 
				"MasterCrafting_MeadTamer" => MeadTamer, 
				"MasterCrafting_MeadEitrLingering" => MeadEitrLingering, 
				"MasterCrafting_MeadStaminaLingering" => MeadStaminaLingering, 
				"MasterCrafting_MeadHealthLingering" => MeadHealthLingering, 
				"MasterCrafting_SetEffect_BerserkerArmor" => SetEffect_BerserkerArmor, 
				"MasterCrafting_SetEffect_RootArmor" => SetEffect_RootArmor, 
				"MasterCrafting_SetEffect_WolfArmor" => SetEffect_WolfArmor, 
				"MasterCrafting_SetEffect_FenringArmor" => SetEffect_FenringArmor, 
				"MasterCrafting_SetEffect_MageArmor" => SetEffect_MageArmor, 
				"MasterCrafting_SetEffect_BerserkerUndeadArmor" => SetEffect_BerserkerUndeadArmor, 
				"MasterCrafting_SetEffect_AshlandsMediumArmor" => SetEffect_AshlandsMediumArmor, 
				"MasterCrafting_WindRun" => WindRun, 
				"MasterCrafting_BeltStrength" => BeltStrength, 
				_ => null, 
			});
		}

		public static float GetHeatResistanceValue(string effectName)
		{
			if (!(effectName == "MasterCrafting_HeatResist20"))
			{
				if (effectName == "MasterCrafting_HeatResist40")
				{
					return 0.4f;
				}
				return 0f;
			}
			return 0.2f;
		}

		public static bool IsHeatResistanceEffect(string effectName)
		{
			return effectName == "MasterCrafting_HeatResist20" || effectName == "MasterCrafting_HeatResist40";
		}

		public static string GetEffectDisplayName(string effectName)
		{
			return effectName switch
			{
				"MasterCrafting_ResistFire" => "Fire Resistance", 
				"MasterCrafting_SlowFall" => "Slow Fall", 
				"MasterCrafting_SneakSkill" => "Sneak Skill", 
				"MasterCrafting_MeadStrength" => "Strength", 
				"MasterCrafting_MeadBzerker" => "Berserker", 
				"MasterCrafting_MeadBugRepellent" => "Bug Repellent", 
				"MasterCrafting_MeadSwimmer" => "Swimmer", 
				"MasterCrafting_MeadHasty" => "Hasty", 
				"MasterCrafting_MeadLightfoot" => "Light Foot", 
				"MasterCrafting_MeadFrostResist" => "Frost Resistance", 
				"MasterCrafting_MeadPoisonResist" => "Poison Resistance", 
				"MasterCrafting_MeadTamer" => "Tamer", 
				"MasterCrafting_MeadEitrLingering" => "Eitr Regeneration", 
				"MasterCrafting_MeadStaminaLingering" => "Stamina Regeneration", 
				"MasterCrafting_MeadHealthLingering" => "Health Regeneration", 
				"MasterCrafting_SetEffect_BerserkerArmor" => "Berserker Fury", 
				"MasterCrafting_SetEffect_RootArmor" => "Root Armor", 
				"MasterCrafting_SetEffect_WolfArmor" => "Wolf Armor", 
				"MasterCrafting_SetEffect_FenringArmor" => "Fenring Armor", 
				"MasterCrafting_SetEffect_MageArmor" => "Mage Armor", 
				"MasterCrafting_SetEffect_BerserkerUndeadArmor" => "Undead Fury", 
				"MasterCrafting_SetEffect_AshlandsMediumArmor" => "Ashlands Armor", 
				"MasterCrafting_WindRun" => "Wind Run", 
				"MasterCrafting_BeltStrength" => "Belt Strength", 
				"MasterCrafting_HeatResist20" => "Heat Resistance (20%)", 
				"MasterCrafting_HeatResist40" => "Heat Resistance (40%)", 
				_ => effectName, 
			};
		}

		private static void RegisterStatusEffects()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Expected O, but got Unknown
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Expected O, but got Unknown
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Expected O, but got Unknown
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: 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_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Expected O, but got Unknown
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Expected O, but got Unknown
			if ((Object)(object)ResistFire != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(ResistFire, false));
			}
			if ((Object)(object)SlowFall != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SlowFall, false));
			}
			if ((Object)(object)SneakSkill != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SneakSkill, false));
			}
			if ((Object)(object)MeadStrength != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadStrength, false));
			}
			if ((Object)(object)MeadBzerker != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadBzerker, false));
			}
			if ((Object)(object)MeadBugRepellent != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadBugRepellent, false));
			}
			if ((Object)(object)MeadSwimmer != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadSwimmer, false));
			}
			if ((Object)(object)MeadHasty != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadHasty, false));
			}
			if ((Object)(object)MeadLightfoot != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadLightfoot, false));
			}
			if ((Object)(object)MeadFrostResist != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadFrostResist, false));
			}
			if ((Object)(object)MeadPoisonResist != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadPoisonResist, false));
			}
			if ((Object)(object)MeadTamer != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadTamer, false));
			}
			if ((Object)(object)MeadEitrLingering != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadEitrLingering, false));
			}
			if ((Object)(object)MeadStaminaLingering != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadStaminaLingering, false));
			}
			if ((Object)(object)MeadHealthLingering != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(MeadHealthLingering, false));
			}
			if ((Object)(object)SetEffect_BerserkerArmor != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SetEffect_BerserkerArmor, false));
			}
			if ((Object)(object)SetEffect_RootArmor != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SetEffect_RootArmor, false));
			}
			if ((Object)(object)SetEffect_WolfArmor != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SetEffect_WolfArmor, false));
			}
			if ((Object)(object)SetEffect_FenringArmor != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SetEffect_FenringArmor, false));
			}
			if ((Object)(object)SetEffect_MageArmor != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SetEffect_MageArmor, false));
			}
			if ((Object)(object)SetEffect_BerserkerUndeadArmor != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SetEffect_BerserkerUndeadArmor, false));
			}
			if ((Object)(object)SetEffect_AshlandsMediumArmor != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(SetEffect_AshlandsMediumArmor, false));
			}
			if ((Object)(object)WindRun != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(WindRun, false));
			}
			if ((Object)(object)BeltStrength != (Object)null)
			{
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(BeltStrength, false));
			}
		}

		private static void AddLocalizations()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "se_MasterCrafting_ResistFire", "Fire Resistance" },
				{ "se_MasterCrafting_SlowFall", "Slow Fall" },
				{ "se_MasterCrafting_SneakSkill", "Sneak Skill" },
				{ "se_MasterCrafting_MeadStrength", "Strength" },
				{ "se_MasterCrafting_MeadBzerker", "Berserker" },
				{ "se_MasterCrafting_MeadBugRepellent", "Bug Repellent" },
				{ "se_MasterCrafting_MeadSwimmer", "Swimmer" },
				{ "se_MasterCrafting_MeadHasty", "Hasty" },
				{ "se_MasterCrafting_MeadLightfoot", "Light Foot" },
				{ "se_MasterCrafting_MeadFrostResist", "Frost Resistance" },
				{ "se_MasterCrafting_MeadPoisonResist", "Poison Resistance" },
				{ "se_MasterCrafting_MeadTamer", "Tamer" },
				{ "se_MasterCrafting_MeadEitrLingering", "Eitr Regeneration" },
				{ "se_MasterCrafting_MeadStaminaLingering", "Stamina Regeneration" },
				{ "se_MasterCrafting_MeadHealthLingering", "Health Regeneration" },
				{ "se_MasterCrafting_SetEffect_BerserkerArmor", "Berserker Fury" },
				{ "se_MasterCrafting_SetEffect_RootArmor", "Root Armor" },
				{ "se_MasterCrafting_SetEffect_WolfArmor", "Wolf Armor" },
				{ "se_MasterCrafting_SetEffect_FenringArmor", "Fenring Armor" },
				{ "se_MasterCrafting_SetEffect_MageArmor", "Mage Armor" },
				{ "se_MasterCrafting_SetEffect_BerserkerUndeadArmor", "Undead Fury" },
				{ "se_MasterCrafting_SetEffect_AshlandsMediumArmor", "Ashlands Armor" },
				{ "se_MasterCrafting_WindRun", "Wind Run" },
				{ "se_MasterCrafting_BeltStrength", "Belt Strength" },
				{ "se_MasterCrafting_HeatResist20", "Heat Resistance (20%)" },
				{ "se_MasterCrafting_HeatResist40", "Heat Resistance (40%)" },
				{ "se_MasterCrafting_ResistFire_tooltip", "Increases resistance to fire damage." },
				{ "se_MasterCrafting_SlowFall_tooltip", "Reduces fall damage by 50%." },
				{ "se_MasterCrafting_SneakSkill_tooltip", "Increases Sneak skill by 15 levels." },
				{ "se_MasterCrafting_MeadStrength_tooltip", "Increases maximum carry weight by 250." },
				{ "se_MasterCrafting_MeadBzerker_tooltip", "Increases damage but reduces defense." },
				{ "se_MasterCrafting_MeadBugRepellent_tooltip", "Repels insects and other small creatures." },
				{ "se_MasterCrafting_MeadSwimmer_tooltip", "Allows swimming without stamina drain." },
				{ "se_MasterCrafting_MeadHasty_tooltip", "Increases movement speed by 25%." },
				{ "se_MasterCrafting_MeadLightfoot_tooltip", "Reduces noise from movement." },
				{ "se_MasterCrafting_MeadFrostResist_tooltip", "Increases resistance to frost damage." },
				{ "se_MasterCrafting_MeadPoisonResist_tooltip", "Increases resistance to poison damage." },
				{ "se_MasterCrafting_MeadTamer_tooltip", "Tamed animals are less likely to flee." },
				{ "se_MasterCrafting_MeadEitrLingering_tooltip", "Gradually restores eitr over time." },
				{ "se_MasterCrafting_MeadStaminaLingering_tooltip", "Gradually restores stamina over time." },
				{ "se_MasterCrafting_MeadHealthLingering_tooltip", "Gradually restores health over time." },
				{ "se_MasterCrafting_SetEffect_BerserkerArmor_tooltip", "Increases damage when health is low." },
				{ "se_MasterCrafting_SetEffect_RootArmor_tooltip", "Increases physical resistance." },
				{ "se_MasterCrafting_SetEffect_WolfArmor_tooltip", "Increases movement speed in cold environments." },
				{ "se_MasterCrafting_SetEffect_FenringArmor_tooltip", "Increases stealth capabilities." },
				{ "se_MasterCrafting_SetEffect_MageArmor_tooltip", "Increases eitr regeneration." },
				{ "se_MasterCrafting_SetEffect_BerserkerUndeadArmor_tooltip", "Increases damage against undead enemies." },
				{ "se_MasterCrafting_SetEffect_AshlandsMediumArmor_tooltip", "Increases resistance to heat damage." },
				{ "se_MasterCrafting_WindRun_tooltip", "Increases movement speed significantly." },
				{ "se_MasterCrafting_BeltStrength_tooltip", "Increases maximum carry weight." },
				{ "se_MasterCrafting_HeatResist20_tooltip", "Increases heat resistance by 20%." },
				{ "se_MasterCrafting_HeatResist40_tooltip", "Increases heat resistance by 40%." }
			});
		}
	}
	[BepInPlugin("com.ruijven.mastercrafting", "MasterCrafting", "1.0.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class MasterCraftingPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.ruijven.mastercrafting";

		public const string PluginName = "MasterCrafting";

		public const string PluginVersion = "1.0.3";

		internal static ManualLogSource Logger;

		public static SkillType ArtisanshipSkillType;

		public static ConfigEntry<float> DamageBonusPerLevel;

		public static ConfigEntry<float> ArmorBonusPerLevel;

		public static ConfigEntry<float> DurabilityBonusPerLevel;

		public static ConfigEntry<float> EfficiencyBonusPerLevel;

		public static ConfigEntry<float> MasterworkBaseChance;

		public static ConfigEntry<float> MasterworkChancePerLevel;

		public static ConfigEntry<bool> EnableBonusEffects;

		public static ConfigEntry<float> EffectProcChanceTier50;

		public static ConfigEntry<float> EffectProcChanceTier60;

		public static ConfigEntry<float> EffectProcChanceTier70;

		public static ConfigEntry<float> EffectProcChanceTier80;

		public static ConfigEntry<float> EffectProcChanceTier90;

		public static ConfigEntry<int> MinimumSkillLevelForEffects;

		internal static MasterCraftingPlugin Instance { get; private set; }

		private void Awake()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			InitializeConfig();
			RegisterArtisanshipSkill();
			Harmony val = new Harmony("com.ruijven.mastercrafting");
			val.PatchAll(Assembly.GetExecutingAssembly());
			((MonoBehaviour)this).StartCoroutine(DelayedEffectInitialization());
			Logger.LogInfo((object)"MasterCrafting v1.0.3 loaded successfully!");
		}

		private void InitializeConfig()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Expected O, but got Unknown
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Expected O, but got Unknown
			DamageBonusPerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "DamageBonusPerLevel", 0.2f, new ConfigDescription("Total damage bonus at level 100 (e.g., 0.2 = 20% increase, 1.0 = 100% increase)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ArmorBonusPerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "ArmorBonusPerLevel", 0.15f, new ConfigDescription("Total armor bonus at level 100 (e.g., 0.15 = 15% increase, 1.0 = 100% increase)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			DurabilityBonusPerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "DurabilityBonusPerLevel", 0.3f, new ConfigDescription("Total durability bonus at level 100 (e.g., 0.3 = 30% increase, 1.0 = 100% increase)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EfficiencyBonusPerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Stat Bonuses", "EfficiencyBonusPerLevel", 0.2f, new ConfigDescription("Total stamina/eitr reduction at level 100 (e.g., 0.2 = 20% reduction, 1.0 = 100% reduction)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			MasterworkBaseChance = ((BaseUnityPlugin)this).Config.Bind<float>("Masterwork Proc", "MasterworkBaseChance", 0.02f, new ConfigDescription("Base chance for masterwork proc (e.g., 0.02 = 2%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			MasterworkChancePerLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Masterwork Proc", "MasterworkChancePerLevel", 0.001f, new ConfigDescription("Additional masterwork chance per Artisanship level (e.g., 0.001 = 0.1% per level)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EnableBonusEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("Bonus Effects", "EnableBonusEffects", true, new ConfigDescription("Enable or disable the random bonus effect system on crafted items", (AcceptableValueBase)null, Array.Empty<object>()));
			EffectProcChanceTier50 = ((BaseUnityPlugin)this).Config.Bind<float>("Bonus Effects", "EffectProcChanceTier50", 0.02f, new ConfigDescription("Chance to proc a bonus effect at skill level 50-59 (e.g., 0.02 = 2%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EffectProcChanceTier60 = ((BaseUnityPlugin)this).Config.Bind<float>("Bonus Effects", "EffectProcChanceTier60", 0.04f, new ConfigDescription("Chance to proc a bonus effect at skill level 60-69 (e.g., 0.04 = 4%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EffectProcChanceTier70 = ((BaseUnityPlugin)this).Config.Bind<float>("Bonus Effects", "EffectProcChanceTier70", 0.06f, new ConfigDescription("Chance to proc a bonus effect at skill level 70-79 (e.g., 0.06 = 6%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EffectProcChanceTier80 = ((BaseUnityPlugin)this).Config.Bind<float>("Bonus Effects", "EffectProcChanceTier80", 0.08f, new ConfigDescription("Chance to proc a bonus effect at skill level 80-89 (e.g., 0.08 = 8%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EffectProcChanceTier90 = ((BaseUnityPlugin)this).Config.Bind<float>("Bonus Effects", "EffectProcChanceTier90", 0.09f, new ConfigDescription("Chance to proc a bonus effect at skill level 90+ (e.g., 0.09 = 9%)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			MinimumSkillLevelForEffects = ((BaseUnityPlugin)this).Config.Bind<int>("Bonus Effects", "MinimumSkillLevelForEffects", 50, new ConfigDescription("Minimum Artisanship skill level required for bonus effects to proc", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
		}

		private void RegisterArtisanshipSkill()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				SkillConfig val = new SkillConfig
				{
					Identifier = "com.ruijven.mastercrafting.artisanship",
					Name = "Artisanship",
					Description = "Your skill in crafting grants permanent bonuses to items you create.",
					Icon = null,
					IncreaseStep = 1f
				};
				ArtisanshipSkillType = SkillManager.Instance.AddSkill(val);
				Logger.LogInfo((object)$"Artisanship skill registered successfully. SkillType: {ArtisanshipSkillType}");
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Failed to register Artisanship skill: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		private IEnumerator DelayedEffectInitialization()
		{
			while ((Object)(object)ObjectDB.instance == (Object)null || ObjectDB.instance.m_items.Count == 0)
			{
				yield return null;
			}
			MasterCraftingEffects.Initialize();
			Logger.LogInfo((object)"MasterCrafting effects initialized successfully.");
		}
	}
}