Decompiled source of DoorOpenerBruh v2.0.10

plugins/DoorOpenerBruh.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DoorOpenerBruh.Assets.Effects;
using DoorOpenerBruh.Assets.Factories;
using DoorOpenerBruh.Assets.Pieces;
using DoorOpenerBruh.Assets.Pieces.Doors;
using DoorOpenerBruh.Components;
using DoorOpenerBruh.Configuration;
using DoorOpenerBruh.Patches;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;
using Vapok.Common.Abstractions;
using Vapok.Common.Managers;
using Vapok.Common.Managers.Configuration;
using Vapok.Common.Managers.Creature;
using Vapok.Common.Managers.LocalizationManager;
using Vapok.Common.Managers.Location;
using Vapok.Common.Managers.PieceManager;
using Vapok.Common.Managers.Skill;
using Vapok.Common.Managers.Splash;
using Vapok.Common.Managers.StatusEffects;
using Vapok.Common.Managers.Telemetry;
using Vapok.Common.Shared;
using Vapok.Common.Tools;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DoorOpenerBruh")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Vapok Gaming")]
[assembly: AssemblyProduct("DoorOpenerBruh")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("997CB563-FCC7-44B7-8F71-069747D27CC5")]
[assembly: AssemblyFileVersion("2.0.10.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.10.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DoorOpenerBruh
{
	[BepInPlugin("vapok.mods.dooropenerbruh", "DoorOpenerBruh", "2.0.10")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class DoorOpenerBruh : BaseUnityPlugin, IPluginInfo
	{
		public class Waiting
		{
			public event EventHandler StatusChanged;

			public void ValheimIsAwake(bool awakeFlag)
			{
				if (awakeFlag)
				{
					this.StatusChanged?.Invoke(this, EventArgs.Empty);
				}
			}
		}

		private const string _pluginId = "vapok.mods.dooropenerbruh";

		private const string _displayName = "DoorOpenerBruh";

		private const string _version = "2.0.10";

		public static bool ValheimAwake;

		public static Waiting Waiter;

		private static DoorOpenerBruh _instance;

		private DoorFactory _doorFactory;

		private static ConfigSyncBase _config;

		private static ILogIt _log;

		private Harmony _harmony;

		public string PluginId => "vapok.mods.dooropenerbruh";

		public string DisplayName => "DoorOpenerBruh";

		public string Version => "2.0.10";

		public BaseUnityPlugin Instance => (BaseUnityPlugin)(object)_instance;

		public static ILogIt Log => _log;

		[UsedImplicitly]
		private void Awake()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			_instance = this;
			Waiter = new Waiting();
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			LogManager.Init(PluginId, out _log);
			Initializer.LoadManagers(localization);
			_config = new ConfigRegistry(_instance);
			Localizer.Waiter.StatusChanged += InitializeModule;
			_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			_harmony.PatchAll(Assembly.GetExecutingAssembly());
			ModSplashManager.Register(new ModSplashDossier(_instance)
			{
				Tagline = "Automatic door and gate opening and closing mechanics with configurable proximity.",
				ShowOnStartup = ConfigSyncBase.ShowSplashOnStartup
			});
			if (GUIManager.IsHeadless())
			{
				InitializeModule(this, EventArgs.Empty);
			}
		}

		public void InitializeModule(object send, EventArgs args)
		{
			if (!ValheimAwake)
			{
				new EffectsFactory(_log, _config).RegisterEffects();
				_doorFactory = new DoorFactory(_log, _config);
				ConfigRegistry.Waiter.ConfigurationComplete(configDone: true);
				ValheimAwake = true;
			}
		}

		private void OnDestroy()
		{
			_instance = null;
		}
	}
}
namespace DoorOpenerBruh.Patches
{
	internal static class DoorPatches
	{
		[HarmonyPatch(typeof(Door), "Awake")]
		internal static class DoorAwakePatch
		{
			internal static Queue<Door> Doors = new Queue<Door>();

			[HarmonyPrepare]
			private static bool Prepare()
			{
				return !GUIManager.IsHeadless();
			}

			[UsedImplicitly]
			private static void Postfix(Door __instance)
			{
				if ((Object)(object)DoorOpener.Instance != (Object)null)
				{
					ExposedGameObjectExtension.GetOrAddComponent<DoorStatus>(((Component)__instance).gameObject);
				}
				else
				{
					Doors.Enqueue(__instance);
				}
			}
		}
	}
	internal static class FejdStartupPatches
	{
		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		[HarmonyAfter(new string[] { "vapok.common.LocalizationManager", "org.bepinex.helpers.LocalizationManager" })]
		[HarmonyBefore(new string[] { "vapok.common.ItemManager", "org.bepinex.helpers.ItemManager" })]
		internal static class FejdStartupAwakePatch
		{
			[HarmonyPrepare]
			private static bool Prepare()
			{
				return !GUIManager.IsHeadless();
			}

			private static void Prefix()
			{
				DoorOpenerBruh.Waiter.ValheimIsAwake(awakeFlag: true);
			}
		}
	}
	internal static class PlayerPatches
	{
		[HarmonyPatch(typeof(Player), "SetLocalPlayer")]
		internal static class PlayerSetLocalPlayerPatch
		{
			[HarmonyPrepare]
			private static bool Prepare()
			{
				return !GUIManager.IsHeadless();
			}

			private static void Postfix()
			{
				if (!((Object)(object)DoorOpener.Instance == (Object)null))
				{
					DoorOpener.Instance.ResetBruh();
				}
			}
		}
	}
	internal static class ZNetScenePatches
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		internal static class ZNetSceneAwakePatch
		{
			[HarmonyPrepare]
			private static bool Prepare()
			{
				return !GUIManager.IsHeadless();
			}

			private static void Prefix(ZNetScene __instance)
			{
				((Component)__instance).gameObject.AddComponent<DoorOpener>();
			}
		}
	}
}
namespace DoorOpenerBruh.Extensions
{
	public static class DoorExtensions
	{
		public static DoorStatus GetDoorStatus(this Door trackedDoor)
		{
			return ((Component)trackedDoor).gameObject.GetComponent<DoorStatus>();
		}
	}
}
namespace DoorOpenerBruh.Configuration
{
	public class ConfigRegistry : ConfigSyncBase
	{
		internal static ConfigEntry<bool> Enabled;

		public static Waiting Waiter;

		public ConfigRegistry(IPluginInfo mod)
			: base(mod)
		{
			Waiter = new Waiting();
			InitializeConfigurationSettings();
		}

		public sealed override void InitializeConfigurationSettings()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			if (ConfigSyncBase._config != null)
			{
				ConfigSyncBase.UnsyncedConfig("Local Settings", "Enable Auto Door", value: true, new ConfigDescription("If true, will automatically open doors.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
				{
					Category = "Local Settings",
					Order = 1
				} }), ref Enabled);
			}
		}
	}
	public class Waiting
	{
		public event EventHandler StatusChanged;

		public void ConfigurationComplete(bool configDone)
		{
			if (configDone)
			{
				this.StatusChanged?.Invoke(this, EventArgs.Empty);
			}
		}
	}
}
namespace DoorOpenerBruh.Components
{
	public enum AutomationMechanic
	{
		OnlyOpenSelfmadeDoors,
		OnlyOpenAllPlayerMadeDoors,
		OpenAllDoors,
		DoNotOpenAutomatically
	}
	public class DoorOpener : MonoBehaviour
	{
		public static DoorOpener Instance;

		public bool Enabled;

		private int _doorCount;

		private bool _needsUpdating = true;

		public Player Bruh => Player.m_localPlayer;

		public bool PlayerSet => (Object)(object)Player.m_localPlayer != (Object)null;

		private void Awake()
		{
			Instance = this;
			DoorOpenerBruh.Log.Debug($"Door Queue Count: {DoorPatches.DoorAwakePatch.Doors.Count}");
			while (DoorPatches.DoorAwakePatch.Doors != null && DoorPatches.DoorAwakePatch.Doors.Count > 0)
			{
				Door val = DoorPatches.DoorAwakePatch.Doors.Dequeue();
				if (!((Object)(object)val == (Object)null))
				{
					if ((Object)(object)val.m_nview != (Object)null && val.m_nview.GetZDO() != null)
					{
						DoorOpenerBruh.Log.Debug($"Queued Door ID: {((ZDOID)(ref val.m_nview.GetZDO().m_uid)).ID}");
					}
					ExposedGameObjectExtension.GetOrAddComponent<DoorStatus>(((Component)val).gameObject);
				}
			}
		}

		private void Update()
		{
			if (_needsUpdating && !((Object)(object)Player.m_localPlayer == (Object)null))
			{
				DoorOpenerBruh.Log.Debug($"Tracking {_doorCount} doors.");
				_needsUpdating = false;
			}
		}

		public void ResetBruh()
		{
			_needsUpdating = true;
		}

		private void OnEnable()
		{
			Enabled = true;
		}

		private void OnDisable()
		{
			Enabled = false;
		}

		private void OnDestroy()
		{
			DoorPatches.DoorAwakePatch.Doors?.Clear();
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		public void AddDoor(Door trackedDoor)
		{
			_doorCount++;
			_needsUpdating = true;
		}

		public void RemoveDoor(Door trackedDoor)
		{
			_doorCount--;
			_needsUpdating = true;
		}
	}
	public class DoorStatus : MonoBehaviour
	{
		private Door _trackedDoor;

		private Piece _piece;

		private bool _enabled;

		private bool _inRange;

		private bool _autoOpened;

		private bool _isGhost;

		private int _status;

		private float _timeRemaining;

		private bool _started;

		private string _prefabCleanName;

		private IDoorPiece _doorPiece;

		private Collider[] _colliders;

		public bool IsGhost => _isGhost;

		public Door TrackedDoor => _trackedDoor;

		public bool Enabled => _enabled;

		private void Awake()
		{
			if (GUIManager.IsHeadless())
			{
				((Behaviour)this).enabled = false;
				Object.Destroy((Object)(object)this);
				return;
			}
			_trackedDoor = ((Component)this).gameObject.GetComponent<Door>();
			_piece = ((Component)this).gameObject.GetComponent<Piece>();
			_prefabCleanName = Utils.GetPrefabName(((Component)this).gameObject);
			_colliders = ((Component)this).gameObject.GetComponentsInChildren<Collider>(true);
		}

		private void Start()
		{
			if (GUIManager.IsHeadless())
			{
				((Behaviour)this).enabled = false;
				Object.Destroy((Object)(object)this);
				return;
			}
			_isGhost = (Object)(object)_trackedDoor != (Object)null && ((Component)_trackedDoor).gameObject.layer == Piece.s_ghostLayer;
			if (_isGhost)
			{
				((Behaviour)this).enabled = false;
			}
			else
			{
				_started = true;
			}
		}

		private void OnEnable()
		{
			if ((Object)(object)DoorOpener.Instance != (Object)null)
			{
				DoorOpener.Instance.AddDoor(_trackedDoor);
			}
		}

		private void OnDisable()
		{
			if ((Object)(object)DoorOpener.Instance != (Object)null)
			{
				DoorOpener.Instance.RemoveDoor(_trackedDoor);
			}
		}

		private void Update()
		{
			if (!_started)
			{
				return;
			}
			_timeRemaining -= Time.deltaTime;
			if (!(_timeRemaining > 0f))
			{
				_timeRemaining = 0.02f;
				if (!((Object)(object)DoorOpener.Instance == (Object)null) && DoorOpener.Instance.Enabled)
				{
					CheckPlayerPositionForDoors();
				}
			}
		}

		private IDoorPiece GetDoorPiece()
		{
			if (_doorPiece != null)
			{
				return _doorPiece;
			}
			if (string.IsNullOrEmpty(_prefabCleanName) && (Object)(object)_trackedDoor != (Object)null)
			{
				_prefabCleanName = Utils.GetPrefabName(((Component)this).gameObject);
			}
			if (DoorFactory.DoorPieces != null)
			{
				IDoorPiece value2;
				if (DoorFactory.DoorPieces.TryGetValue(_prefabCleanName ?? string.Empty, out var value))
				{
					_doorPiece = value;
				}
				else if (DoorFactory.DoorPieces.TryGetValue("other", out value2))
				{
					_doorPiece = value2;
				}
			}
			return _doorPiece;
		}

		private float GetDistanceToPlayer(Player player)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_trackedDoor == (Object)null || (Object)(object)player == (Object)null)
			{
				return float.MaxValue;
			}
			Vector3 position = ((Component)player).transform.position;
			float num = Vector3.Distance(((Component)_trackedDoor).transform.position, position);
			if (_colliders != null && _colliders.Length != 0)
			{
				for (int i = 0; i < _colliders.Length; i++)
				{
					Collider val = _colliders[i];
					if (!((Object)(object)val == (Object)null) && val.enabled && !val.isTrigger)
					{
						Bounds bounds = val.bounds;
						float num2 = Vector3.Distance(((Bounds)(ref bounds)).ClosestPoint(position), position);
						if (num2 < num)
						{
							num = num2;
						}
					}
				}
			}
			return num;
		}

		private void CheckPlayerPositionForDoors()
		{
			if ((Object)(object)DoorOpener.Instance == (Object)null)
			{
				return;
			}
			Player bruh = DoorOpener.Instance.Bruh;
			if ((Object)(object)bruh == (Object)null || ((Character)bruh).IsDead() || (Object)(object)_trackedDoor == (Object)null || (Object)(object)_trackedDoor.m_nview == (Object)null || !_trackedDoor.m_nview.IsValid())
			{
				return;
			}
			ZDO zDO = _trackedDoor.m_nview.GetZDO();
			if (zDO == null)
			{
				return;
			}
			_status = zDO.GetInt(ZDOVars.s_state, 0);
			IDoorPiece doorPiece = GetDoorPiece();
			float num = doorPiece?.GetOpenDistance() ?? 3f;
			float num2 = doorPiece?.GetCloseDistance() ?? 4.5f;
			float distanceToPlayer = GetDistanceToPlayer(bruh);
			if (_inRange)
			{
				if (distanceToPlayer > num2)
				{
					_inRange = false;
				}
			}
			else if (distanceToPlayer <= num)
			{
				_inRange = true;
			}
			if (_inRange)
			{
				_enabled = doorPiece?.DoorAutomationEnabled(this) ?? false;
				if (_enabled && ((_status == 0 && !_trackedDoor.m_invertedOpenClosedText) || (_status != 0 && _trackedDoor.m_invertedOpenClosedText)))
				{
					if (!_autoOpened)
					{
						try
						{
							_trackedDoor.Interact((Humanoid)(object)bruh, false, false);
						}
						catch (Exception ex)
						{
							DoorOpenerBruh.Log.Warning("Exception during door interaction: " + ex.Message);
						}
						_autoOpened = true;
					}
				}
				else
				{
					_autoOpened = true;
				}
			}
			else if (_autoOpened)
			{
				_enabled = doorPiece?.DoorAutomationEnabled(this) ?? false;
				if (_enabled)
				{
					SetState(_trackedDoor.m_invertedOpenClosedText ? 1 : 0);
				}
				_autoOpened = false;
			}
		}

		private void SetState(int state)
		{
			if ((Object)(object)_trackedDoor != (Object)null && (Object)(object)_trackedDoor.m_nview != (Object)null && _trackedDoor.m_nview.IsValid())
			{
				_trackedDoor.m_nview.InvokeRPC("UseDoor", new object[1] { state });
			}
		}
	}
}
namespace DoorOpenerBruh.Assets.Pieces
{
	public abstract class DoorPiece : IDoorPiece
	{
		private string _configSection;

		private string _prefabName;

		private string _pieceName;

		internal ConfigEntry<AutomationMechanic> AutomationMechanic;

		internal ConfigEntry<bool> CheckForKey;

		internal ConfigEntry<float> OpenDistance;

		internal ConfigEntry<float> CloseDistance;

		public string PrefabName => _prefabName;

		public string PieceName => _pieceName;

		protected DoorPiece(string prefabName, string pieceName, string configSection)
		{
			_prefabName = prefabName;
			_pieceName = pieceName;
			_configSection = (string.IsNullOrEmpty(configSection) ? ("Door: " + pieceName) : configSection);
		}

		public abstract bool DoorAutomationEnabled(DoorStatus trackedDoor);

		internal abstract void RegisterConfigSettings();

		public virtual float GetOpenDistance()
		{
			return OpenDistance?.Value ?? 3f;
		}

		public virtual float GetCloseDistance()
		{
			return CloseDistance?.Value ?? 4.5f;
		}

		internal virtual void RegisterDistances(float defaultOpen = 3f, float defaultClose = 4.5f)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			ConfigSyncBase.UnsyncedConfig(_configSection, "Open Distance", defaultOpen, new ConfigDescription("Distance (in meters) from the door to automatically open.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Category = _configSection,
				Order = 3
			} }), ref OpenDistance);
			ConfigSyncBase.UnsyncedConfig(_configSection, "Close Distance", defaultClose, new ConfigDescription("Distance (in meters) away from the door to automatically close.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Category = _configSection,
				Order = 4
			} }), ref CloseDistance);
		}

		internal virtual void RegisterAutomationMechanic(AutomationMechanic defaultValue = global::DoorOpenerBruh.Components.AutomationMechanic.DoNotOpenAutomatically, float defaultOpen = 3f, float defaultClose = 4.5f)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			ConfigSyncBase.UnsyncedConfig(_configSection, "Automation Mechanic", defaultValue, new ConfigDescription("Determine door open automation based on list provided.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Category = _configSection,
				Order = 1
			} }), ref AutomationMechanic);
			RegisterDistances(defaultOpen, defaultClose);
		}

		internal virtual void RegisterCheckForKey(bool defaultValue = false)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			ConfigSyncBase.UnsyncedConfig(_configSection, "Check for Key", defaultValue, new ConfigDescription("If enabled, will automatically open locked doors, if player has key. If disabled, Doors with keys will not automatically open.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Category = _configSection,
				Order = 2
			} }), ref CheckForKey);
		}

		internal bool ComputeAutomation(DoorStatus trackedDoor, bool keyDefined = false)
		{
			if ((Object)(object)trackedDoor == (Object)null || (Object)(object)trackedDoor.TrackedDoor == (Object)null)
			{
				return false;
			}
			bool result = false;
			switch (AutomationMechanic.Value)
			{
			case global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors:
				result = DefaultDoorEnablement(trackedDoor, keyDefined);
				break;
			case global::DoorOpenerBruh.Components.AutomationMechanic.OnlyOpenSelfmadeDoors:
				result = DefaultDoorEnablement(trackedDoor, keyDefined) && IsSelfMadeDoor(trackedDoor);
				break;
			case global::DoorOpenerBruh.Components.AutomationMechanic.OnlyOpenAllPlayerMadeDoors:
				result = DefaultDoorEnablement(trackedDoor, keyDefined) && IsPlayerMadeDoor(trackedDoor);
				break;
			}
			return result;
		}

		private bool IsPlayerMadeDoor(DoorStatus trackedDoor)
		{
			if ((Object)(object)trackedDoor == (Object)null || (Object)(object)trackedDoor.TrackedDoor == (Object)null)
			{
				return false;
			}
			ZNetView nview = trackedDoor.TrackedDoor.m_nview;
			if ((Object)(object)nview != (Object)null && nview.IsValid())
			{
				return nview.GetZDO().GetLong(ZDOVars.s_creator, 0L) != 0;
			}
			return false;
		}

		private bool IsSelfMadeDoor(DoorStatus trackedDoor)
		{
			Player val = (((Object)(object)DoorOpener.Instance != (Object)null) ? DoorOpener.Instance.Bruh : null);
			if ((Object)(object)val == (Object)null || (Object)(object)trackedDoor == (Object)null || (Object)(object)trackedDoor.TrackedDoor == (Object)null)
			{
				return false;
			}
			ZNetView nview = trackedDoor.TrackedDoor.m_nview;
			if ((Object)(object)nview != (Object)null && nview.IsValid())
			{
				return nview.GetZDO().GetLong(ZDOVars.s_creator, 0L) == val.GetPlayerID();
			}
			return false;
		}

		private bool DefaultDoorEnablement(DoorStatus trackedDoor, bool keyDefined)
		{
			if (((Behaviour)trackedDoor).isActiveAndEnabled && !trackedDoor.IsGhost && ConfigRegistry.Enabled.Value && (Object)(object)DoorOpener.Instance != (Object)null && DoorOpener.Instance.PlayerSet && DetermineCheckForKey(trackedDoor, keyDefined))
			{
				return trackedDoor.TrackedDoor.CanInteract();
			}
			return false;
		}

		private bool DetermineCheckForKey(DoorStatus trackedDoor, bool keyDefined)
		{
			bool result = (Object)(object)trackedDoor.TrackedDoor.m_keyItem == (Object)null;
			if (!keyDefined)
			{
				return result;
			}
			if (CheckForKey != null && CheckForKey.Value)
			{
				result = true;
				if ((Object)(object)trackedDoor.TrackedDoor.m_keyItem != (Object)null)
				{
					Player val = (((Object)(object)DoorOpener.Instance != (Object)null) ? DoorOpener.Instance.Bruh : null);
					result = (Object)(object)val != (Object)null && trackedDoor.TrackedDoor.HaveKey((Humanoid)(object)val, true);
				}
			}
			return result;
		}
	}
	public interface IDoorPiece
	{
		string PrefabName { get; }

		string PieceName { get; }

		bool DoorAutomationEnabled(DoorStatus trackedDoor);

		float GetOpenDistance();

		float GetCloseDistance();
	}
}
namespace DoorOpenerBruh.Assets.Pieces.Doors
{
	public class AshwoodDoor : DoorPiece
	{
		public AshwoodDoor(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class DarkwoodGate : DoorPiece
	{
		public DarkwoodGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class Drawbridge : DoorPiece
	{
		public Drawbridge(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors, 6f, 8f);
		}
	}
	public class DungeonForestCryptDoor : DoorPiece
	{
		public DungeonForestCryptDoor(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic();
		}
	}
	public class DungeonQueenDoor : DoorPiece
	{
		public DungeonQueenDoor(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor, keyDefined: true);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic();
			RegisterCheckForKey();
		}
	}
	public class DungeonSunkenCryptIronGate : DoorPiece
	{
		public DungeonSunkenCryptIronGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic();
		}
	}
	public class DvergrTownSecretDoor : DoorPiece
	{
		public DvergrTownSecretDoor(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic();
		}
	}
	public class DvergrTownSlidingDoor : DoorPiece
	{
		public DvergrTownSlidingDoor(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic();
		}
	}
	public class DvergrWoodDoor : DoorPiece
	{
		public DvergrWoodDoor(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic();
		}
	}
	public class FlametalGate : DoorPiece
	{
		public FlametalGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class GraustenDoor : DoorPiece
	{
		public GraustenDoor(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class GraustenGate : DoorPiece
	{
		public GraustenGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class HexagonalGate : DoorPiece
	{
		public HexagonalGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class IronGrate : DoorPiece
	{
		public IronGrate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class MountainWoodGate : DoorPiece
	{
		public MountainWoodGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class OtherDoors : DoorPiece
	{
		public OtherDoors(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor, keyDefined: true);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OnlyOpenAllPlayerMadeDoors);
			RegisterCheckForKey();
		}
	}
	public class RusticDrawbridge : DoorPiece
	{
		public RusticDrawbridge(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors, 6f, 8f);
		}
	}
	public class StaveGate : DoorPiece
	{
		public StaveGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class SunkenCryptIronGate : DoorPiece
	{
		public SunkenCryptIronGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor, keyDefined: true);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic();
			RegisterCheckForKey();
		}
	}
	public class WindowShutter : DoorPiece
	{
		public WindowShutter(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class WoodDoor : DoorPiece
	{
		public WoodDoor(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class WoodFenceGate : DoorPiece
	{
		public WoodFenceGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
	public class WoodGate : DoorPiece
	{
		public WoodGate(string prefabName, string pieceName, string configSection)
			: base(prefabName, pieceName, configSection)
		{
			RegisterConfigSettings();
		}

		public override bool DoorAutomationEnabled(DoorStatus trackedDoor)
		{
			return ComputeAutomation(trackedDoor);
		}

		internal sealed override void RegisterConfigSettings()
		{
			RegisterAutomationMechanic(global::DoorOpenerBruh.Components.AutomationMechanic.OpenAllDoors);
		}
	}
}
namespace DoorOpenerBruh.Assets.Items
{
	internal interface IAssetItem
	{
		string PrefabName { get; }

		string ItemName { get; }

		Item Item { get; }
	}
	internal abstract class AssetItem : IAssetItem
	{
		private const string AssetName = "vapokbackpacks";

		private const string AssetFolderName = "Assets.Bundles";

		private string _prefabName;

		private string _itemName;

		private Item _item;

		public string PrefabName => _prefabName;

		public string ItemName => _itemName;

		public Item Item => _item;

		internal AssetItem(string prefabName, string itemName)
		{
			_prefabName = prefabName;
			_itemName = itemName;
			_item = new Item("vapokbackpacks", PrefabName, "Assets.Bundles")
			{
				Configurable = Configurability.Disabled
			};
			SetPersistence();
			ResetPrefabArmor();
		}

		internal void AssignCraftingTable(ItemManager.CraftingTable craftingTable, int stationLevel)
		{
			_item.Crafting.Add(craftingTable, stationLevel);
		}

		internal void AddRecipeIngredient(string prefabName, int quantity)
		{
			_item.RequiredItems.Add(prefabName, quantity);
		}

		internal void AddUpgradeIngredient(string prefabName, int quantity)
		{
			_item.RequiredUpgradeItems.Add(prefabName, quantity);
		}

		internal ItemDrop GetItemDrop()
		{
			Item item = _item;
			if (item == null)
			{
				return null;
			}
			return item.Prefab.GetComponent<ItemDrop>();
		}

		internal void RegisterShaderSwap(MaterialReplacer.ShaderType shaderType = MaterialReplacer.ShaderType.PieceShader)
		{
			MaterialReplacer.RegisterGameObjectForShaderSwap(_item.Prefab, shaderType);
		}

		internal void SetPersistence()
		{
			_item.Prefab.GetComponent<ZNetView>().m_persistent = true;
		}

		internal void ResetPrefabArmor()
		{
			ItemDrop itemDrop = GetItemDrop();
			ItemData itemData = itemDrop.m_itemData;
			if (itemData != null)
			{
				itemDrop.m_autoPickup = true;
				itemData.m_shared.m_armor = itemData.m_shared.m_armorPerLevel;
				itemDrop.Save();
			}
		}
	}
}
namespace DoorOpenerBruh.Assets.Factories
{
	internal abstract class AssetFactory : FactoryBase
	{
		internal AssetFactory(ILogIt logger, ConfigSyncBase configs)
			: base(logger, configs)
		{
		}

		internal abstract void CreateAssets();
	}
	public class DoorFactory : FactoryBase
	{
		private static Dictionary<string, IDoorPiece> _doorPieces = new Dictionary<string, IDoorPiece>();

		public static Dictionary<string, IDoorPiece> DoorPieces => _doorPieces;

		public DoorFactory(ILogIt logger, ConfigSyncBase configs)
			: base(logger, configs)
		{
			_doorPieces.Clear();
			_doorPieces.Add("dungeon_forestcrypt_door", new DungeonForestCryptDoor("dungeon_forestcrypt_door", "$piece_wooddoor", "Dungeon: Burial Chamber Door"));
			_doorPieces.Add("dungeon_queen_door", new DungeonQueenDoor("dungeon_queen_door", "$piece_queendoor", "World: Mistlands Queen Door"));
			_doorPieces.Add("dvergrtown_secretdoor", new DvergrTownSecretDoor("dvergrtown_secretdoor", "$piece_secretdoor", "Dungeon: Dvergr Town Secret Door"));
			_doorPieces.Add("dvergrtown_slidingdoor", new DvergrTownSlidingDoor("dvergrtown_slidingdoor", "$piece_dv_gate", "Dungeon: Dvergr Town Sliding Door"));
			_doorPieces.Add("piece_dvergr_wood_door", new DvergrWoodDoor("piece_dvergr_wood_door", "$piece_dvergr_door", "World: Dvergr Wood Door"));
			_doorPieces.Add("piece_hexagonal_door", new HexagonalGate("piece_hexagonal_door", "$piece_hexagonalgate", "Buildable: Hexagonal Gate"));
			_doorPieces.Add("wood_door", new WoodDoor("wood_door", "$piece_wooddoor", "Buildable: Wood Door"));
			_doorPieces.Add("iron_grate", new IronGrate("iron_grate", "$piece_irongate", "Buildable: Iron Gate"));
			_doorPieces.Add("darkwood_gate", new DarkwoodGate("darkwood_gate", "$piece_darkwoodgate", "Buildable: Darkwood Gate"));
			_doorPieces.Add("ashwood_door", new AshwoodDoor("ashwood_door", "$piece_ashwood_door", "Buildable: Ashwood Door"));
			_doorPieces.Add("flametal_gate", new FlametalGate("flametal_gate", "$piece_flametal_gate", "Buildable: Flametal Gate"));
			_doorPieces.Add("piece_grausten_door", new GraustenDoor("piece_grausten_door", "$piece_grausten_door", "Buildable: Grausten Door"));
			_doorPieces.Add("piece_grausten_gate", new GraustenGate("piece_grausten_gate", "$piece_grausten_gate", "Buildable: Grausten Gate"));
			_doorPieces.Add("piece_drawbridge", new Drawbridge("piece_drawbridge", "$piece_drawbridge", "Buildable: Drawbridge"));
			_doorPieces.Add("piece_drawbridge_log", new RusticDrawbridge("piece_drawbridge_log", "$piece_drawbridge_log", "Buildable: Rustic Drawbridge"));
			_doorPieces.Add("dungeon_sunkencrypt_irongate", new DungeonSunkenCryptIronGate("dungeon_sunkencrypt_irongate", "$piece_irongate", "Dungeon: Sunken Crypt Iron Gate"));
			_doorPieces.Add("MountainKit_wood_gate", new MountainWoodGate("MountainKit_wood_gate", "$piece_woodgate", "World: Mountain Wood Gate"));
			_doorPieces.Add("sunken_crypt_gate", new SunkenCryptIronGate("sunken_crypt_gate", "$piece_irongate", "World: Sunken Crypt Gate"));
			_doorPieces.Add("wood_gate", new WoodGate("wood_gate", "$piece_woodgate", "Buildable: Wood Gate"));
			_doorPieces.Add("wood_window", new WindowShutter("wood_window", "$piece_woodwindowshutter", "Buildable: Wood Shutter"));
			_doorPieces.Add("wood_fence_gate", new WoodFenceGate("wood_fence_gate", "$piece_woodfencegate", "Buildable: Wood Fence Gate"));
			_doorPieces.Add("stave_gate", new StaveGate("stave_gate", "$piece_stavegate", "Buildable: Stave Gate"));
			_doorPieces.Add("other", new OtherDoors("other", "other", "Other: Other and Custom Doors"));
		}
	}
	public enum DoorOpenerBruhEffects
	{

	}
	public class EffectsFactory : FactoryBase
	{
		private static Dictionary<DoorOpenerBruhEffects, EffectsBase> _effectList = new Dictionary<DoorOpenerBruhEffects, EffectsBase>();

		public static Dictionary<DoorOpenerBruhEffects, EffectsBase> EffectList => _effectList;

		public EffectsFactory(ILogIt logger, ConfigSyncBase configs)
			: base(logger, configs)
		{
		}

		public void RegisterEffects()
		{
		}
	}
	public abstract class FactoryBase
	{
		private ILogIt _logger;

		private ConfigSyncBase _config;

		internal ILogIt Log => _logger;

		internal ConfigSyncBase Config => _config;

		internal FactoryBase(ILogIt logger, ConfigSyncBase configs)
		{
			_logger = logger;
			_config = configs;
		}
	}
}
namespace DoorOpenerBruh.Assets.Effects
{
	public abstract class EffectsBase
	{
		public ConfigEntry<bool> EnabledEffect;

		private string _configSection;

		private string _effectName;

		private string _description;

		public string EffectName => _effectName;

		public EffectsBase(string effectName, string effectDesc)
		{
			_effectName = effectName;
			_description = (string.IsNullOrEmpty(effectDesc) ? "Enables the effect." : effectDesc);
			_configSection = "Effect: " + effectName;
		}

		public void RegisterEffectConfiguration()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			ConfigSyncBase.SyncedConfig(_configSection, "Effect Enabled", value: true, new ConfigDescription(_description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }), ref EnabledEffect);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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;
		}
	}
}
namespace ItemManager
{
	[PublicAPI]
	internal 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,
		[InternalName("piece_preptable")]
		FoodPreparationTable,
		[InternalName("piece_MeadCauldron")]
		MeadKetill,
		Custom
	}
	[PublicAPI]
	internal enum ConversionPiece
	{
		Disabled,
		[InternalName("smelter")]
		Smelter,
		[InternalName("charcoal_kiln")]
		CharcoalKiln,
		[InternalName("blastfurnace")]
		BlastFurnace,
		[InternalName("windmill")]
		Windmill,
		[InternalName("piece_spinningwheel")]
		SpinningWheel,
		[InternalName("eitrrefinery")]
		EitrRefinery,
		Custom
	}
	internal class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	internal 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]
	internal 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]
	internal 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]
	internal class Trade
	{
		public Trader Trader;

		public uint Price;

		public uint Stack = 1u;

		public string? RequiredGlobalKey;
	}
	[PublicAPI]
	[Flags]
	internal enum Trader
	{
		None = 0,
		Haldor = 1,
		Hildir = 2
	}
	internal 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;
	}
	internal struct CraftingStationConfig
	{
		public CraftingTable Table;

		public int level;

		public string? custom;
	}
	[Flags]
	internal enum Configurability
	{
		Disabled = 0,
		Recipe = 1,
		Stats = 2,
		Drop = 4,
		Trader = 8,
		Full = 0xF
	}
	[PublicAPI]
	internal 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, bool dontScale = false)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = (max ?? min),
				levelMultiplier = levelMultiplier,
				dontScale = dontScale
			});
		}
	}
	internal struct DropTarget
	{
		public string creature;

		public int min;

		public int max;

		public float chance;

		public bool levelMultiplier;

		public bool dontScale;
	}
	internal enum Toggle
	{
		On = 1,
		Off = 0
	}
	[PublicAPI]
	internal 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;

			[UsedImplicitly]
			public Action<IUguiDrawerScope>? CustomUguiDrawer;

			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] { ':' });
					int result;
					int result2;
					return new Requirement
					{
						itemName = array[0],
						amount = ((array.Length <= 1 || !int.TryParse(array[1], out result)) ? 1 : result),
						quality = ((array.Length > 2 && int.TryParse(array[2], out result2)) ? result2 : 0)
					};
				}).ToList())
			{
			}

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

			public static ItemDrop? fetchByName(ObjectDB objectDB, string name)
			{
				GameObject itemPrefab = objectDB.GetItemPrefab(name);
				ItemDrop obj = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					LogManager.Log.Warning("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";
					float result3;
					return new DropTarget
					{
						creature = array[0],
						chance = ((array.Length > 1 && float.TryParse(array[1], out result3)) ? result3 : 1f),
						min = result,
						max = result2,
						levelMultiplier = levelMultiplier
					};
				}).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 = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Character>() : null);
				if ((Object)(object)obj == (Object)null)
				{
					LogManager.Log.Debug("The drop target character '" + name + "' does not exist.");
				}
				return obj;
			}

			public Dictionary<Character, Drop> toCharacterDrops(ZNetScene netScene, GameObject item, bool adjustLevel = false, bool adjustScaling = false)
			{
				//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_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: 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 = adjustLevel,
							m_dontScale = !adjustScaling
						};
					}
				}
				return dictionary;
			}
		}

		private static bool _initialized;

		private static readonly MethodBase? _itemTarget;

		private static readonly List<Item> registeredItems;

		private static readonly Dictionary<ItemDrop, Item> itemDropMap;

		private static Dictionary<Item, Dictionary<string, List<Recipe>>> activeRecipes;

		private static Dictionary<Recipe, ConfigEntryBase?> hiddenCraftRecipes;

		private static Dictionary<Recipe, ConfigEntryBase?> hiddenUpgradeRecipes;

		private static Dictionary<Item, Dictionary<string, ItemConfig>> itemCraftConfigs;

		private static Dictionary<Item, ConfigEntry<string>> itemDropConfigs;

		private static Dictionary<Item, ConfigEntry<bool>> itemDropEnabledConfig;

		private static Dictionary<Item, ConfigEntry<bool>> itemDropScalingConfig;

		private static Dictionary<Item, ConfigEntry<bool>> itemDropLevelingConfig;

		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;

		public string SectionName = string.Empty;

		public static Configurability DefaultConfigurability;

		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 static object? configManager;

		private static BaseUnityPlugin? _plugin;

		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 ItemRecipe value))
				{
					return value;
				}
				return Recipes[name] = new ItemRecipe();
			}
		}

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Expected O, but got Unknown
				if ((Object)(object)_plugin == (Object)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;
			}
		}

		static Item()
		{
			_initialized = false;
			_itemTarget = AccessTools.DeclaredMethod(typeof(Item), "Patch_FejdStartup", (Type[])null, (Type[])null);
			registeredItems = new List<Item>();
			itemDropMap = new Dictionary<ItemDrop, Item>();
			activeRecipes = new Dictionary<Item, Dictionary<string, List<Recipe>>>();
			hiddenCraftRecipes = new Dictionary<Recipe, ConfigEntryBase>();
			hiddenUpgradeRecipes = new Dictionary<Recipe, ConfigEntryBase>();
			itemCraftConfigs = new Dictionary<Item, Dictionary<string, ItemConfig>>();
			itemDropConfigs = new Dictionary<Item, ConfigEntry<string>>();
			itemDropEnabledConfig = new Dictionary<Item, ConfigEntry<bool>>();
			itemDropScalingConfig = new Dictionary<Item, ConfigEntry<bool>>();
			itemDropLevelingConfig = new Dictionary<Item, ConfigEntry<bool>>();
			requirementQuality = new ConditionalWeakTable<Requirement, RequirementQuality>();
			DefaultConfigurability = Configurability.Full;
			if (_itemTarget != null)
			{
				DynamicPatches.Register(_itemTarget, 848123570u, "Ei8+Ngs6LzgzPik=");
			}
		}

		public static void Init()
		{
			if (!_initialized)
			{
				_initialized = true;
			}
		}

		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 ((Object)(object)prefab == (Object)null)
			{
				LogManager.Log?.Warning("Attempted to initialize Item with a null prefab.");
				Prefab = null;
				return;
			}
			if (!skipRegistering)
			{
				PrefabManager.RegisterPrefab(prefab, addToObjectDb: true);
			}
			Prefab = prefab;
			registeredItems.Add(this);
			ItemDrop component = Prefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				itemDropMap[component] = this;
				if (component.m_itemData != null)
				{
					component.m_itemData.m_dropPrefab = Prefab;
				}
			}
		}

		public void ToggleConfigurationVisibility(Configurability visible)
		{
			configurationVisible = visible;
			if (itemDropConfigs.TryGetValue(this, out ConfigEntry<string> value))
			{
				Toggle((ConfigEntryBase)(object)value, Configurability.Drop);
			}
			if (itemCraftConfigs.TryGetValue(this, out Dictionary<string, ItemConfig> 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) != Configurability.Disabled)
				{
					statsConfig.Value();
				}
			}
			reloadConfigDisplay();
			void Toggle(ConfigEntryBase cfg, Configurability check)
			{
				object[] tags = cfg.Description.Tags;
				for (int i = 0; i < tags.Length; i++)
				{
					if (tags[i] is ConfigurationManagerAttributes configurationManagerAttributes)
					{
						configurationManagerAttributes.Browsable = (visible & check) != Configurability.Disabled && (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 List<Recipe> value))
			{
				value.First().m_enabled = table != CraftingTable.Disabled;
				if ((uint)table <= 1u)
				{
					value.First().m_craftingStation = null;
				}
				else if (table == CraftingTable.Custom)
				{
					GameObject prefab = ZNetScene.instance.GetPrefab(customTableValue);
					value.First().m_craftingStation = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<CraftingStation>() : null);
				}
				else
				{
					GameObject prefab2 = ZNetScene.instance.GetPrefab(getInternalName(table));
					value.First().m_craftingStation = (((Object)(object)prefab2 != (Object)null) ? prefab2.GetComponent<CraftingStation>() : null);
				}
			}
		}

		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 List<Recipe> value))
			{
				return;
			}
			foreach (Recipe item in value)
			{
				item.m_resources = SerializedRequirements.toPieceReqs(ObjectDB.instance, craftRequirements, upgradeRequirements);
			}
		}

		internal static void Patch_FejdStartup()
		{
			//IL_11e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_11e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_249a: Unknown result type (might be due to invalid IL or missing references)
			//IL_24a7: Expected O, but got Unknown
			//IL_12aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_1303: Expected I4, but got Unknown
			//IL_0c6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c80: Expected O, but got Unknown
			//IL_0d5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d6e: Expected O, but got Unknown
			//IL_0ddd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dea: Expected O, but got Unknown
			//IL_0e54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e61: Expected O, but got Unknown
			//IL_1437: Unknown result type (might be due to invalid IL or missing references)
			//IL_143a: Unknown result type (might be due to invalid IL or missing references)
			//IL_143c: Invalid comparison between Unknown and I4
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Expected O, but got Unknown
			//IL_143e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1442: Invalid comparison between Unknown and I4
			//IL_0fe4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1000: Expected O, but got Unknown
			//IL_1090: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ac: Expected O, but got Unknown
			//IL_1444: Unknown result type (might be due to invalid IL or missing references)
			//IL_1448: Invalid comparison between Unknown and I4
			//IL_1145: Unknown result type (might be due to invalid IL or missing references)
			//IL_1161: Expected O, but got Unknown
			//IL_1643: Unknown result type (might be due to invalid IL or missing references)
			//IL_1646: Unknown result type (might be due to invalid IL or missing references)
			//IL_1648: Invalid comparison between Unknown and I4
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Expected O, but got Unknown
			//IL_164a: Unknown result type (might be due to invalid IL or missing references)
			//IL_164e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1650: Invalid comparison between Unknown and I4
			//IL_1652: Unknown result type (might be due to invalid IL or missing references)
			//IL_1656: Invalid comparison between Unknown and I4
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Expected O, but got Unknown
			//IL_172b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1730: Unknown result type (might be due to invalid IL or missing references)
			//IL_1732: Unknown result type (might be due to invalid IL or missing references)
			//IL_1735: Invalid comparison between Unknown and I4
			//IL_1737: Unknown result type (might be due to invalid IL or missing references)
			//IL_173b: Invalid comparison between Unknown and I4
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Expected O, but got Unknown
			//IL_17aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_17ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_17af: Invalid comparison between Unknown and I4
			//IL_17b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_17b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_17b7: Invalid comparison between Unknown and I4
			//IL_07df: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f6: Expected O, but got Unknown
			//IL_17b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_17bd: Invalid comparison between Unknown and I4
			//IL_18fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_18fd: Invalid comparison between Unknown and I4
			//IL_08ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0901: Expected O, but got Unknown
			//IL_1afa: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b01: Invalid comparison between Unknown and I4
			//IL_1bca: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bcf: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bd1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bd5: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bd7: Invalid comparison between Unknown and I4
			//IL_1c46: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c49: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c4b: Invalid comparison between Unknown and I4
			//IL_1870: Unknown result type (might be due to invalid IL or missing references)
			//IL_1875: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c51: Invalid comparison between Unknown and I4
			//IL_1c53: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c57: Invalid comparison between Unknown and I4
			//IL_20c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_20c7: Invalid comparison between Unknown and I4
			if (_itemTarget != null)
			{
				DynamicPatches.Patch(_itemTarget);
			}
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type));
			if (DefaultConfigurability != Configurability.Disabled)
			{
				bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
				plugin.Config.SaveOnConfigSet = false;
				foreach (Item item3 in registeredItems.Where((Item i) => i.configurability != Configurability.Disabled))
				{
					Item item = item3;
					string text = (string.IsNullOrEmpty(item.SectionName) ? item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name : item.SectionName);
					string englishName = new Regex("['[\"\\]]").Replace(Localizer.GetTranslation("English", text), "").Trim();
					string localizedName = Localization.instance.Localize(text).Trim();
					int order = 0;
					if ((item.configurability & Configurability.Recipe) != Configurability.Disabled)
					{
						itemCraftConfigs[item] = new Dictionary<string, ItemConfig>();
						foreach (string item4 in item.Recipes.Keys.DefaultIfEmpty(""))
						{
							string configKey = item4;
							string text2 = ((configKey == "") ? "" : (" (" + configKey + ")"));
							if (configKey == "" && item.Configurable.HasValue && item.Crafting.Stations.Count == 0)
							{
								item.Crafting.Add(CraftingTable.Disabled, 1);
							}
							if (!item.Recipes.ContainsKey(configKey) || item.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							ItemConfig itemConfig = (itemCraftConfigs[item][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig;
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							ConfigSyncBase.SyncedConfig(englishName, "Crafting Station" + text2, item.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 = ((item.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}), ref cfg.table);
							ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = CustomTableBrowsability,
								Browsable = (CustomTableBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							ConfigSyncBase.SyncedConfig(englishName, "Custom Crafting Station" + text2, item.Recipes[configKey].Crafting.Stations.First().custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }), ref cfg.customTable);
							cfg.table.SettingChanged += TableConfigChanged;
							cfg.customTable.SettingChanged += TableConfigChanged;
							ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = TableLevelBrowsability,
								Browsable = (TableLevelBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							hideWhenNoneAttributes.Add(configurationManagerAttributes);
							ConfigSyncBase.SyncedConfig(englishName, "Crafting Station Level" + text2, item.Recipes[configKey].Crafting.Stations.First().level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }), ref cfg.tableLevel);
							cfg.tableLevel.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(configKey, out List<Recipe> value))
								{
									value.First().m_minStationLevel = cfg.tableLevel.Value;
								}
							};
							if (item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1)
							{
								ConfigSyncBase.SyncedConfig(englishName, "Maximum Crafting Station Level" + text2, (item.MaximumRequiredStationLevel == int.MaxValue) ? (item.Recipes[configKey].Crafting.Stations.First().level + item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }), ref cfg.maximumTableLevel);
							}
							ConfigSyncBase.SyncedConfig(englishName, "Require only one resource" + text2, item.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),
									browsability = TableLevelBrowsability,
									Browsable = (TableLevelBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}), ref cfg.requireOneIngredient);
							ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = QualityResultBrowsability,
								Browsable = (QualityResultBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.requireOneIngredient.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(configKey, out List<Recipe> value))
								{
									foreach (Recipe item5 in value)
									{
										item5.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On;
									}
								}
								qualityResultAttributes.Browsable = QualityResultBrowsability();
								reloadConfigDisplay();
							};
							ConfigSyncBase.SyncedConfig(englishName, "Quality Multiplier" + text2, item.Recipes[configKey].QualityResultAmountMultiplier, new ConfigDescription("Multiplies the crafted amount based on the quality of the resources when crafting " + englishName + ". Only works, if Require Only One Resource is true.", (AcceptableValueBase)null, new object[1] { qualityResultAttributes }), ref cfg.qualityResultAmountMultiplier);
							cfg.qualityResultAmountMultiplier.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item) && activeRecipes[item].TryGetValue(configKey, out List<Recipe> value))
								{
									foreach (Recipe item6 in value)
									{
										item6.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value;
									}
								}
							};
							if ((!item.Recipes[configKey].RequiredItems.Free || item.Recipes[configKey].RequiredItems.Requirements.Count > 0) && item.Recipes[configKey].RequiredItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.craft = itemConfig3("Crafting Costs" + text2, new SerializedRequirements(item.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false);
							}
							ItemDrop component = item.Prefab.GetComponent<ItemDrop>();
							if ((Object)(object)component != (Object)null && component.m_itemData.m_shared.m_maxQuality > 1 && (!item.Recipes[configKey].RequiredUpgradeItems.Free || item.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && item.Recipes[configKey].RequiredUpgradeItems.Requirements.All((Requirement r) => r.amountConfig == null))
							{
								cfg.upgrade = itemConfig3("Upgrading Costs" + text2, new SerializedRequirements(item.Recipes[configKey].RequiredUpgradeItems.Requirements).ToString(), "Item costs per level to upgrade " + englishName, isUpgrade: true);
							}
							if (cfg.craft != null)
							{
								cfg.craft.SettingChanged += ConfigChanged;
							}
							if (cfg.upgrade != null)
							{
								cfg.upgrade.SettingChanged += ConfigChanged;
							}
							void ConfigChanged(object o, EventArgs e)
							{
								item.UpdateCraftConfig(configKey, new SerializedRequirements(cfg.craft?.Value ?? ""), new SerializedRequirements(cfg.upgrade?.Value ?? ""));
							}
							bool CustomTableBrowsability()
							{
								return cfg.table.Value == CraftingTable.Custom;
							}
							bool ItemBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							bool QualityResultBrowsability()
							{
								return cfg.requireOneIngredient.Value == Toggle.On;
							}
							void TableConfigChanged(object o, EventArgs e)
							{
								item.UpdateItemTableConfig(configKey, cfg.table.Value, cfg.customTable.Value);
								customTableAttributes.Browsable = cfg.table.Value == CraftingTable.Custom;
								foreach (ConfigurationManagerAttributes item7 in hideWhenNoneAttributes)
								{
									item7.Browsable = cfg.table.Value != CraftingTable.Disabled;
								}
								reloadConfigDisplay();
							}
							bool TableLevelBrowsability()
							{
								return cfg.table.Value != CraftingTable.Disabled;
							}
							ConfigEntry<string> itemConfig3(string name, string value, string desc, bool isUpgrade)
							{
								//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
								//IL_00d7: Expected O, but got Unknown
								ConfigEntry<string> itemCfg = null;
								ConfigurationManagerAttributes configurationManagerAttributes3 = new ConfigurationManagerAttributes
								{
									CustomDrawer = drawRequirementsConfigTable(item, isUpgrade),
									CustomUguiDrawer = delegate(IUguiDrawerScope ui)
									{
										DrawRequirementsConfigTableUgui(ui, (ConfigEntryBase)(object)itemCfg);
									},
									Order = (order -= 1),
									browsability = ItemBrowsability,
									Browsable = (ItemBrowsability() && (item.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								};
								hideWhenNoneAttributes.Add(configurationManagerAttributes3);
								ConfigSyncBase.SyncedConfig(englishName, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes3 }), ref itemCfg);
								return itemCfg;
							}
						}
						if ((item.configurability & Configurability.Drop) != Configurability.Disabled)
						{
							ConfigEntry<bool> dropsEnabledConfig = null;
							ConfigSyncBase.SyncedConfig(englishName, "Drops Enabled", value: false, new ConfigDescription("Enables " + englishName + " drops", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Drop) != 0)
								}
							}), ref dropsEnabledConfig);
							itemDropEnabledConfig[item] = dropsEnabledConfig;
							ConfigEntry<string> dropConfig = null;
							ConfigurationManagerAttributes configurationManagerAttributes2 = new ConfigurationManagerAttributes
							{
								CustomDrawer = drawDropsConfigTable,
								CustomUguiDrawer = delegate(IUguiDrawerScope ui)
								{
									DrawDropsConfigTableUgui(ui, (ConfigEntryBase)(object)dropConfig);
								},
								Category = localizedName,
								Browsable = ((item.configurationVisible & Configurability.Drop) != 0)
							};
							ConfigSyncBase.SyncedConfig(englishName, "Drops from", new SerializedDrop(item.DropsFrom.Drops).ToString(), new ConfigDescription("Creatures " + englishName + " drops from", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes2 }), ref dropConfig);
							itemDropConfigs[item] = dropConfig;
							ConfigEntry<bool> configEntry = null;
							ConfigSyncBase.SyncedConfig(englishName, "Adjust Drop Count By Level", value: false, new ConfigDescription("Enables Level/Star Factor on Drops", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Drop) != 0)
								}
							}), ref configEntry);
							itemDropLevelingConfig[item] = configEntry;
							ConfigEntry<bool> configEntry2 = null;
							ConfigSyncBase.SyncedConfig(englishName, "Adjust Drop Count by World Scaling", value: false, new ConfigDescription("Enables Scaling Factor on Drops", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Drop) != 0)
								}
							}), ref configEntry2);
							itemDropScalingConfig[item] = configEntry2;
							dropsEnabledConfig.SettingChanged += delegate
							{
								item.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
							configEntry2.SettingChanged += delegate
							{
								item.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
							configEntry.SettingChanged += delegate
							{
								item.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
							dropConfig.SettingChanged += delegate
							{
								item.UpdateCharacterDrop(dropsEnabledConfig.Value);
							};
							item.UpdateCharacterDrop(dropsEnabledConfig.Value);
						}
						for (int num = 0; num < item.Conversions.Count; num++)
						{
							string text3 = ((item.Conversions.Count > 1) ? $"{num + 1}. " : "");
							Conversion conversion = item.Conversions[num];
							conversion.config = new Conversion.ConversionConfig();
							int index = num;
							ConfigSyncBase.SyncedConfig(englishName, text3 + "Conversion Input Item", conversion.Input, new ConfigDescription("Input item to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Recipe) != 0)
								}
							}), ref conversion.config.input);
							conversion.config.input.SettingChanged += delegate
							{
								if (index < item.conversions.Count)
								{
									ObjectDB instance = ObjectDB.instance;
									if (instance != null)
									{
										ItemDrop val = SerializedRequirements.fetchByName(instance, conversion.config.input.Value);
										item.conversions[index].m_from = val;
										UpdatePiece();
									}
								}
							};
							ConfigSyncBase.SyncedConfig(englishName, text3 + "Conversion Piece", conversion.Piece, new ConfigDescription("Conversion piece used to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Recipe) != 0)
								}
							}), ref conversion.config.piece);
							conversion.config.piece.SettingChanged += delegate
							{
								UpdatePiece();
							};
							ConfigSyncBase.SyncedConfig(englishName, text3 + "Conversion Custom Piece", conversion.customPiece ?? "", new ConfigDescription("Custom conversion piece to create " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Category = localizedName,
									Browsable = ((item.configurationVisible & Configurability.Recipe) != 0)
								}
							}), ref conversion.config.customPiece);
							conversion.config.customPiece.SettingChanged += delegate
							{
								UpdatePiece();
							};
							void UpdatePiece()
							{
								if (index < item.conversions.Count && Object.op_Implicit((Object)(object)ZNetScene.instance))
								{
									string text4 = ((conversion.config.piece.Value == ConversionPiece.Disabled) ? null : ((conversion.config.piece.Value == ConversionPiece.Custom) ? conversion.config.customPiece.Value : getInternalName(conversion.config.piece.Value)));
									string activePiece = conversion.config.activePiece;
									if (conversion.config.activePiece != null)
									{
										GameObject prefab = ZNetScene.instance.GetPrefab(conversion.config.activePiece);
										Smelter val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Smelter>() : null);
										if ((Object)(object)val != (Object)null)
										{
											int num4 = val.m_conversion.IndexOf(item.conversions[index]);
											if (num4 >= 0)
											{
												Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
												foreach (Smelter val2 in array3)
												{
													if ((Object)(object)val2 != (Object)null && Utils.GetPrefabName(((Component)val2).gameObject) == activePiece)
													{
														val2.m_conversion.RemoveAt(num4);
													}
												}
												val.m_conversion.RemoveAt(num4);
											}
										}
										conversion.config.activePiece = null;
									}
									if ((Object)(object)item.conversions[index].m_from != (Object)null && conversion.config.piece.Value != ConversionPiece.Disabled)
									{
										GameObject prefab2 = ZNetScene.instance.GetPrefab(text4);
										if ((Object)(object)prefab2 != (Object)null && (Object)(object)prefab2.GetComponent<Smelter>() != (Object)null)
										{
											conversion.config.activePiece = text4;
											Smelter[] array3 = Resources.FindObjectsOfTypeAll<Smelter>();
											foreach (Smelter val3 in array3)
											{
												if ((Object)(object)val3 != (Object)null && Utils.GetPrefabName(((Component)val3).gameObject) == text4)
												{
													val3.m_conversion.Add(item.conversions[index]);
												}
											}
										}
									}
								}
							}
						}
					}
					if ((item.configurability & Configurability.Stats) != Configurability.Disabled)
					{
						item.statsConfigs.Clear();
						SharedData shared = item.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
						ItemType itemType = shared.m_itemType;
						statcfg<float>("Weight", "Weight of " + englishName + ".", (SharedData val) => val.m_weight, delegate(SharedData val, float value)
						{
							val.m_weight = value;
						});
						statcfg<int>("Trader Value", "Trader value of " + englishName + ".", (SharedData val) => val.m_value, delegate(SharedData val, int value)
						{
							val.m_value = value;
						});
						bool flag;
						switch (itemType - 3)
						{
						case 0:
						case 1:
						case 2:
						case 3:
						case 4:
						case 8:
						case 9:
						case 11:
						case 14:
						case 16:
						case 19:
							flag = true;
							break;
						default:
							flag = false;
							break;
						}
						if (flag)
						{
							statcfg<float>("Durability", "Durability of " + englishName + ".", (SharedData val) => val.m_maxDurability, delegate(SharedData val, float value)
							{
								val.m_maxDurability = value;
							});
							statcfg<float>("Durability per Level", "Durability gain per level of " + englishName + ".", (SharedData val) => val.m_durabilityPerLevel, delegate(SharedData val, float value)
							{
								val.m_durabilityPerLevel = value;
							});
							statcfg<float>("Movement Speed Modifier", "Movement speed modifier of " + englishName + ".", (SharedData val) => val.m_movementModifier, delegate(SharedData val, float value)
							{
								val.m_movementModifier = value;
							});
						}
						if ((itemType - 3 <= 2 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
						{
							statcfg<float>("Block Armor", "Block armor of " + englishName + ".", (SharedData val) => val.m_blockPower, delegate(SharedData val, float value)
							{
								val.m_blockPower = value;
							});
							statcfg<float>("Block Armor per Level", "Block armor per level for " + englishName + ".", (SharedData val) => val.m_blockPowerPerLevel, delegate(SharedData val, float value)
							{
								val.m_blockPowerPerLevel = value;
							});
							statcfg<float>("Block Force", "Block force of " + englishName + ".", (SharedData val) => val.m_deflectionForce, delegate(SharedData val, float value)
							{
								val.m_deflectionForce = value;
							});
							statcfg<float>("Block Force per Level", "Block force per level for " + englishName + ".", (SharedData val) => val.m_deflectionForcePerLevel, delegate(SharedData val, float value)
							{
								val.m_deflectionForcePerLevel = value;
							});
							statcfg<float>("Parry Bonus", "Parry bonus of " + englishName + ".", (SharedData val) => val.m_timedBlockBonus, delegate(SharedData val, float value)
							{
								val.m_timedBlockBonus = value;
							});
						}
						else if ((itemType - 6 <= 1 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
						{
							statcfg<float>("Armor", "Armor of " + englishName + ".", (SharedData val) => val.m_armor, delegate(SharedData val, float value)
							{
								val.m_armor = value;
							});
							statcfg<float>("Armor per Level", "Armor per level for " + englishName + ".", (SharedData val) => val.m_armorPerLevel, delegate(SharedData val, float value)
							{
								val.m_armorPerLevel = value;
							});
						}
						SkillType skillType = shared.m_skillType;
						if (((int)skillType == 7 || (int)skillType == 12) ? true : false)
						{
							statcfg<int>("Tool tier", "Tool tier of " + englishName + ".", (SharedData val) => val.m_toolTier, delegate(SharedData val, int value)
							{
								val.m_toolTier = value;
							});
						}
						if ((itemType - 5 <= 2 || itemType - 11 <= 1 || (int)itemType == 17) ? true : false)
						{
							Dictionary<DamageType, DamageModifier> modifiers = shared.m_damageModifiers.ToDictionary((DamageModPair d) => d.m_type, (DamageModPair d) => (DamageModifier)d.m_modifier);
							DamageType[] first = (DamageType[])Enum.GetValues(typeof(DamageType));
							DamageType[] array = new DamageType[5];
							RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
							foreach (DamageType damageType in first.Except((IEnumerable<DamageType>)(object)array))
							{
								statcfg<DamageModifier>(((object)Unsafe.As<DamageType, DamageType>(ref damageType)/*cast due to .constrained prefix*/).ToString() + " Resistance", ((object)Unsafe.As<DamageType, DamageType>(ref damageType)/*cast due to .constrained prefix*/).ToString() + " resistance of " + englishName + ".", (SharedData _) => (!modifiers.TryGetValue(damageType, out var value)) ? DamageModifier.None : value, delegate(SharedData val2, DamageModifier value)
								{
									//IL_0002: Unknown result type (might be due to invalid IL or missing references)
									//IL_000b: Unknown result type (might be due to invalid IL or missing references)
									//IL_0010: Unknown result type (might be due to invalid IL or missing references)
									//IL_0018: Unknown result type (might be due to invalid IL or missing references)
									//IL_001d: Unknown result type (might be due to invalid IL or missing references)
									//IL_001e: Unknown result type (might be due to invalid IL or missing references)
									//IL_002a: Unknown result type (might be due to invalid IL or missing references)
									//IL_002f: Unknown result type (might be due to invalid IL or missing references)
									//IL_0035: Unknown result type (might be due to invalid IL or missing references)
									//IL_0077: Unknown result type (might be due to invalid IL or missing references)
									//IL_0054: Unknown result type (might be due to invalid IL or missing references)
									DamageModPair val = new DamageModPair
									{
										m_type = damageType,
										m_modifier = (DamageModifier)value
									};
									for (int i = 0; i < val2.m_damageModifiers.Count; i++)
									{
										if (val2.m_damageModifiers[i].m_type == damageType)
										{
											if (value == DamageModifier.None)
											{
												val2.m_damageModifiers.RemoveAt(i);
											}
											else
											{
												val2.m_damageModifiers[i] = val;
											}
											return;
										}
									}
									if (value != DamageModifier.None)
									{
										val2.m_damageModifiers.Add(val);
									}
								});
							}
						}
						if ((int)itemType == 2 && shared.m_food > 0f)
						{
							statcfg<float>("Health", "Health value of " + englishName + ".", (SharedData val) => val.m_food, delegate(SharedData val, float value)
							{
								val.m_food = value;
							});
							statcfg<float>("Stamina", "Stamina value of " + englishName + ".", (SharedData val) => val.m_foodStamina, delegate(SharedData val, float value)
							{
								val.m_foodStamina = value;
							});
							statcfg<float>("Eitr", "Eitr value of " + englishName + ".", (SharedData val) => val.m_foodEitr, delegate(SharedData val, float value)
							{
								val.m_foodEitr = value;
							});
							statcfg<float>("Duration", "Duration of " + englishName + ".", (SharedData val) => val.m_foodBurnTime, delegate(SharedData val, float value)
							{
								val.m_foodBurnTime = value;
							});
							statcfg<float>("Health Regen", "Health regen value of " + englishName + ".", (SharedData val) => val.m_foodRegen, delegate(SharedData val, float value)
							{
								val.m_foodRegen = value;
							});
						}
						if ((int)shared.m_skillType == 10)
						{
							statcfg<float>("Health Cost", "Health cost of " + englishName + ".", (SharedData val) => val.m_attack.m_attackHealth, delegate(SharedData val, float value)
							{
								val.m_attack.m_attackHealth = value;
							});
							statcfg<float>("Health Cost Percentage", "Health cost percentage of " + englishName + ".", (SharedData val) => val.m_attack.m_attackHealthPercentage, delegate(SharedData val, float value)
							{
								val.m_attack.m_attackHealthPercentage = value;
							});
						}
						skillType = shared.m_skillType;
						if (skillType - 9 <= 1)
						{
							statcfg<float>("Eitr Cost", "Eitr cost of " + englishName + ".", (SharedData val) => val.m_attack.m_attackEitr, delegate(SharedData val, float value)
							{
								val.m_attack.m_attackEitr = value;
							});
						}
						if ((itemType - 3 <= 1 || (int)itemType == 14 || (int)itemType == 22) ? true : false)
						{
							statcfg<float>("Knockback", "Knockback of " + englishName + ".", (SharedData val) => val.m_attackForce, delegate(SharedData val, float value)
							{
								val.m_attackForce = value;
							});
							statcfg<float>("Backstab Bonus", "Backstab bonus of " + englishName + ".", (SharedData val) => val.m_backstabBonus, delegate(SharedData val, float value)
							{
								val.m_backstabBonus = value;
							});
							statcfg<float>("Attack Stamina", "Attack stamina of " + englishName + ".", (SharedData val) => val.m_attack.m_attackStamina, delegate(SharedData val, float value)
							{
								val.m_attack.m_attackStamina = value;
							});
							SetDmg("True", (DamageTypes dmg) => dmg.m_damage, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_damage = val;
							});
							SetDmg("Slash", (DamageTypes dmg) => dmg.m_slash, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_slash = val;
							});
							SetDmg("Pierce", (DamageTypes dmg) => dmg.m_pierce, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_pierce = val;
							});
							SetDmg("Blunt", (DamageTypes dmg) => dmg.m_blunt, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_blunt = val;
							});
							SetDmg("Chop", (DamageTypes dmg) => dmg.m_chop, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_chop = val;
							});
							SetDmg("Pickaxe", (DamageTypes dmg) => dmg.m_pickaxe, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_pickaxe = val;
							});
							SetDmg("Fire", (DamageTypes dmg) => dmg.m_fire, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_fire = val;
							});
							SetDmg("Poison", (DamageTypes dmg) => dmg.m_poison, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_poison = val;
							});
							SetDmg("Frost", (DamageTypes dmg) => dmg.m_frost, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_frost = val;
							});
							SetDmg("Lightning", (DamageTypes dmg) => dmg.m_lightning, delegate(ref DamageTypes dmg, float val)
							{
								dmg.m_lightning = val;
							});
							SetDmg("Spirit", (DamageTypes dmg) => dmg.m_spirit, delegate(ref DamageTypes dmg, float val)
							{
								dmg