Decompiled source of GunzNBullets v1.0.4

GunzNBullets.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using GunzNBullets.Functions;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("GunzNBullets")]
[assembly: AssemblyDescription("https://thunderstore.io/c/valheim/p/blacks7ar/GunzNBullets/")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyProduct("GunzNBullets")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("B466880C-AEEC-400E-909E-89931DD6BA93")]
[assembly: AssemblyFileVersion("1.0.4")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace GunzNBullets
{
	[BepInPlugin("blacks7ar.GunzNBullets", "GunzNBullets", "1.0.4")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "blacks7ar.GunzNBullets";

		public const string modName = "GunzNBullets";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "1.0.4";

		public const string modLink = "https://thunderstore.io/c/valheim/p/blacks7ar/GunzNBullets/";

		private static readonly Harmony _harmony = new Harmony("blacks7ar.GunzNBullets");

		private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.GunzNBullets")
		{
			DisplayName = "GunzNBullets",
			CurrentVersion = "1.0.4",
			MinimumRequiredVersion = "1.0.4",
			ModRequired = true
		};

		private static ConfigEntry<GunzNBullets.Functions.Toggle> _serverConfigLocked;

		public static ConfigEntry<int> _bulletMaxStackSize;

		private static ConfigEntry<KeyCode> _nextBullet;

		public static Plugin _Instance;

		public ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool _synchronizedConfig = true)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (_synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			_configSync.AddConfigEntry<T>(val2).SynchronizedConfig = _synchronizedConfig;
			return val2;
		}

		public void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			Localizer.Load();
			_Instance = this;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			_serverConfigLocked = config("1- ServerSync", "Lock Configuration", GunzNBullets.Functions.Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>()));
			_configSync.AddLockingConfigEntry<GunzNBullets.Functions.Toggle>(_serverConfigLocked);
			_bulletMaxStackSize = config("2- General", "Bullets Max Stack Size", 100, new ConfigDescription("Bullets max stack size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>()));
			_nextBullet = config<KeyCode>("2- General", "Cycle Bullet", (KeyCode)103, new ConfigDescription("Hotkey to press to cycle through bullets in you inventory.", (AcceptableValueBase)null, Array.Empty<object>()));
			ConfigSetup.Init();
			SetupPrefabs.Init();
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.Save();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		public void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name != "main") && ZInput.instance != null && !ZNet.instance.InPasswordDialog() && _nextBullet != null)
			{
				Player localPlayer = Player.m_localPlayer;
				if (Input.GetKeyDown(_nextBullet.Value) && ((Character)localPlayer).TakeInput())
				{
					CycleBullets.CycleBullet();
				}
			}
		}
	}
}
namespace GunzNBullets.Functions
{
	public static class ConfigSetup
	{
		public static ConfigEntry<Toggle> _blackMetalShotGunAlwaysRotate;

		public static ConfigEntry<float> _blackMetalShotGunRecoil;

		public static ConfigEntry<float> _blackMetalShotGunReloadTime;

		public static ConfigEntry<float> _blackMetalShotGunReloadStamina;

		public static ConfigEntry<Toggle> _bronzeRifleAlwaysRotate;

		public static ConfigEntry<float> _bronzeRifleRecoil;

		public static ConfigEntry<float> _bronzeRifleReloadTime;

		public static ConfigEntry<float> _bronzeRifleReloadStamina;

		public static ConfigEntry<Toggle> _flametalMusketAlwaysRotate;

		public static ConfigEntry<float> _flametalMusketRecoil;

		public static ConfigEntry<float> _flametalMusketReloadTime;

		public static ConfigEntry<float> _flametalMusketReloadStamina;

		public static ConfigEntry<Toggle> _flintRifleAlwaysRotate;

		public static ConfigEntry<float> _flintRifleRecoil;

		public static ConfigEntry<float> _flintRifleReloadTime;

		public static ConfigEntry<float> _flintRifleReloadStamina;

		public static ConfigEntry<Toggle> _ironRifleAlwaysRotate;

		public static ConfigEntry<float> _ironRifleRecoil;

		public static ConfigEntry<float> _ironRifleReloadTime;

		public static ConfigEntry<float> _ironRifleReloadStamina;

		public static ConfigEntry<Toggle> _silverRifleAlwaysRotate;

		public static ConfigEntry<float> _silverRifleRecoil;

		public static ConfigEntry<float> _silverRifleReloadTime;

		public static ConfigEntry<float> _silverRifleReloadStamina;

		public static ConfigEntry<float> _blackMetalBulletBluntDmg;

		public static ConfigEntry<float> _carapaceBulletBluntDmg;

		public static ConfigEntry<float> _fireBulletBluntDmg;

		public static ConfigEntry<float> _fireBulletFireDmg;

		public static ConfigEntry<float> _flametalBulletBluntDmg;

		public static ConfigEntry<float> _iceBulletBluntDmg;

		public static ConfigEntry<float> _iceBulletFrostDmg;

		public static ConfigEntry<float> _ironBulletBluntDmg;

		public static ConfigEntry<float> _lightningBulletBluntDmg;

		public static ConfigEntry<float> _lightningBulletLightningDmg;

		public static ConfigEntry<float> _poisonBulletBluntDmg;

		public static ConfigEntry<float> _poisonBulletPoisonDmg;

		public static ConfigEntry<float> _silverBulletBluntDmg;

		public static ConfigEntry<float> _flintBulletBluntDmg;

		public static ConfigEntry<float> _copperBulletBluntDmg;

		public static ConfigEntry<float> _boneRoundsPierceDmg;

		public static ConfigEntry<float> _bronzeRoundsPierceDmg;

		public static ConfigEntry<float> _ceramicRoundsPierceDmg;

		public static ConfigEntry<float> _charredRoundsPierceDmg;

		public static ConfigEntry<float> _chitinRoundsPierceDmg;

		public static ConfigEntry<float> _fangRoundsPierceDmg;

		public static ConfigEntry<float> _needleRoundsPierceDmg;

		private static Localization english;

		public static void Init()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Expected O, but got Unknown
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Expected O, but got Unknown
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Expected O, but got Unknown
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Expected O, but got Unknown
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Expected O, but got Unknown
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Expected O, but got Unknown
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Expected O, but got Unknown
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Expected O, but got Unknown
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Expected O, but got Unknown
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Expected O, but got Unknown
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Expected O, but got Unknown
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Expected O, but got Unknown
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Expected O, but got Unknown
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Expected O, but got Unknown
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Expected O, but got Unknown
			//IL_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Expected O, but got Unknown
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Expected O, but got Unknown
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Expected O, but got Unknown
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Expected O, but got Unknown
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0697: Expected O, but got Unknown
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Expected O, but got Unknown
			//IL_0711: Unknown result type (might be due to invalid IL or missing references)
			//IL_071c: Expected O, but got Unknown
			//IL_075c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0767: Expected O, but got Unknown
			//IL_07a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Expected O, but got Unknown
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ec: Expected O, but got Unknown
			//IL_082c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Expected O, but got Unknown
			//IL_0877: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: Expected O, but got Unknown
			//IL_08b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bc: Expected O, but got Unknown
			//IL_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0907: Expected O, but got Unknown
			//IL_0936: Unknown result type (might be due to invalid IL or missing references)
			//IL_0941: Expected O, but got Unknown
			//IL_0981: Unknown result type (might be due to invalid IL or missing references)
			//IL_098c: Expected O, but got Unknown
			//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d7: Expected O, but got Unknown
			//IL_0a17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a22: Expected O, but got Unknown
			//IL_0a62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6d: Expected O, but got Unknown
			//IL_0aad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab8: Expected O, but got Unknown
			//IL_0af8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b03: Expected O, but got Unknown
			//IL_0b43: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4e: Expected O, but got Unknown
			//IL_0b8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b99: Expected O, but got Unknown
			english = new Localization();
			english.SetupLanguage("English");
			string group = english.Localize("$bmm_shotgun_blackmetal");
			_blackMetalShotGunAlwaysRotate = Plugin._Instance.config(group, "Always Rotate", Toggle.On, new ConfigDescription("If On, your character will always face the direction of your cursor.", (AcceptableValueBase)null, Array.Empty<object>()));
			_blackMetalShotGunRecoil = Plugin._Instance.config(group, "Recoil Pushback", 15f, new ConfigDescription("Recoil pushback.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			_blackMetalShotGunReloadTime = Plugin._Instance.config(group, "Reload Time", 1.9f, new ConfigDescription("Reload time.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.9f), Array.Empty<object>()));
			_blackMetalShotGunReloadStamina = Plugin._Instance.config(group, "Reload Stamina Drain", 3f, new ConfigDescription("Reload stamina drain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			string group2 = english.Localize("$bmm_rifle_bronze");
			_bronzeRifleAlwaysRotate = Plugin._Instance.config(group2, "Always Rotate", Toggle.On, new ConfigDescription("If On, your character will always face the direction of your cursor.", (AcceptableValueBase)null, Array.Empty<object>()));
			_bronzeRifleRecoil = Plugin._Instance.config(group2, "Recoil Pushback", 15f, new ConfigDescription("Recoil pushback.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			_bronzeRifleReloadTime = Plugin._Instance.config(group2, "Reload Time", 1.9f, new ConfigDescription("Reload time.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.9f), Array.Empty<object>()));
			_bronzeRifleReloadStamina = Plugin._Instance.config(group2, "Reload Stamina Drain", 3f, new ConfigDescription("Reload stamina drain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			string group3 = english.Localize("$bmm_musket_flametal");
			_flametalMusketAlwaysRotate = Plugin._Instance.config(group3, "Always Rotate", Toggle.On, new ConfigDescription("If On, your character will always face the direction of your cursor.", (AcceptableValueBase)null, Array.Empty<object>()));
			_flametalMusketRecoil = Plugin._Instance.config(group3, "Recoil Pushback", 15f, new ConfigDescription("Recoil pushback.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			_flametalMusketReloadTime = Plugin._Instance.config(group3, "Reload Time", 1.9f, new ConfigDescription("Reload time.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.9f), Array.Empty<object>()));
			_flametalMusketReloadStamina = Plugin._Instance.config(group3, "Reload Stamina Drain", 3f, new ConfigDescription("Reload stamina drain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			string group4 = english.Localize("$bmm_rifle_flint");
			_flintRifleAlwaysRotate = Plugin._Instance.config(group4, "Always Rotate", Toggle.On, new ConfigDescription("If On, your character will always face the direction of your cursor.", (AcceptableValueBase)null, Array.Empty<object>()));
			_flintRifleRecoil = Plugin._Instance.config(group4, "Recoil Pushback", 15f, new ConfigDescription("Recoil pushback.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			_flintRifleReloadTime = Plugin._Instance.config(group4, "Reload Time", 1.9f, new ConfigDescription("Reload time.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.9f), Array.Empty<object>()));
			_flintRifleReloadStamina = Plugin._Instance.config(group4, "Reload Stamina Drain", 3f, new ConfigDescription("Reload stamina drain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			string group5 = english.Localize("$bmm_rifle_iron");
			_ironRifleAlwaysRotate = Plugin._Instance.config(group5, "Always Rotate", Toggle.On, new ConfigDescription("If On, your character will always face the direction of your cursor.", (AcceptableValueBase)null, Array.Empty<object>()));
			_ironRifleRecoil = Plugin._Instance.config(group5, "Recoil Pushback", 15f, new ConfigDescription("Recoil pushback.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			_ironRifleReloadTime = Plugin._Instance.config(group5, "Reload Time", 1.9f, new ConfigDescription("Reload time.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.9f), Array.Empty<object>()));
			_ironRifleReloadStamina = Plugin._Instance.config(group5, "Reload Stamina Drain", 3f, new ConfigDescription("Reload stamina drain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			string group6 = english.Localize("$bmm_rifle_silver");
			_silverRifleAlwaysRotate = Plugin._Instance.config(group6, "Always Rotate", Toggle.On, new ConfigDescription("If On, your character will always face the direction of your cursor.", (AcceptableValueBase)null, Array.Empty<object>()));
			_silverRifleRecoil = Plugin._Instance.config(group6, "Recoil Pushback", 15f, new ConfigDescription("Recoil pushback.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			_silverRifleReloadTime = Plugin._Instance.config(group6, "Reload Time", 1.9f, new ConfigDescription("Reload time.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1.9f), Array.Empty<object>()));
			_silverRifleReloadStamina = Plugin._Instance.config(group6, "Reload Stamina Drain", 3f, new ConfigDescription("Reload stamina drain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			string group7 = english.Localize("$bmm_bullet_copper");
			_copperBulletBluntDmg = Plugin._Instance.config(group7, "Blunt Damage", 32f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group8 = english.Localize("$bmm_bullet_flint");
			_flintBulletBluntDmg = Plugin._Instance.config(group8, "Blunt Damage", 22f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group9 = english.Localize("$bmm_bullet_blackmetal");
			_blackMetalBulletBluntDmg = Plugin._Instance.config(group9, "Blunt Damage", 62f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group10 = english.Localize("$bmm_bullet_carapace");
			_carapaceBulletBluntDmg = Plugin._Instance.config(group10, "Blunt Damage", 72f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group11 = english.Localize("$bmm_bullet_fire");
			_fireBulletBluntDmg = Plugin._Instance.config(group11, "Blunt Damage", 47f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			_fireBulletFireDmg = Plugin._Instance.config(group11, "Fire Damage", 72f, new ConfigDescription("Base fire damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group12 = english.Localize("$bmm_bullet_flametal");
			_flametalBulletBluntDmg = Plugin._Instance.config(group12, "Blunt Damage", 82f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group13 = english.Localize("$bmm_bullet_ice");
			_iceBulletBluntDmg = Plugin._Instance.config(group13, "Blunt Damage", 47f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			_iceBulletFrostDmg = Plugin._Instance.config(group13, "Frost Damage", 72f, new ConfigDescription("Base frost damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group14 = english.Localize("$bmm_bullet_iron");
			_ironBulletBluntDmg = Plugin._Instance.config(group14, "Blunt Damage", 42f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group15 = english.Localize("$bmm_bullet_lightning");
			_lightningBulletBluntDmg = Plugin._Instance.config(group15, "Blunt Damage", 47f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			_lightningBulletLightningDmg = Plugin._Instance.config(group15, "Lightning Damage", 72f, new ConfigDescription("Base lightning damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group16 = english.Localize("$bmm_bullet_poison");
			_poisonBulletBluntDmg = Plugin._Instance.config(group16, "Blunt Damage", 47f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			_poisonBulletPoisonDmg = Plugin._Instance.config(group16, "Poison Damage", 72f, new ConfigDescription("Base poison damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group17 = english.Localize("$bmm_bullet_silver");
			_silverBulletBluntDmg = Plugin._Instance.config(group17, "Blunt Damage", 52f, new ConfigDescription("Base blunt damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group18 = english.Localize("$bmm_piercingrounds_bone");
			_boneRoundsPierceDmg = Plugin._Instance.config(group18, "Pierce Damage", 22f, new ConfigDescription("Base pierce damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group19 = english.Localize("$bmm_piercingrounds_bronze");
			_bronzeRoundsPierceDmg = Plugin._Instance.config(group19, "Pierce Damage", 32f, new ConfigDescription("Base pierce damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group20 = english.Localize("$bmm_piercingrounds_ceramic");
			_ceramicRoundsPierceDmg = Plugin._Instance.config(group20, "Pierce Damage", 72f, new ConfigDescription("Base pierce damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group21 = english.Localize("$bmm_piercingrounds_charredbone");
			_charredRoundsPierceDmg = Plugin._Instance.config(group21, "Pierce Damage", 82f, new ConfigDescription("Base pierce damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group22 = english.Localize("$bmm_piercingrounds_chitin");
			_chitinRoundsPierceDmg = Plugin._Instance.config(group22, "Pierce Damage", 42f, new ConfigDescription("Base pierce damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group23 = english.Localize("$bmm_piercingrounds_fang");
			_fangRoundsPierceDmg = Plugin._Instance.config(group23, "Pierce Damage", 52f, new ConfigDescription("Base pierce damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
			string group24 = english.Localize("$bmm_piercingrounds_needle");
			_needleRoundsPierceDmg = Plugin._Instance.config(group24, "Pierce Damage", 62f, new ConfigDescription("Base pierce damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 150f), Array.Empty<object>()));
		}
	}
	public static class CycleBullets
	{
		public static void CycleBullet()
		{
			Player localPlayer = Player.m_localPlayer;
			if (CheckIfGunExist())
			{
				((Humanoid)localPlayer).EquipItem(EquipNextBullet(), true);
				ShowBulletEquipped();
			}
		}

		private static bool CheckIfGunExist()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "main")
			{
				return false;
			}
			Player localPlayer = Player.m_localPlayer;
			if (((Humanoid)localPlayer).GetCurrentWeapon() != null && ((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_ammoType != "$ammo_bullets")
			{
				return false;
			}
			if (string.IsNullOrEmpty(((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_ammoType))
			{
				List<ItemData> list = new List<ItemData>();
				((Humanoid)localPlayer).GetInventory().GetAllItems((ItemType)14, list);
				switch (list.Count)
				{
				case 0:
					((Character)localPlayer).Message((MessageType)2, "<size=28>$bmm_noguninventory</size>", 0, (Sprite)null);
					break;
				case 1:
					((Humanoid)localPlayer).EquipItem(list[0], true);
					ShowBulletEquipped();
					break;
				}
				return false;
			}
			switch (CountBulletStacks())
			{
			case 0:
				((Character)localPlayer).Message((MessageType)2, "<size=28>$bmm_nobulletinventory</size>", 0, (Sprite)null);
				return false;
			case 1:
				((Character)localPlayer).Message((MessageType)2, "<size=28>$bmm_onetypebullet</size>", 0, (Sprite)null);
				return true;
			default:
				return true;
			}
		}

		private static void ShowBulletEquipped()
		{
			Player localPlayer = Player.m_localPlayer;
			((Character)localPlayer).Message((MessageType)2, "<size=28><color=white>" + ((Humanoid)localPlayer).GetAmmoItem()?.m_shared.m_name + "</color> equipped.</size>", 0, (Sprite)null);
		}

		private static int CountBulletStacks()
		{
			int num = 0;
			List<string> list = new List<string>();
			foreach (ItemData item in from item in ((Humanoid)Player.m_localPlayer).GetInventory().GetAllItems()
				where (int)item.m_shared.m_itemType == 9 && (item.m_shared.m_name.StartsWith("$bmm_piercing") || item.m_shared.m_name.StartsWith("$bmm_bullet_")) && !list.Contains(item.m_shared.m_name)
				select item)
			{
				list.Add(item.m_shared.m_name);
				num++;
			}
			return num;
		}

		private static ItemData EquipNextBullet()
		{
			Player player = Player.m_localPlayer;
			ItemData ammoItem = ((Humanoid)player).GetAmmoItem();
			List<string> list = new List<string>();
			if (ammoItem == null || ammoItem.m_shared.m_ammoType != "$ammo_bullets")
			{
				return ((Humanoid)player).GetInventory().GetAmmoItem(((Humanoid)player).GetCurrentWeapon().m_shared.m_ammoType, (string)null);
			}
			int num = CalculateAmmo(((Humanoid)player).GetAmmoItem());
			int num2 = -1;
			ItemData result = null;
			foreach (ItemData item in from item in ((Humanoid)player).GetInventory().GetAllItems()
				where (int)item.m_shared.m_itemType == 9 && item.m_shared.m_ammoType == ((Humanoid)player).GetCurrentWeapon().m_shared.m_ammoType && (item.m_shared.m_name.StartsWith("$bmm_piercing") || item.m_shared.m_name.StartsWith("$bmm_bullet_")) && !list.Contains(item.m_shared.m_name)
				select item)
			{
				list.Add(item.m_shared.m_name);
				int num3 = CalculateAmmo(item);
				if (num3 > num && num2 == -1)
				{
					num2 = num3;
					result = item;
				}
				else if (num3 < num2 && num3 > num)
				{
					num2 = num3;
					result = item;
				}
			}
			if (num2 != -1)
			{
				return result;
			}
			return ((Humanoid)player).GetInventory().GetAmmoItem(((Humanoid)player).GetCurrentWeapon().m_shared.m_ammoType, (string)null);
		}

		private static int CalculateAmmo(ItemData item)
		{
			return item.m_gridPos.y * ((Humanoid)Player.m_localPlayer).GetInventory().GetWidth() + item.m_gridPos.x;
		}
	}
	[HarmonyPatch]
	public class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(ItemDrop), "Awake")]
		private static void Awake_Postfix(ItemDrop __instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "main" || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			string name = __instance.m_itemData.m_shared.m_name;
			if (name == null)
			{
				return;
			}
			switch (name.Length)
			{
			case 17:
				switch (name[11])
				{
				case 'b':
					if (name == "$bmm_rifle_bronze")
					{
						StatsSetup.BronzeRifle(__instance.m_itemData);
					}
					break;
				case 's':
					if (name == "$bmm_rifle_silver")
					{
						StatsSetup.SilverRifle(__instance.m_itemData);
					}
					break;
				case '_':
					if (name == "$bmm_bullet_flint")
					{
						StatsSetup.FlintBullet(__instance.m_itemData);
					}
					break;
				}
				break;
			case 20:
				switch (name[5])
				{
				case 'm':
					if (name == "$bmm_musket_flametal")
					{
						StatsSetup.FlametalMusket(__instance.m_itemData);
					}
					break;
				case 'b':
					if (!(name == "$bmm_bullet_carapace"))
					{
						if (name == "$bmm_bullet_flametal")
						{
							StatsSetup.FlametalBullet(__instance.m_itemData);
						}
					}
					else
					{
						StatsSetup.CarapaceBullet(__instance.m_itemData);
					}
					break;
				}
				break;
			case 16:
				switch (name[12])
				{
				case 'l':
					if (name == "$bmm_rifle_flint")
					{
						StatsSetup.FlintRifle(__instance.m_itemData);
					}
					break;
				case 'f':
					if (name == "$bmm_bullet_fire")
					{
						StatsSetup.FireBullet(__instance.m_itemData);
					}
					break;
				case 'i':
					if (name == "$bmm_bullet_iron")
					{
						StatsSetup.IronBullet(__instance.m_itemData);
					}
					break;
				}
				break;
			case 15:
				switch (name[5])
				{
				case 'r':
					if (name == "$bmm_rifle_iron")
					{
						StatsSetup.IronRifle(__instance.m_itemData);
					}
					break;
				case 'b':
					if (name == "$bmm_bullet_ice")
					{
						StatsSetup.IceBullet(__instance.m_itemData);
					}
					break;
				}
				break;
			case 18:
				switch (name[12])
				{
				case 'p':
					if (name == "$bmm_bullet_poison")
					{
						StatsSetup.PoisonBullet(__instance.m_itemData);
					}
					break;
				case 's':
					if (name == "$bmm_bullet_silver")
					{
						StatsSetup.SilverBullet(__instance.m_itemData);
					}
					break;
				case 'c':
					if (name == "$bmm_bullet_copper")
					{
						StatsSetup.CopperBullet(__instance.m_itemData);
					}
					break;
				}
				break;
			case 24:
				switch (name[20])
				{
				case 'b':
					if (name == "$bmm_piercingrounds_bone")
					{
						StatsSetup.BoneRounds(__instance.m_itemData);
					}
					break;
				case 'f':
					if (name == "$bmm_piercingrounds_fang")
					{
						StatsSetup.FangRounds(__instance.m_itemData);
					}
					break;
				}
				break;
			case 26:
				switch (name[20])
				{
				case 'b':
					if (name == "$bmm_piercingrounds_bronze")
					{
						StatsSetup.BronzeRounds(__instance.m_itemData);
					}
					break;
				case 'c':
					if (name == "$bmm_piercingrounds_chitin")
					{
						StatsSetup.ChitinRounds(__instance.m_itemData);
					}
					break;
				case 'n':
					if (name == "$bmm_piercingrounds_needle")
					{
						StatsSetup.NeedleRounds(__instance.m_itemData);
					}
					break;
				}
				break;
			case 23:
				if (name == "$bmm_shotgun_blackmetal")
				{
					StatsSetup.BlackMetalShotGun(__instance.m_itemData);
				}
				break;
			case 22:
				if (name == "$bmm_bullet_blackmetal")
				{
					StatsSetup.BlackMetalBullet(__instance.m_itemData);
				}
				break;
			case 21:
				if (name == "$bmm_bullet_lightning")
				{
					StatsSetup.LightningBullet(__instance.m_itemData);
				}
				break;
			case 27:
				if (name == "$bmm_piercingrounds_ceramic")
				{
					StatsSetup.CeramicRounds(__instance.m_itemData);
				}
				break;
			case 31:
				if (name == "$bmm_piercingrounds_charredbone")
				{
					StatsSetup.CharredRounds(__instance.m_itemData);
				}
				break;
			case 19:
			case 25:
			case 28:
			case 29:
			case 30:
				break;
			}
		}
	}
	public static class SetupPrefabs
	{
		private static AssetBundle _gunzBundle;

		public static void Init()
		{
			_gunzBundle = PrefabManager.RegisterAssetBundle("gunzbundle");
			Guns();
			Bullets();
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_fx_block_camshake");
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_fx_bullet_hit");
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_fx_DvergerMage_Ice_hit");
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_fx_firebullet_explosion");
			ShaderReplacer.Replace(PrefabManager.RegisterPrefab(_gunzBundle, "bmm_fx_lightningbulletprojectile_hit"));
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_fx_poisonbullet_explosion");
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_fx_swing_camshake");
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_sfx_bow_draw");
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_sfx_staff_lightning_fire");
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_sfx_wood_blocked");
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_vfx_blocked");
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_vfx_lightningstaff_fire");
		}

		private static void Guns()
		{
			Item item = new Item(_gunzBundle, "BMM_BlackMetalShotGun");
			item.Crafting.Add(CraftingTable.Forge, 1);
			item.RequiredItems.Add("Thunderstone", 5);
			item.RequiredItems.Add("BlackMetal", 48);
			item.RequiredItems.Add("Iron", 36);
			item.RequiredItems.Add("SerpentScale", 6);
			item.RequiredUpgradeItems.Add("BlackMetal", 24, 2);
			item.RequiredUpgradeItems.Add("Iron", 18, 2);
			item.RequiredUpgradeItems.Add("SerpentScale", 3, 2);
			item.RequiredUpgradeItems.Add("Mandible", 12, 3);
			item.RequiredUpgradeItems.Add("BlackMetal", 24, 3);
			item.RequiredUpgradeItems.Add("Carapace", 6, 3);
			item.RequiredUpgradeItems.Add("Mandible", 12, 4);
			item.RequiredUpgradeItems.Add("BlackMetal", 24, 4);
			item.RequiredUpgradeItems.Add("Carapace", 6, 4);
			item.Configurable = Configurability.Full;
			StatsSetup.BlackMetalShotGun(item.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item2 = new Item(_gunzBundle, "BMM_BronzeRifle");
			item2.Crafting.Add(CraftingTable.Forge, 1);
			item2.RequiredItems.Add("Coal", 10);
			item2.RequiredItems.Add("Bronze", 18);
			item2.RequiredItems.Add("Copper", 8);
			item2.RequiredItems.Add("FineWood", 32);
			item2.RequiredUpgradeItems.Add("Bronze", 9);
			item2.RequiredUpgradeItems.Add("Copper", 4);
			item2.RequiredUpgradeItems.Add("FineWood", 16);
			item2.Configurable = Configurability.Full;
			StatsSetup.BronzeRifle(item2.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item3 = new Item(_gunzBundle, "BMM_FlametalMusket");
			item3.Crafting.Add(CraftingTable.BlackForge, 1);
			item3.RequiredItems.Add("GemstoneRed", 2);
			item3.RequiredItems.Add("FlametalNew", 36);
			item3.RequiredItems.Add("Blackwood", 28);
			item3.RequiredItems.Add("CeramicPlate", 18);
			item3.RequiredUpgradeItems.Add("FlametalNew", 18);
			item3.RequiredUpgradeItems.Add("Blackwood", 14);
			item3.RequiredUpgradeItems.Add("CeramicPlate", 9);
			item3.Configurable = Configurability.Full;
			StatsSetup.FlametalMusket(item3.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item4 = new Item(_gunzBundle, "BMM_FlintRifle");
			item4.Crafting.Add(CraftingTable.Workbench, 1);
			item4.RequiredItems.Add("BoneFragments", 2);
			item4.RequiredItems.Add("Flint", 8);
			item4.RequiredItems.Add("Stone", 4);
			item4.RequiredItems.Add("Wood", 14);
			item4.RequiredUpgradeItems.Add("Flint", 4);
			item4.RequiredUpgradeItems.Add("Stone", 2);
			item4.RequiredUpgradeItems.Add("Wood", 7);
			item4.Configurable = Configurability.Full;
			StatsSetup.FlintRifle(item4.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item5 = new Item(_gunzBundle, "BMM_IronRifle");
			item5.Crafting.Add(CraftingTable.Forge, 1);
			item5.RequiredItems.Add("Chain", 2);
			item5.RequiredItems.Add("Iron", 32);
			item5.RequiredItems.Add("Bronze", 18);
			item5.RequiredItems.Add("ElderBark", 36);
			item5.RequiredUpgradeItems.Add("Iron", 16);
			item5.RequiredUpgradeItems.Add("Bronze", 9);
			item5.RequiredUpgradeItems.Add("ElderBark", 18);
			item5.Configurable = Configurability.Full;
			StatsSetup.IronRifle(item5.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item6 = new Item(_gunzBundle, "BMM_SilverRifle");
			item6.Crafting.Add(CraftingTable.Forge, 1);
			item6.RequiredItems.Add("Chain", 2);
			item6.RequiredItems.Add("Silver", 42);
			item6.RequiredItems.Add("Iron", 26);
			item6.RequiredItems.Add("FineWood", 38);
			item6.RequiredUpgradeItems.Add("Silver", 21);
			item6.RequiredUpgradeItems.Add("Iron", 13);
			item6.RequiredUpgradeItems.Add("FineWood", 19);
			item6.Configurable = Configurability.Full;
			StatsSetup.SilverRifle(item6.Prefab.GetComponent<ItemDrop>().m_itemData);
		}

		private static void Bullets()
		{
			Item item = new Item(_gunzBundle, "BMM_BlackMetalBullet");
			item.Crafting.Add(CraftingTable.Forge, 1);
			item.CraftAmount = 20;
			item.RequiredItems.Add("BlackMetal", 10);
			item.RequiredItems.Add("Obsidian", 10);
			item.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_blackmetalbullet_projectile");
			StatsSetup.BlackMetalBullet(item.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item2 = new Item(_gunzBundle, "BMM_CarapaceBullet");
			item2.Crafting.Add(CraftingTable.Forge, 1);
			item2.CraftAmount = 20;
			item2.RequiredItems.Add("Carapace", 10);
			item2.RequiredItems.Add("Iron", 5);
			item2.RequiredItems.Add("Sap", 5);
			item2.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_carapacebullet_projectile");
			StatsSetup.CarapaceBullet(item2.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item3 = new Item(_gunzBundle, "BMM_FireBullet");
			item3.Crafting.Add(CraftingTable.Forge, 1);
			item3.CraftAmount = 20;
			item3.RequiredItems.Add("Iron", 10);
			item3.RequiredItems.Add("Obsidian", 10);
			item3.RequiredItems.Add("Resin", 10);
			item3.RequiredItems.Add("Eitr", 5);
			item3.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_firesbullet_projectile");
			StatsSetup.FireBullet(item3.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item4 = new Item(_gunzBundle, "BMM_FlametalBullet");
			item4.Crafting.Add(CraftingTable.Forge, 1);
			item4.CraftAmount = 20;
			item4.RequiredItems.Add("FlametalOreNew", 10);
			item4.RequiredItems.Add("CharcoalResin", 10);
			item4.RequiredItems.Add("SulfurStone", 5);
			item4.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_flametalbullet_projectile");
			StatsSetup.FlametalBullet(item4.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item5 = new Item(_gunzBundle, "BMM_IceBullet");
			item5.Crafting.Add(CraftingTable.Forge, 1);
			item5.CraftAmount = 20;
			item5.RequiredItems.Add("Silver", 10);
			item5.RequiredItems.Add("FreezeGland", 10);
			item5.RequiredItems.Add("Crystal", 5);
			item5.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_icebullet_projectile");
			StatsSetup.IceBullet(item5.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item6 = new Item(_gunzBundle, "BMM_IronBullet");
			item6.Crafting.Add(CraftingTable.Forge, 1);
			item6.CraftAmount = 20;
			item6.RequiredItems.Add("Iron", 10);
			item6.RequiredItems.Add("Resin", 10);
			item6.RequiredItems.Add("Coal", 5);
			item6.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_ironbullet_projectile");
			StatsSetup.IronBullet(item6.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item7 = new Item(_gunzBundle, "BMM_LightningBullet");
			item7.Crafting.Add(CraftingTable.Forge, 1);
			item7.CraftAmount = 20;
			item7.RequiredItems.Add("Silver", 10);
			item7.RequiredItems.Add("Chitin", 5);
			item7.RequiredItems.Add("Obsidian", 10);
			item7.RequiredItems.Add("Eitr", 5);
			item7.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_lightningbullet_projectile");
			StatsSetup.LightningBullet(item7.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item8 = new Item(_gunzBundle, "BMM_PoisonBullet");
			item8.Crafting.Add(CraftingTable.Forge, 1);
			item8.CraftAmount = 20;
			item8.RequiredItems.Add("BlackMetal", 10);
			item8.RequiredItems.Add("Guck", 10);
			item8.RequiredItems.Add("Ooze", 10);
			item8.RequiredItems.Add("Eitr", 5);
			item8.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_poison_projectile");
			StatsSetup.PoisonBullet(item8.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item9 = new Item(_gunzBundle, "BMM_SilverBullet");
			item9.Crafting.Add(CraftingTable.Forge, 1);
			item9.CraftAmount = 20;
			item9.RequiredItems.Add("Silver", 10);
			item9.RequiredItems.Add("Obsidian", 10);
			item9.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_silverbullet_projectile");
			StatsSetup.SilverBullet(item9.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item10 = new Item(_gunzBundle, "BMM_CopperBullet");
			item10.Crafting.Add(CraftingTable.Forge, 1);
			item10.CraftAmount = 20;
			item10.RequiredItems.Add("Copper", 10);
			item10.RequiredItems.Add("Coal", 10);
			item10.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_copperbullet_projectile");
			StatsSetup.CopperBullet(item10.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item11 = new Item(_gunzBundle, "BMM_FlintBullet");
			item11.Crafting.Add(CraftingTable.Workbench, 1);
			item11.CraftAmount = 20;
			item11.RequiredItems.Add("Flint", 5);
			item11.RequiredItems.Add("Stone", 5);
			item11.RequiredItems.Add("Resin", 2);
			item11.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_flintbullet_projectile");
			StatsSetup.FlintBullet(item11.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item12 = new Item(_gunzBundle, "BMM_PiercingRounds_Bone");
			item12.Crafting.Add(CraftingTable.Workbench, 1);
			item12.CraftAmount = 20;
			item12.RequiredItems.Add("BoneFragments", 5);
			item12.RequiredItems.Add("Stone", 5);
			item12.RequiredItems.Add("Resin", 2);
			item12.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_piercingbone_projectile");
			StatsSetup.BoneRounds(item12.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item13 = new Item(_gunzBundle, "BMM_PiercingRounds_Bronze");
			item13.Crafting.Add(CraftingTable.Forge, 1);
			item13.CraftAmount = 20;
			item13.RequiredItems.Add("Bronze", 5);
			item13.RequiredItems.Add("Coal", 10);
			item13.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_piercingbronze_projectile");
			StatsSetup.BronzeRounds(item13.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item14 = new Item(_gunzBundle, "BMM_PiercingRounds_Ceramic");
			item14.Crafting.Add(CraftingTable.BlackForge, 1);
			item14.CraftAmount = 20;
			item14.RequiredItems.Add("BlackMarble", 10);
			item14.RequiredItems.Add("Iron", 5);
			item14.RequiredItems.Add("Coal", 5);
			item14.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_piercingceramic_projectile");
			StatsSetup.CeramicRounds(item14.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item15 = new Item(_gunzBundle, "BMM_PiercingRounds_CharredBone");
			item15.Crafting.Add(CraftingTable.BlackForge, 1);
			item15.CraftAmount = 20;
			item15.RequiredItems.Add("CharredBone", 10);
			item15.RequiredItems.Add("Iron", 10);
			item15.RequiredItems.Add("SulfurStone", 5);
			item15.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_piercingcharred_projectile");
			StatsSetup.CharredRounds(item15.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item16 = new Item(_gunzBundle, "BMM_PiercingRounds_Chitin");
			item16.Crafting.Add(CraftingTable.Forge, 1);
			item16.CraftAmount = 20;
			item16.RequiredItems.Add("Chitin", 5);
			item16.RequiredItems.Add("Iron", 10);
			item16.RequiredItems.Add("Coal", 5);
			item16.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_piercingchitin_projectile");
			StatsSetup.ChitinRounds(item16.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item17 = new Item(_gunzBundle, "BMM_PiercingRounds_Fang");
			item17.Crafting.Add(CraftingTable.Forge, 1);
			item17.CraftAmount = 20;
			item17.RequiredItems.Add("WolfFang", 5);
			item17.RequiredItems.Add("Silver", 5);
			item17.RequiredItems.Add("Obsidian", 5);
			item17.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_piercingfang_projectile");
			StatsSetup.FangRounds(item17.Prefab.GetComponent<ItemDrop>().m_itemData);
			Item item18 = new Item(_gunzBundle, "BMM_PiercingRounds_Needle");
			item18.Crafting.Add(CraftingTable.Forge, 1);
			item18.CraftAmount = 20;
			item18.RequiredItems.Add("Needle", 5);
			item18.RequiredItems.Add("BlackMetal", 5);
			item18.RequiredItems.Add("Coal", 5);
			item18.Configurable = Configurability.Full;
			PrefabManager.RegisterPrefab(_gunzBundle, "bmm_piercingneedle_projectile");
			StatsSetup.NeedleRounds(item18.Prefab.GetComponent<ItemDrop>().m_itemData);
		}
	}
	public static class ShaderReplacer
	{
		private static readonly List<GameObject> GOToSwap;

		static ShaderReplacer()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			GOToSwap = new List<GameObject>();
			new Harmony("blacks7ar.utilities.ShaderReplacer").Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(ShaderReplacer), "ReplaceShaderPatch", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static void Replace(GameObject gameObject)
		{
			GOToSwap.Add(gameObject);
		}

		[HarmonyPriority(700)]
		private static void ReplaceShaderPatch()
		{
			foreach (Material item in from gameObject in GOToSwap
				select gameObject.GetComponentsInChildren<Renderer>(true) into renderers
				from renderer in renderers
				where (Object)(object)renderer != (Object)null
				from material in renderer.sharedMaterials
				where (Object)(object)material != (Object)null
				select material)
			{
				Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
				foreach (Shader val in array)
				{
					if (((Object)item.shader).name == ((Object)val).name)
					{
						item.shader = val;
					}
				}
			}
		}
	}
	public static class StatsSetup
	{
		public static void BlackMetalShotGun(ItemData item)
		{
			ConfigSetup._blackMetalShotGunAlwaysRotate.SettingChanged += delegate
			{
				item.m_shared.m_alwaysRotate = ConfigSetup._blackMetalShotGunAlwaysRotate.Value == Toggle.On;
			};
			item.m_shared.m_alwaysRotate = ConfigSetup._blackMetalShotGunAlwaysRotate.Value == Toggle.On;
			ConfigSetup._blackMetalShotGunRecoil.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_recoilPushback = ConfigSetup._blackMetalShotGunRecoil.Value;
			};
			item.m_shared.m_attack.m_recoilPushback = ConfigSetup._blackMetalShotGunRecoil.Value;
			ConfigSetup._blackMetalShotGunReloadStamina.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._blackMetalShotGunReloadStamina.Value;
			};
			item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._blackMetalShotGunReloadStamina.Value;
			ConfigSetup._blackMetalShotGunReloadTime.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadTime = ConfigSetup._blackMetalShotGunReloadTime.Value;
			};
		}

		public static void BronzeRifle(ItemData item)
		{
			ConfigSetup._bronzeRifleAlwaysRotate.SettingChanged += delegate
			{
				item.m_shared.m_alwaysRotate = ConfigSetup._bronzeRifleAlwaysRotate.Value == Toggle.On;
			};
			item.m_shared.m_alwaysRotate = ConfigSetup._bronzeRifleAlwaysRotate.Value == Toggle.On;
			ConfigSetup._bronzeRifleRecoil.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_recoilPushback = ConfigSetup._bronzeRifleRecoil.Value;
			};
			item.m_shared.m_attack.m_recoilPushback = ConfigSetup._bronzeRifleRecoil.Value;
			ConfigSetup._bronzeRifleReloadStamina.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._bronzeRifleReloadStamina.Value;
			};
			item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._bronzeRifleReloadStamina.Value;
			ConfigSetup._bronzeRifleReloadTime.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadTime = ConfigSetup._bronzeRifleReloadTime.Value;
			};
			item.m_shared.m_attack.m_reloadTime = ConfigSetup._bronzeRifleReloadTime.Value;
		}

		public static void FlametalMusket(ItemData item)
		{
			ConfigSetup._flametalMusketAlwaysRotate.SettingChanged += delegate
			{
				item.m_shared.m_alwaysRotate = ConfigSetup._flametalMusketAlwaysRotate.Value == Toggle.On;
			};
			item.m_shared.m_alwaysRotate = ConfigSetup._flametalMusketAlwaysRotate.Value == Toggle.On;
			ConfigSetup._flametalMusketRecoil.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_recoilPushback = ConfigSetup._flametalMusketRecoil.Value;
			};
			item.m_shared.m_attack.m_recoilPushback = ConfigSetup._flametalMusketRecoil.Value;
			ConfigSetup._flametalMusketReloadStamina.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._flametalMusketReloadStamina.Value;
			};
			item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._flametalMusketReloadStamina.Value;
			ConfigSetup._flametalMusketReloadTime.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadTime = ConfigSetup._flametalMusketReloadTime.Value;
			};
			item.m_shared.m_attack.m_reloadTime = ConfigSetup._flametalMusketReloadTime.Value;
		}

		public static void FlintRifle(ItemData item)
		{
			ConfigSetup._flintRifleAlwaysRotate.SettingChanged += delegate
			{
				item.m_shared.m_alwaysRotate = ConfigSetup._flintRifleAlwaysRotate.Value == Toggle.On;
			};
			item.m_shared.m_alwaysRotate = ConfigSetup._flintRifleAlwaysRotate.Value == Toggle.On;
			ConfigSetup._flintRifleRecoil.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_recoilPushback = ConfigSetup._flintRifleRecoil.Value;
			};
			item.m_shared.m_attack.m_recoilPushback = ConfigSetup._flintRifleRecoil.Value;
			ConfigSetup._flintRifleReloadStamina.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._flintRifleReloadStamina.Value;
			};
			item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._flintRifleReloadStamina.Value;
			ConfigSetup._flintRifleReloadTime.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadTime = ConfigSetup._flintRifleReloadTime.Value;
			};
			item.m_shared.m_attack.m_reloadTime = ConfigSetup._flintRifleReloadTime.Value;
		}

		public static void IronRifle(ItemData item)
		{
			ConfigSetup._ironRifleAlwaysRotate.SettingChanged += delegate
			{
				item.m_shared.m_alwaysRotate = ConfigSetup._ironRifleAlwaysRotate.Value == Toggle.On;
			};
			item.m_shared.m_alwaysRotate = ConfigSetup._ironRifleAlwaysRotate.Value == Toggle.On;
			ConfigSetup._ironRifleRecoil.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_recoilPushback = ConfigSetup._ironRifleRecoil.Value;
			};
			item.m_shared.m_attack.m_recoilPushback = ConfigSetup._ironRifleRecoil.Value;
			ConfigSetup._ironRifleReloadStamina.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._ironRifleReloadStamina.Value;
			};
			item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._ironRifleReloadStamina.Value;
			ConfigSetup._ironRifleReloadTime.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadTime = ConfigSetup._ironRifleReloadTime.Value;
			};
			item.m_shared.m_attack.m_reloadTime = ConfigSetup._ironRifleReloadTime.Value;
		}

		public static void SilverRifle(ItemData item)
		{
			ConfigSetup._silverRifleAlwaysRotate.SettingChanged += delegate
			{
				item.m_shared.m_alwaysRotate = ConfigSetup._silverRifleAlwaysRotate.Value == Toggle.On;
			};
			item.m_shared.m_alwaysRotate = ConfigSetup._silverRifleAlwaysRotate.Value == Toggle.On;
			ConfigSetup._silverRifleRecoil.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_recoilPushback = ConfigSetup._silverRifleRecoil.Value;
			};
			item.m_shared.m_attack.m_recoilPushback = ConfigSetup._silverRifleRecoil.Value;
			ConfigSetup._silverRifleReloadStamina.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._silverRifleReloadStamina.Value;
			};
			item.m_shared.m_attack.m_reloadStaminaDrain = ConfigSetup._silverRifleReloadStamina.Value;
			ConfigSetup._silverRifleReloadTime.SettingChanged += delegate
			{
				item.m_shared.m_attack.m_reloadTime = ConfigSetup._silverRifleReloadTime.Value;
			};
			item.m_shared.m_attack.m_reloadTime = ConfigSetup._silverRifleReloadTime.Value;
		}

		public static void FlintBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._flintBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._flintBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._flintBulletBluntDmg.Value;
		}

		public static void CopperBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._copperBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._copperBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._copperBulletBluntDmg.Value;
		}

		public static void BlackMetalBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._blackMetalBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._blackMetalBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._blackMetalBulletBluntDmg.Value;
		}

		public static void CarapaceBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._carapaceBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._carapaceBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._carapaceBulletBluntDmg.Value;
		}

		public static void FireBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._fireBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._fireBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._fireBulletBluntDmg.Value;
			ConfigSetup._fireBulletFireDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_fire = ConfigSetup._fireBulletFireDmg.Value;
			};
			item.m_shared.m_damages.m_fire = ConfigSetup._fireBulletFireDmg.Value;
		}

		public static void FlametalBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._flametalBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._flametalBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._flametalBulletBluntDmg.Value;
		}

		public static void IceBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._iceBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._iceBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._iceBulletBluntDmg.Value;
			ConfigSetup._iceBulletFrostDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_frost = ConfigSetup._iceBulletFrostDmg.Value;
			};
			item.m_shared.m_damages.m_frost = ConfigSetup._iceBulletFrostDmg.Value;
		}

		public static void IronBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._ironBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._ironBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._ironBulletBluntDmg.Value;
		}

		public static void LightningBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._lightningBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._lightningBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._lightningBulletBluntDmg.Value;
			ConfigSetup._lightningBulletLightningDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_lightning = ConfigSetup._lightningBulletLightningDmg.Value;
			};
			item.m_shared.m_damages.m_lightning = ConfigSetup._lightningBulletLightningDmg.Value;
		}

		public static void PoisonBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._poisonBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._poisonBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._poisonBulletBluntDmg.Value;
			ConfigSetup._poisonBulletPoisonDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_poison = ConfigSetup._poisonBulletPoisonDmg.Value;
			};
			item.m_shared.m_damages.m_poison = ConfigSetup._poisonBulletPoisonDmg.Value;
		}

		public static void SilverBullet(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._silverBulletBluntDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_blunt = ConfigSetup._silverBulletBluntDmg.Value;
			};
			item.m_shared.m_damages.m_blunt = ConfigSetup._silverBulletBluntDmg.Value;
		}

		public static void BoneRounds(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._boneRoundsPierceDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_pierce = ConfigSetup._boneRoundsPierceDmg.Value;
			};
			item.m_shared.m_damages.m_pierce = ConfigSetup._boneRoundsPierceDmg.Value;
		}

		public static void BronzeRounds(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._bronzeRoundsPierceDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_pierce = ConfigSetup._bronzeRoundsPierceDmg.Value;
			};
			item.m_shared.m_damages.m_pierce = ConfigSetup._bronzeRoundsPierceDmg.Value;
		}

		public static void CeramicRounds(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._ceramicRoundsPierceDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_pierce = ConfigSetup._ceramicRoundsPierceDmg.Value;
			};
			item.m_shared.m_damages.m_pierce = ConfigSetup._ceramicRoundsPierceDmg.Value;
		}

		public static void CharredRounds(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._charredRoundsPierceDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_pierce = ConfigSetup._charredRoundsPierceDmg.Value;
			};
			item.m_shared.m_damages.m_pierce = ConfigSetup._charredRoundsPierceDmg.Value;
		}

		public static void ChitinRounds(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._chitinRoundsPierceDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_pierce = ConfigSetup._chitinRoundsPierceDmg.Value;
			};
			item.m_shared.m_damages.m_pierce = ConfigSetup._chitinRoundsPierceDmg.Value;
		}

		public static void FangRounds(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._fangRoundsPierceDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_pierce = ConfigSetup._fangRoundsPierceDmg.Value;
			};
			item.m_shared.m_damages.m_pierce = ConfigSetup._fangRoundsPierceDmg.Value;
		}

		public static void NeedleRounds(ItemData item)
		{
			Plugin._bulletMaxStackSize.SettingChanged += delegate
			{
				item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			};
			item.m_shared.m_maxStackSize = Plugin._bulletMaxStackSize.Value;
			ConfigSetup._needleRoundsPierceDmg.SettingChanged += delegate
			{
				item.m_shared.m_damages.m_pierce = ConfigSetup._needleRoundsPierceDmg.Value;
			};
			item.m_shared.m_damages.m_pierce = ConfigSetup._needleRoundsPierceDmg.Value;
		}
	}
	public enum Toggle
	{
		On = 1,
		Off = 0
	}
}
namespace ItemManager
{
	[PublicAPI]
	public enum CraftingTable
	{
		Disabled,
		Inventory,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[InternalName("blackforge")]
		BlackForge,
		Custom
	}
	[PublicAPI]
	public enum ConversionPiece
	{
		Disabled,
		[InternalName("smelter")]
		Smelter,
		[InternalName("charcoal_kiln")]
		CharcoalKiln,
		[InternalName("blastfurnace")]
		BlastFurnace,
		[InternalName("windmill")]
		Windmill,
		[InternalName("piece_spinningwheel")]
		SpinningWheel,
		[InternalName("eitrrefinery")]
		EitrRefinery,
		Custom
	}
	public class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	public class RequiredResourceList
	{
		public readonly List<Requirement> Requirements = new List<Requirement>();

		public bool Free;

		public void Add(string itemName, int amount, int quality = 0)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amount = amount,
				quality = quality
			});
		}

		public void Add(string itemName, ConfigEntry<int> amountConfig, int quality = 0)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amountConfig = amountConfig,
				quality = quality
			});
		}
	}
	[PublicAPI]
	public class CraftingStationList
	{
		public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>();

		public void Add(CraftingTable table, int level)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = table,
				level = level
			});
		}

		public void Add(string customTable, int level)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = CraftingTable.Custom,
				level = level,
				custom = customTable
			});
		}
	}
	[PublicAPI]
	public class ItemRecipe
	{
		public readonly RequiredResourceList RequiredItems = new RequiredResourceList();

		public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList();

		public readonly CraftingStationList Crafting = new CraftingStationList();

		public int CraftAmount = 1;

		public bool RequireOnlyOneIngredient;

		public float QualityResultAmountMultiplier = 1f;

		public ConfigEntryBase? RecipeIsActive;
	}
	[PublicAPI]
	public class Trade
	{
		public Trader Trader;

		public uint Price;

		public uint Stack = 1u;

		public string? RequiredGlobalKey;
	}
	[PublicAPI]
	[Flags]
	public enum Trader
	{
		None = 0,
		Haldor = 1,
		Hildir = 2
	}
	public struct Requirement
	{
		public string itemName;

		public int amount;

		public ConfigEntry<int>? amountConfig;

		[Description("Set to a non-zero value to apply the requirement only for a specific quality")]
		public int quality;
	}
	public struct CraftingStationConfig
	{
		public CraftingTable Table;

		public int level;

		public string? custom;
	}
	[Flags]
	public enum Configurability
	{
		Disabled = 0,
		Recipe = 1,
		Stats = 2,
		Drop = 4,
		Trader = 8,
		Full = 0xF
	}
	[PublicAPI]
	public class DropTargets
	{
		public readonly List<DropTarget> Drops = new List<DropTarget>();

		public void Add(string creatureName, float chance, int min = 1, int? max = null, bool levelMultiplier = true)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = (max ?? min),
				levelMultiplier = levelMultiplier
			});
		}
	}
	public struct DropTarget
	{
		public string creature;

		public int min;

		public int max;

		public float chance;

		public bool levelMultiplier;
	}
	public enum Toggle
	{
		On = 1,
		Off = 0
	}
	[PublicAPI]
	public class Item
	{
		private class ItemConfig
		{
			public ConfigEntry<string>? craft;

			public ConfigEntry<string>? upgrade;

			public ConfigEntry<CraftingTable> table;

			public ConfigEntry<int> tableLevel;

			public ConfigEntry<string> customTable;

			public ConfigEntry<int>? maximumTableLevel;

			public ConfigEntry<Toggle> requireOneIngredient;

			public ConfigEntry<float> qualityResultAmountMultiplier;
		}

		private class TraderConfig
		{
			public ConfigEntry<Trader> trader;

			public ConfigEntry<uint> price;

			public ConfigEntry<uint> stack;

			public ConfigEntry<string> requiredGlobalKey;
		}

		private class RequirementQuality
		{
			public int quality;
		}

		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[UsedImplicitly]
			public string? Category;

			[UsedImplicitly]
			public Action<ConfigEntryBase>? CustomDrawer;

			public Func<bool>? browsability;
		}

		[PublicAPI]
		public enum DamageModifier
		{
			Normal,
			Resistant,
			Weak,
			Immune,
			Ignore,
			VeryResistant,
			VeryWeak,
			None
		}

		private delegate void setDmgFunc(ref DamageTypes dmg, float value);

		private class SerializedRequirements
		{
			public readonly List<Requirement> Reqs;

			public SerializedRequirements(List<Requirement> reqs)
			{
				Reqs = reqs;
			}

			public SerializedRequirements(string reqs)
				: this(reqs.Split(new char[1] { ',' }).Select(delegate(string r)
				{
					string[] array = r.Split(new char[1] { ':' });
					Requirement result = default(Requirement);
					result.itemName = array[0];
					result.amount = ((array.Length <= 1 || !int.TryParse(array[1], out var result2)) ? 1 : result2);
					result.quality = ((array.Length > 2 && int.TryParse(array[2], out var result3)) ? result3 : 0);
					return result;
				}).ToList())
			{
			}

			public override string ToString()
			{
				return string.Join(",", Reqs.Select((Requirement r) => $"{r.itemName}:{r.amount}" + ((r.quality > 0) ? $":{r.quality}" : "")));
			}

			public static ItemDrop? fetchByName(ObjectDB objectDB, string name)
			{
				GameObject itemPrefab = objectDB.GetItemPrefab(name);
				ItemDrop obj = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					Debug.LogWarning((object)("The required item '" + name + "' does not exist."));
				}
				return obj;
			}

			public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade)
			{
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0185: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Expected O, but got Unknown
				//IL_0194: Expected O, but got Unknown
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Expected O, but got Unknown
				Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)((Requirement r) => r.itemName), (Func<Requirement, Requirement>)delegate(Requirement r)
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0036: Unknown result type (might be due to invalid IL or missing references)
					//IL_003e: Expected O, but got Unknown
					ItemDrop val6 = ResItem(r);
					return (val6 != null) ? new Requirement
					{
						m_amount = (r.amountConfig?.Value ?? r.amount),
						m_resItem = val6,
						m_amountPerLevel = 0
					} : ((Requirement)null);
				});
				List<Requirement> list = dictionary.Values.Where((Requirement v) => v != null).ToList();
				foreach (Requirement item in upgrade.Reqs.Where((Requirement r) => r.itemName != ""))
				{
					if (item.quality > 0)
					{
						ItemDrop val = ResItem(item);
						if (val != null)
						{
							Requirement val2 = new Requirement
							{
								m_resItem = val,
								m_amountPerLevel = (item.amountConfig?.Value ?? item.amount),
								m_amount = 0
							};
							list.Add(val2);
							requirementQuality.Add(val2, new RequirementQuality
							{
								quality = item.quality
							});
						}
						continue;
					}
					if (!dictionary.TryGetValue(item.itemName, out var value) || value == null)
					{
						ItemDrop val3 = ResItem(item);
						if (val3 != null)
						{
							string itemName = item.itemName;
							Requirement val4 = new Requirement
							{
								m_resItem = val3,
								m_amount = 0
							};
							Requirement val5 = val4;
							dictionary[itemName] = val4;
							value = val5;
							list.Add(value);
						}
					}
					if (value != null)
					{
						value.m_amountPerLevel = item.amountConfig?.Value ?? item.amount;
					}
				}
				return list.ToArray();
				ItemDrop? ResItem(Requirement r)
				{
					return fetchByName(objectDB, r.itemName);
				}
			}
		}

		private class SerializedDrop
		{
			public readonly List<DropTarget> Drops;

			public SerializedDrop(List<DropTarget> drops)
			{
				Drops = drops;
			}

			public SerializedDrop(string drops)
			{
				Drops = ((drops == "") ? ((IEnumerable<string>)Array.Empty<string>()) : ((IEnumerable<string>)drops.Split(new char[1] { ',' }))).Select(delegate(string r)
				{
					string[] array = r.Split(new char[1] { ':' });
					if (array.Length <= 2 || !int.TryParse(array[2], out var result))
					{
						result = 1;
					}
					if (array.Length <= 3 || !int.TryParse(array[3], out var result2))
					{
						result2 = result;
					}
					bool levelMultiplier = array.Length <= 4 || array[4] != "0";
					DropTarget result3 = default(DropTarget);
					result3.creature = array[0];
					result3.chance = ((array.Length > 1 && float.TryParse(array[1], out var result4)) ? result4 : 1f);
					result3.min = result;
					result3.max = result2;
					result3.levelMultiplier = levelMultiplier;
					return result3;
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Drops.Select((DropTarget r) => $"{r.creature}:{r.chance.ToString(CultureInfo.InvariantCulture)}:{r.min}:" + ((r.min == r.max) ? "" : $"{r.max}") + (r.levelMultiplier ? "" : ":0")));
			}

			private static Character? fetchByName(ZNetScene netScene, string name)
			{
				GameObject prefab = netScene.GetPrefab(name);
				Character obj = ((prefab != null) ? prefab.GetComponent<Character>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					Debug.LogWarning((object)("The drop target character '" + name + "' does not exist."));
				}
				return obj;
			}

			public Dictionary<Character, Drop> toCharacterDrops(ZNetScene netScene, GameObject item)
			{
				//IL_002e: 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_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Expected O, but got Unknown
				Dictionary<Character, Drop> dictionary = new Dictionary<Character, Drop>();
				foreach (DropTarget drop in Drops)
				{
					Character val = fetchByName(netScene, drop.creature);
					if (val != null)
					{
						dictionary[val] = new Drop
						{
							m_prefab = item,
							m_amountMin = drop.min,
							m_amountMax = drop.max,
							m_chance = drop.chance,
							m_levelMultiplier = drop.levelMultiplier
						};
					}
				}
				return dictionary;
			}
		}

		private static readonly List<Item> registeredItems = new List<Item>();

		private static readonly Dictionary<ItemDrop, Item> itemDropMap = new Dictionary<ItemDrop, Item>();

		private static Dictionary<Item, Dictionary<string, List<Recipe>>> activeRecipes = new Dictionary<Item, Dictionary<string, List<Recipe>>>();

		private static Dictionary<Recipe, ConfigEntryBase?> hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		private static Dictionary<Recipe, ConfigEntryBase?> hiddenUpgradeRecipes = new Dictionary<Recipe, ConfigEntryBase>();

		private static Dictionary<Item, Dictionary<string, ItemConfig>> itemCraftConfigs = new Dictionary<Item, Dictionary<string, ItemConfig>>();

		private static Dictionary<Item, ConfigEntry<string>> itemDropConfigs = new Dictionary<Item, ConfigEntry<string>>();

		private Dictionary<CharacterDrop, Drop> characterDrops = new Dictionary<CharacterDrop, Drop>();

		private readonly Dictionary<ConfigEntryBase, Action> statsConfigs = new Dictionary<ConfigEntryBase, Action>();

		private static readonly ConditionalWeakTable<Requirement, RequirementQuality> requirementQuality = new ConditionalWeakTable<Requirement, RequirementQuality>();

		public static Configurability DefaultConfigurability = Configurability.Full;

		public Configurability? Configurable;

		private Configurability configurationVisible = Configurability.Full;

		private TraderConfig? traderConfig;

		public readonly GameObject Prefab;

		[Description("Specifies the maximum required crafting station level to upgrade and repair the item.\nDefault is calculated from crafting station level and maximum quality.")]
		public int MaximumRequiredStationLevel = int.MaxValue;

		[Description("Assigns the item as a drop item to a creature.\nUses a creature name, a drop chance and a minimum and maximum amount.")]
		public readonly DropTargets DropsFrom = new DropTargets();

		[Description("Configures whether the item can be bought at the trader.\nDon't forget to set cost to something above 0 or the item will be sold for free.")]
		public readonly Trade Trade = new Trade();

		internal List<Conversion> Conversions = new List<Conversion>();

		internal List<ItemConversion> conversions = new List<ItemConversion>();

		public Dictionary<string, ItemRecipe> Recipes = new Dictionary<string, ItemRecipe>();

		private LocalizeKey? _name;

		private LocalizeKey? _description;

		private static object? configManager;

		private static Localization? _english;

		private static BaseUnityPlugin? _plugin;

		private static bool hasConfigSync = true;

		private static object? _configSync;

		private Configurability configurability => Configurable ?? DefaultConfigurability;

		[Description("Specifies the resources needed to craft the item.\nUse .Add to add resources with their internal ID and an amount.\nUse one .Add for each resource type the item should need.")]
		public RequiredResourceList RequiredItems => this[""].RequiredItems;

		[Description("Specifies the resources needed to upgrade the item.\nUse .Add to add resources with their internal ID and an amount. This amount will be multipled by the item quality level.\nUse one .Add for each resource type the upgrade should need.")]
		public RequiredResourceList RequiredUpgradeItems => this[""].RequiredUpgradeItems;

		[Description("Specifies the crafting station needed to craft the item.\nUse .Add to add a crafting station, using the CraftingTable enum and a minimum level for the crafting station.\nUse one .Add for each crafting station.")]
		public CraftingStationList Crafting => this[""].Crafting;

		[Description("Specifies a config entry which toggles whether a recipe is active.")]
		public ConfigEntryBase? RecipeIsActive
		{
			get
			{
				return this[""].RecipeIsActive;
			}
			set
			{
				this[""].RecipeIsActive = value;
			}
		}

		[Description("Specifies the number of items that should be given to the player with a single craft of the item.\nDefaults to 1.")]
		public int CraftAmount
		{
			get
			{
				return this[""].CraftAmount;
			}
			set
			{
				this[""].CraftAmount = value;
			}
		}

		public bool RequireOnlyOneIngredient
		{
			get
			{
				return this[""].RequireOnlyOneIngredient;
			}
			set
			{
				this[""].RequireOnlyOneIngredient = value;
			}
		}

		public float QualityResultAmountMultiplier
		{
			get
			{
				return this[""].QualityResultAmountMultiplier;
			}
			set
			{
				this[""].QualityResultAmountMultiplier = value;
			}
		}

		public ItemRecipe this[string name]
		{
			get
			{
				if (Recipes.TryGetValue(name, out var value))
				{
					return value;
				}
				return Recipes[name] = new ItemRecipe();
			}
		}

		public LocalizeKey Name
		{
			get
			{
				LocalizeKey name = _name;
				if (name != null)
				{
					return name;
				}
				SharedData shared = Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
				if (shared.m_name.StartsWith("$"))
				{
					_name = new LocalizeKey(shared.m_name);
				}
				else
				{
					string text = "$item_" + ((Object)Prefab).name.Replace(" ", "_");
					_name = new LocalizeKey(text).English(shared.m_name);
					shared.m_name = text;
				}
				return _name;
			}
		}

		public LocalizeKey Description
		{
			get
			{
				LocalizeKey description = _description;
				if (description != null)
				{
					return description;
				}
				SharedData shared = Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
				if (shared.m_description.StartsWith("$"))
				{
					_description = new LocalizeKey(shared.m_description);
				}
				else
				{
					string text = "$itemdesc_" + ((Object)Prefab).name.Replace(" ", "_");
					_description = new LocalizeKey(text).English(shared.m_description);
					shared.m_description = text;
				}
				return _description;
			}
		}

		private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English"));

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		private static object? configSync
		{
			get
			{
				if (_configSync == null && hasConfigSync)
				{
					Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync");
					if ((object)type != null)
					{
						_configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " ItemManager");
						type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
						type.GetProperty("IsLocked").SetValue(_configSync, true);
					}
					else
					{
						hasConfigSync = false;
					}
				}
				return _configSync;
			}
		}

		public Item(string assetBundleFileName, string prefabName, string folderName = "assets")
			: this(PrefabManager.RegisterAssetBundle(assetBundleFileName, folderName), prefabName)
		{
		}

		public Item(AssetBundle bundle, string prefabName)
			: this(PrefabManager.RegisterPrefab(bundle, prefabName, addToObjectDb: true), skipRegistering: true)
		{
		}

		public Item(GameObject prefab, bool skipRegistering = false)
		{
			if (!skipRegistering)
			{
				PrefabManager.RegisterPrefab(prefab, addToObjectDb: true);
			}
			Prefab = prefab;
			registeredItems.Add(this);
			itemDropMap[Prefab.GetComponent<ItemDrop>()] = this;
			Prefab.GetComponent<ItemDrop>().m_itemData.m_dropPrefab = Prefab;
		}

		public void ToggleConfigurationVisibility(Configurability visible)
		{
			configurationVisible = visible;
			if (itemDropConfigs.TryGetValue(this, out var value))
			{
				Toggle((ConfigEntryBase)(object)value, Configurability.Drop);
			}
			if (itemCraftConfigs.TryGetValue(this, out var value2))
			{
				foreach (ItemConfig value4 in value2.Values)
				{
					ToggleObj(value4, Configurability.Recipe);
				}
			}
			foreach (Conversion conversion in Conversions)
			{
				if (conversion.config != null)
				{
					ToggleObj(conversion.config, Configurability.Recipe);
				}
			}
			foreach (KeyValuePair<ConfigEntryBase, Action> statsConfig in statsConfigs)
			{
				Toggle(statsConfig.Key, Configurability.Stats);
				if ((visible & Configurability.Stats) != 0)
				{
					statsConfig.Value();
				}
			}
			reloadConfigDisplay();
			void Toggle(ConfigEntryBase cfg, Configurability check)
			{
				object[] tags = cfg.Description.Tags;
				for (int j = 0; j < tags.Length; j++)
				{
					if (tags[j] is ConfigurationManagerAttributes configurationManagerAttributes)
					{
						configurationManagerAttributes.Browsable = (visible & check) != 0 && (configurationManagerAttributes.browsability == null || configurationManagerAttributes.browsability());
					}
				}
			}
			void ToggleObj(object obj, Configurability check)
			{
				FieldInfo[] fields = obj.GetType().GetFields();
				for (int i = 0; i < fields.Length; i++)
				{
					object? value3 = fields[i].GetValue(obj);
					ConfigEntryBase val = (ConfigEntryBase)((value3 is ConfigEntryBase) ? value3 : null);
					if (val != null)
					{
						Toggle(val, check);
					}
				}
			}
		}

		internal static void reloadConfigDisplay()
		{
			object obj = configManager?.GetType().GetProperty("DisplayingWindow").GetValue(configManager);
			if (obj is bool && (bool)obj)
			{
				configManager.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>());
			}
		}

		private void UpdateItemTableConfig(string recipeKey, CraftingTable table, string customTableValue)
		{
			if (activeRecipes.ContainsKey(this) && activeRecipes[this].TryGetValue(recipeKey, out var value))
			{
				value.First().m_enabled = table != CraftingTable.Disabled;
				if ((uint)table <= 1u)
				{
					value.First().m_craftingStation = null;
				}
				else if (table == CraftingTable.Custom)
				{
					Recipe obj = value.First();
					GameObject prefab = ZNetScene.instance.GetPrefab(customTableValue);
					obj.m_craftingStation = ((prefab != null) ? prefab.GetComponent<CraftingStation>() : null);
				}
				else
				{
					value.First().m_craftingStation = ZNetScene.instance.GetPrefab(getInternalName(table)).GetComponent<CraftingStation>();
				}
			}
		}

		private void UpdateCraftConfig(string recipeKey, SerializedRequirements craftRequirements, SerializedRequirements upgradeRequirements)
		{
			if (!Object.op_Implicit((Object)(object)ObjectDB.instance) || !activeRecipes.ContainsKey(this) || !activeRecipes[this].TryGetValue(recipeKey, out var value))
			{
				return;
			}
			foreach (Recipe item in value)
			{
				item.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, craftRequirements, upgradeRequirements);
			}
		}

		internal static void Patch_FejdStartup()
		{
			//IL_0e99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_2164: Unknown result type (might be due to invalid IL or missing references)
			//IL_216e: Expected O, but got Unknown
			//IL_0f62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fbb: Expected I4, but got Unknown
			//IL_0b88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b92: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Expected O, but got Unknown
			//IL_10ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f4: Invalid comparison between Unknown and I4
			//IL_10f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fa: Invalid comparison between Unknown and I4
			//IL_0cab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb5: Expected O, but got Unknown
			//IL_0d56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d60: Expected O, but got Unknown
			//IL_10fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_1100: Invalid comparison between Unknown and I4
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Expected O, but got Unknown
			//IL_0e0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e14: Expected O, but got Unknown
			//IL_12fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_12fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1300: Invalid comparison between Unknown and I4
			//IL_1302: Unknown result type (might be due to invalid IL or missing references)
			//IL_1306: Unknown result type (might be due to invalid IL or missing references)
			//IL_1308: Invalid comparison between Unknown and I4
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Expected O, but got Unknown
			//IL_130a: Unknown result type (might be due to invalid IL or missing references)
			//IL_130e: Invalid comparison between Unknown and I4
			//IL_13e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ed: Invalid comparison between Unknown and I4
			//IL_13ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_13f3: Invalid comparison between Unknown and I4
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fa: Expected O, but got Unknown
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_065b: Expected O, but got Unknown
			//IL_1462: Unknown result type (might be due to invalid IL or missing references)
			//IL_1465: Unknown result type (might be due to invalid IL or missing references)
			//IL_1467: Invalid comparison between Unknown and I4
			//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0804: Expected O, but got Unknown
			//IL_1469: Unknown result type (might be due to invalid IL or missing references)
			//IL_146d: Unknown result type (might be due to invalid IL or missing references)
			//IL_146f: Invalid comparison between Unknown and I4
			//IL_1471: Unknown result type (might be due to invalid IL or missing references)
			//IL_1475: Invalid comparison between Unknown and I4
			//IL_15b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_15b5: Invalid comparison between Unknown and I4
			//IL_17b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_17b9: Invalid comparison between Unknown and I4
			//IL_1882: Unknown result type (might be due to invalid IL or missing references)
			//IL_1887: Unknown result type (might be due to invalid IL or missing references)
			//IL_1889: Unknown result type (might be due to invalid IL or missing references)
			//IL_188d: Unknown result type (might be due to invalid IL or missing references)
			//IL_188f: Invalid comparison between Unknown and I4
			//IL_18fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_1901: Unknown result type (might be due to invalid IL or missing references)
			//IL_1903: Invalid comparison between Unknown and I4
			//IL_1528: Unknown result type (might be due to invalid IL or missing references)
			//IL_152d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1905: Unknown result type (might be due to invalid IL or missing references)
			//IL_1909: Invalid comparison between Unknown and I4
			//IL_190b: Unknown result type (might be due to invalid IL or missing references)
			//IL_190f: Invalid comparison between Unknown and I4
			//IL_1d7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d7f: Invalid comparison between Unknown and I4
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			if (DefaultConfigurability != 0)
			{
				bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
				plugin.Config.SaveOnConfigSet = false;
				foreach (Item item4 in registeredItems.Where((Item i) => i.configurability != Configurability.Disabled))
				{
					Item item3 = item4;
					string name2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
					string englishName = new Regex("[=\\n\\t\\\\\"\\'\\[\\]]*").Replace(english.Localize(name2), "").Trim();
					string localizedName = Localization.instance.Localize(name2).Trim();
					int order = 0;
					if ((item3.configurability & Configurability.Recipe) != 0)
					{
						itemCraftConfigs[item3] = new Dictionary<string, ItemConfig>();
						foreach (string item5 in item3.Recipes.Keys.DefaultIfEmpty(""))
						{
							string configKey = item5;
							string text = ((configKey == "") ? "" : (" (" + configKey + ")"));
							if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig2;
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							cfg.table = config(englishName, "Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = CustomTableBrowsability,
								Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.customTable = config(englishName, "Custom Crafting Station" + text, item3.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
							cfg.table.SettingChanged += TableConfigChanged;
							cfg.customTable.SettingChanged += TableConfigChanged;
							ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = TableLevelBrowsability,
								Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							hideWhenNoneAttributes.Add(configurationManagerAttributes);
							cfg.tableLevel = config(englishName, "Crafting Station Level" + text, item3.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							cfg.tableLevel.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value6))
								{
									value6.First().m_minStationLevel = cfg.tableLevel.Value;
								}
							};
							if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1)
							{
								cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item3.MaximumRequiredStationLevel == int.MaxValue) ? (item3.Recipes[configKey].Crafting.Stations.First().level + item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item3.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							}
							cfg.requireOneIngredient = config(englishName, "Require only one resource" + text, item3.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = QualityResultBrowsability,
								Browsable = (QualityResultBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.requireOneIngredient.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out var value5))
								{
									foreach (Recipe item6 in value5)
									{
										item6.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On;
									}
								}