Decompiled source of GlassPieces v1.2.5

GlassPieces.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.5")]
[assembly: AssemblyInformationalVersion("1.2.5")]
[assembly: AssemblyProduct("GlassPieces")]
[assembly: AssemblyTitle("GlassPieces")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace GlassPieces
{
	[BepInPlugin("blacks7ar.GlassPieces", "GlassPieces", "1.2.5")]
	public class Plugin : BaseUnityPlugin
	{
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		private const string modGUID = "blacks7ar.GlassPieces";

		public const string modName = "GlassPieces";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "1.2.5";

		public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/GlassPieces/";

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

		private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.GlassPieces")
		{
			DisplayName = "GlassPieces",
			CurrentVersion = "1.2.5",
			MinimumRequiredVersion = "1.2.5"
		};

		private static ConfigEntry<Toggle> _serverConfigLocked;

		public static ConfigEntry<Toggle> _automaticDoor;

		public static ConfigEntry<Toggle> _enablePickables;

		public static ConfigEntry<float> _silicaPickableGroupRadius;

		public static ConfigEntry<int> _silicaPickableGroupSizeMin;

		public static ConfigEntry<int> _silicaPickableGroupSizeMax;

		public static ConfigEntry<float> _silicaPickableMax;

		public static ConfigEntry<float> _silicaVeinGroupRadius;

		public static ConfigEntry<int> _silicaVeinGroupSizeMin;

		public static ConfigEntry<int> _silicaVeinGroupSizeMax;

		public static ConfigEntry<float> _silicaVeinMax;

		public static ConfigEntry<float> _secPerUnit;

		public static ConfigEntry<int> _maxProduct;

		private static ConfigEntry<Toggle> _enableSmelter;

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

		public void Awake()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Expected O, but got Unknown
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Expected O, but got Unknown
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Expected O, but got Unknown
			Localizer.Load();
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			_serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>()));
			_configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			_automaticDoor = config("2- General", "Automatic Door", Toggle.On, new ConfigDescription("If On, sliding glass door will automatically open and close.", (AcceptableValueBase)null, Array.Empty<object>()));
			_secPerUnit = config("2- General", "Collector Duration", 1200f, new ConfigDescription("How long does the collector would take to transmute the item.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(300f, 2400f), Array.Empty<object>()));
			_maxProduct = config("2- General", "Collector Max Capacity", 10, new ConfigDescription("Maximum capacity.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), Array.Empty<object>()));
			_enableSmelter = config("2- General", "Use Smelter", Toggle.Off, new ConfigDescription("If On, smelting silica ores into smelters will be enabled.\nFor those who wants to build glass pieces early.\nNeeds a Logout.", (AcceptableValueBase)null, Array.Empty<object>()));
			_enablePickables = config("3- Silica-Pickable", "Enable Pickable", Toggle.On, new ConfigDescription("If On, pickable silica ores will be spawned across different biomes.", (AcceptableValueBase)null, Array.Empty<object>()));
			_silicaPickableGroupRadius = config("3- Silica-Pickable", "Group Radius", 48f, new ConfigDescription("Group radius.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 200f), Array.Empty<object>()));
			_silicaPickableGroupSizeMin = config("3- Silica-Pickable", "Group Size Min", 2, new ConfigDescription("Minimum group size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
			_silicaPickableGroupSizeMax = config("3- Silica-Pickable", "Group Size Max", 4, new ConfigDescription("Maximum group size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>()));
			_silicaPickableMax = config("3- Silica-Pickable", "Max", 20f, new ConfigDescription("Maximum amount per zone.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			_silicaVeinGroupRadius = config("4- Silica-Vein", "Group Radius", 80f, new ConfigDescription("Group radius.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 200f), Array.Empty<object>()));
			_silicaVeinGroupSizeMin = config("4- Silica-Vein", "Group Size Min", 1, new ConfigDescription("Minimum group size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), new object[1]
			{
				new GlassPieces.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_silicaVeinGroupSizeMax = config("4- Silica-Vein", "Group Size Max", 1, new ConfigDescription("Maximum group size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), new object[1]
			{
				new GlassPieces.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_silicaVeinMax = config("4- Silica-Vein", "Max", 2f, new ConfigDescription("Maximum amount per zone.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), new object[1]
			{
				new GlassPieces.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			SetupPrefabs.Init();
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.Save();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
		}

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

		public static void SetFurnace(ZNetScene zNetScene)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			if (Helper.ZNetSceneAwake())
			{
				zNetScene.GetPrefab("blastfurnace").GetComponent<Smelter>().m_conversion.Add(new ItemConversion
				{
					m_from = zNetScene.GetPrefab("BGP_SilicaOre").GetComponent<ItemDrop>(),
					m_to = zNetScene.GetPrefab("BGP_Glass").GetComponent<ItemDrop>()
				});
				if (_enableSmelter.Value == Toggle.On)
				{
					zNetScene.GetPrefab("smelter").GetComponent<Smelter>().m_conversion.Add(new ItemConversion
					{
						m_from = zNetScene.GetPrefab("BGP_SilicaOre").GetComponent<ItemDrop>(),
						m_to = zNetScene.GetPrefab("BGP_Glass").GetComponent<ItemDrop>()
					});
				}
			}
		}

		public static void SetMineRock(ZNetScene zNetScene)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (Helper.ZNetSceneAwake())
			{
				SetupPrefabs._silicaVein.GetComponent<MineRock>().m_dropItems.m_drops.Add(new DropData
				{
					m_item = zNetScene.GetPrefab("Stone"),
					m_stackMin = 1,
					m_stackMax = 1,
					m_weight = 0.4f,
					m_dontScale = false
				});
			}
		}

		public static void SetCollector(ZNetScene zNetScene)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			if (Helper.ZNetSceneAwake())
			{
				Collector component = zNetScene.GetPrefab("BGP_SilicaCollector").GetComponent<Collector>();
				component.m_name = "$bgp_silica_collector";
				component.m_spawnPoint = Utils.FindChild(((Component)component).gameObject.transform, "spawnpoint", (IterativeSearchType)0);
				component.m_workingEffect = ((Component)Utils.FindChild(((Component)component).gameObject.transform, "working", (IterativeSearchType)0)).gameObject;
				component.m_secPerUnit = _secPerUnit.Value;
				component.m_maxProduct = _maxProduct.Value;
				component.m_productItem = zNetScene.GetPrefab("BGP_SilicaOre").GetComponent<ItemDrop>();
				component.m_spawnEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[2]
				{
					new EffectData
					{
						m_prefab = zNetScene.GetPrefab("sfx_pickable_pick"),
						m_enabled = true,
						m_variant = -1
					},
					new EffectData
					{
						m_prefab = zNetScene.GetPrefab("vfx_pickable_pick"),
						m_enabled = true,
						m_variant = -1
					}
				};
			}
		}
	}
}
namespace GlassPieces.Patches
{
	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	public class ZNetScenePatch
	{
		public static void Postfix(ZNetScene __instance)
		{
			Plugin.SetFurnace(__instance);
			Plugin.SetMineRock(__instance);
			Plugin.SetCollector(__instance);
		}
	}
	[HarmonyPatch(typeof(ZoneSystem), "ValidateVegetation")]
	public class ZoneSystemPatch
	{
		private static readonly List<ZoneVegetation> _silicaList = new List<ZoneVegetation>();

		private static void Prefix(ZoneSystem __instance)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			foreach (ZoneVegetation silica in _silicaList)
			{
				__instance.m_vegetation.Remove(silica);
			}
			_silicaList.Clear();
			ZoneVegetation item = new ZoneVegetation
			{
				m_biome = (Biome)30,
				m_groupRadius = Plugin._silicaPickableGroupRadius.Value,
				m_groupSizeMin = Plugin._silicaPickableGroupSizeMin.Value,
				m_groupSizeMax = Plugin._silicaPickableGroupSizeMax.Value,
				m_minAltitude = 0f,
				m_max = Plugin._silicaPickableMax.Value,
				m_prefab = SetupPrefabs._pickable,
				m_enable = (Plugin._enablePickables.Value == Plugin.Toggle.On)
			};
			ZoneVegetation item2 = new ZoneVegetation
			{
				m_biome = (Biome)16,
				m_groupRadius = Plugin._silicaVeinGroupRadius.Value,
				m_groupSizeMin = Plugin._silicaVeinGroupSizeMin.Value,
				m_groupSizeMax = Plugin._silicaVeinGroupSizeMax.Value,
				m_max = Plugin._silicaVeinMax.Value,
				m_chanceToUseGroundTilt = 1f,
				m_minAltitude = -0.5f,
				m_prefab = SetupPrefabs._silicaVein
			};
			_silicaList.Add(item);
			_silicaList.Add(item2);
			foreach (ZoneVegetation silica2 in _silicaList)
			{
				__instance.m_vegetation.Add(silica2);
			}
		}
	}
}
namespace GlassPieces.Functions
{
	public class Collector : MonoBehaviour, Hoverable, Interactable
	{
		public string m_name = "";

		public Transform m_spawnPoint;

		public float m_secPerUnit = 1200f;

		public int m_maxProduct = 4;

		public ItemDrop m_productItem;

		public EffectList m_spawnEffect = new EffectList();

		public GameObject m_workingEffect;

		public string m_extractText = "$bgp_collector_extract";

		public string m_collectingText = "$bgp_collector_collecting";

		public string m_fullText = "$bgp_collector_full";

		public ZNetView m_nview;

		private Collider m_collider;

		private Piece m_piece;

		public void Awake()
		{
			m_nview = ((Component)this).GetComponent<ZNetView>();
			m_collider = ((Component)this).GetComponentInChildren<Collider>();
			m_piece = ((Component)this).GetComponent<Piece>();
			if (m_nview.GetZDO() != null)
			{
				if (m_nview.IsOwner() && m_nview.GetZDO().GetLong(ZDOVars.s_lastTime, 0L) == 0L)
				{
					m_nview.GetZDO().Set(ZDOVars.s_lastTime, ZNet.instance.GetTime().Ticks);
				}
				m_nview.Register("RPC_Extract", (Action<long>)RPC_Extract);
				m_nview.Register("RPC_UpdateEffects", (Action<long>)RPC_UpdateEffects);
				((MonoBehaviour)this).InvokeRepeating("UpdateTicks", 0f, 10f);
				Plugin._secPerUnit.SettingChanged += delegate
				{
					m_secPerUnit = Plugin._secPerUnit.Value;
				};
				m_secPerUnit = Plugin._secPerUnit.Value;
				Plugin._maxProduct.SettingChanged += delegate
				{
					m_maxProduct = Plugin._maxProduct.Value;
				};
				m_maxProduct = Plugin._maxProduct.Value;
			}
		}

		public string GetHoverText()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, false, false))
			{
				return Localization.instance.Localize(m_name + "\n$bgp_noaccess");
			}
			int level = GetLevel();
			string statusText = GetStatusText();
			string name = m_productItem.m_itemData.m_shared.m_name;
			string text = m_name + "\n" + statusText + " " + name + "\n( " + level + " / " + m_maxProduct + " ) <color=orange>" + TimeLeft() + "</color>";
			if (level > 0)
			{
				text = text + "\n[<color=yellow><b>$KEY_Use</b></color>] " + m_extractText;
			}
			return Localization.instance.Localize(text);
		}

		public string GetHoverName()
		{
			return m_name;
		}

		public bool Interact(Humanoid character, bool repeat, bool alt)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if (repeat)
			{
				return false;
			}
			if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false))
			{
				return true;
			}
			if (GetLevel() <= 0)
			{
				return false;
			}
			Extract();
			return true;
		}

		private string GetStatusText()
		{
			if (GetLevel() < m_maxProduct)
			{
				return m_collectingText;
			}
			return m_fullText;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		public void Extract()
		{
			m_nview.InvokeRPC("RPC_Extract", Array.Empty<object>());
		}

		public void RPC_Extract(long caller)
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//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_006c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			int level = GetLevel();
			if (level > 0)
			{
				m_spawnEffect.Create(m_spawnPoint.position, Quaternion.identity, (Transform)null, 1f, -1);
				for (int i = 0; i < level; i++)
				{
					Vector2 val = Random.insideUnitCircle * 0.5f;
					Vector3 val2 = m_spawnPoint.position + new Vector3(val.x, 0.25f * (float)i, val.y);
					Object.Instantiate<ItemDrop>(m_productItem, val2, Quaternion.identity);
				}
				ResetLevel();
				m_nview.InvokeRPC(ZNetView.Everybody, "RPC_UpdateEffects", Array.Empty<object>());
			}
		}

		private float GetTimeSinceLastUpdate()
		{
			DateTime dateTime = new DateTime(m_nview.GetZDO().GetLong(ZDOVars.s_lastTime, ZNet.instance.GetTime().Ticks));
			DateTime time = ZNet.instance.GetTime();
			TimeSpan timeSpan = time - dateTime;
			m_nview.GetZDO().Set(ZDOVars.s_lastTime, time.Ticks);
			double num = timeSpan.TotalSeconds;
			if (num < 0.0)
			{
				num = 0.0;
			}
			return (float)num;
		}

		public void ResetLevel()
		{
			m_nview.GetZDO().Set(ZDOVars.s_level, 0, false);
		}

		public void IncreaseLevel(int i)
		{
			int level = GetLevel();
			level++;
			level = Mathf.Clamp(level, 0, m_maxProduct);
			m_nview.GetZDO().Set(ZDOVars.s_level, level, false);
		}

		private int GetLevel()
		{
			if (m_nview.GetZDO() != null)
			{
				return m_nview.GetZDO().GetInt(ZDOVars.s_level, 0);
			}
			return 0;
		}

		public void UpdateTicks()
		{
			if (m_nview.IsOwner())
			{
				float timeSinceLastUpdate = GetTimeSinceLastUpdate();
				if (GetLevel() < m_maxProduct)
				{
					float @float = m_nview.GetZDO().GetFloat(ZDOVars.s_product, 0f);
					@float += timeSinceLastUpdate;
					if (@float > m_secPerUnit)
					{
						int i = (int)(@float / m_secPerUnit);
						IncreaseLevel(i);
						@float = 0f;
					}
					m_nview.GetZDO().Set(ZDOVars.s_product, @float);
				}
			}
			UpdateEffects();
		}

		public void RPC_UpdateEffects(long caller)
		{
			UpdateEffects();
		}

		public void UpdateEffects()
		{
			bool active = GetLevel() < m_maxProduct;
			m_workingEffect.SetActive(active);
		}

		private string TimeLeft()
		{
			string result = "";
			if (GetLevel() == m_maxProduct)
			{
				return result;
			}
			if (!m_nview.IsValid() || !m_nview.IsOwner())
			{
				return result;
			}
			float @float = m_nview.GetZDO().GetFloat(ZDOVars.s_product, 0f);
			float num = m_secPerUnit - @float - Time.deltaTime;
			int num2 = Mathf.FloorToInt((float)((int)num / 60));
			int num3 = Mathf.FloorToInt((float)((int)num % 60));
			return $"[ {num2:00}:{num3:00} ]";
		}
	}
	public class ConfigurationManagerAttributes
	{
		[UsedImplicitly]
		public bool? ShowRangeAsPercent;
	}
	public static class Helper
	{
		public static bool ZNetSceneAwake()
		{
			if ((Object)(object)ZNetScene.instance != (Object)null && ZNetScene.instance.m_prefabs.Count != 0)
			{
				return (Object)(object)ZNetScene.instance.GetPrefab("piece_workbench") != (Object)null;
			}
			return false;
		}
	}
	public static class SetupPrefabs
	{
		private static AssetBundle _glassBundle;

		public static GameObject _sfxOpen;

		public static GameObject _pickable;

		public static GameObject _silicaVein;

		private const string _ironCategory = "GlassPieces-Iron";

		private const string _copperCategory = "GlassPieces-Copper";

		public static void Init()
		{
			_glassBundle = PiecePrefabManager.RegisterAssetBundle("glassbundle");
			Others();
			Iron();
			Copper();
			new Item(_glassBundle, "BGP_Glass").Configurable = Configurability.Disabled;
			new Item(_glassBundle, "BGP_SilicaOre").Configurable = Configurability.Disabled;
		}

		private static void Iron()
		{
			BuildPiece buildPiece = new BuildPiece(_glassBundle, "BGP_DiagonalBeam26");
			buildPiece.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece.Category.Set("GlassPieces-Iron");
			buildPiece.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece.Prefab);
			BuildPiece buildPiece2 = new BuildPiece(_glassBundle, "BGP_DiagonalBeam45");
			buildPiece2.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece2.Category.Set("GlassPieces-Iron");
			buildPiece2.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece2.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece2.Prefab);
			BuildPiece buildPiece3 = new BuildPiece(_glassBundle, "BGP_GlassDoor");
			buildPiece3.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece3.Category.Set("GlassPieces-Iron");
			buildPiece3.RequiredItems.Add("Iron", 3, recover: true);
			buildPiece3.RequiredItems.Add("BGP_Glass", 4, recover: true);
			buildPiece3.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece3.Prefab);
			BuildPiece buildPiece4 = new BuildPiece(_glassBundle, "BGP_GlassFloorRoof");
			buildPiece4.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece4.Category.Set("GlassPieces-Iron");
			buildPiece4.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece4.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece4.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece4.Prefab);
			BuildPiece buildPiece5 = new BuildPiece(_glassBundle, "BGP_GlassFloorRoof_Half");
			buildPiece5.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece5.Category.Set("GlassPieces-Iron");
			buildPiece5.RequiredItems.Add("Iron", 1, recover: true);
			buildPiece5.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece5.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece5.Prefab);
			BuildPiece buildPiece6 = new BuildPiece(_glassBundle, "BGP_GlassHalfWall");
			buildPiece6.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece6.Category.Set("GlassPieces-Iron");
			buildPiece6.RequiredItems.Add("Iron", 1, recover: true);
			buildPiece6.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece6.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece6.Prefab);
			BuildPiece buildPiece7 = new BuildPiece(_glassBundle, "BGP_GlassHalfWall_Vertical");
			buildPiece7.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece7.Category.Set("GlassPieces-Iron");
			buildPiece7.RequiredItems.Add("Iron", 1, recover: true);
			buildPiece7.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece7.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece7.Prefab);
			BuildPiece buildPiece8 = new BuildPiece(_glassBundle, "BGP_GlassQuarterWall");
			buildPiece8.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece8.Category.Set("GlassPieces-Iron");
			buildPiece8.RequiredItems.Add("Iron", 1, recover: true);
			buildPiece8.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece8.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece8.Prefab);
			BuildPiece buildPiece9 = new BuildPiece(_glassBundle, "BGP_GlassRoof26");
			buildPiece9.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece9.Category.Set("GlassPieces-Iron");
			buildPiece9.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece9.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece9.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece9.Prefab);
			BuildPiece buildPiece10 = new BuildPiece(_glassBundle, "BGP_GlassRoof45");
			buildPiece10.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece10.Category.Set("GlassPieces-Iron");
			buildPiece10.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece10.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece10.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece10.Prefab);
			BuildPiece buildPiece11 = new BuildPiece(_glassBundle, "BGP_GlassRoof_ICorner26");
			buildPiece11.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece11.Category.Set("GlassPieces-Iron");
			buildPiece11.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece11.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece11.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece11.Prefab);
			BuildPiece buildPiece12 = new BuildPiece(_glassBundle, "BGP_GlassRoof_ICorner45");
			buildPiece12.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece12.Category.Set("GlassPieces-Iron");
			buildPiece12.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece12.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece12.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece12.Prefab);
			BuildPiece buildPiece13 = new BuildPiece(_glassBundle, "BGP_GlassRoof_OCorner26");
			buildPiece13.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece13.Category.Set("GlassPieces-Iron");
			buildPiece13.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece13.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece13.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece13.Prefab);
			BuildPiece buildPiece14 = new BuildPiece(_glassBundle, "BGP_GlassRoof_OCorner45");
			buildPiece14.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece14.Category.Set("GlassPieces-Iron");
			buildPiece14.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece14.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece14.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece14.Prefab);
			BuildPiece buildPiece15 = new BuildPiece(_glassBundle, "BGP_GlassRoof_Top26");
			buildPiece15.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece15.Category.Set("GlassPieces-Iron");
			buildPiece15.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece15.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece15.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece15.Prefab);
			BuildPiece buildPiece16 = new BuildPiece(_glassBundle, "BGP_GlassRoof_Top45");
			buildPiece16.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece16.Category.Set("GlassPieces-Iron");
			buildPiece16.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece16.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece16.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece16.Prefab);
			BuildPiece buildPiece17 = new BuildPiece(_glassBundle, "BGP_GlassWall");
			buildPiece17.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece17.Category.Set("GlassPieces-Iron");
			buildPiece17.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece17.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece17.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece17.Prefab);
			BuildPiece buildPiece18 = new BuildPiece(_glassBundle, "BGP_GlassWall_Roof26");
			buildPiece18.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece18.Category.Set("GlassPieces-Iron");
			buildPiece18.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece18.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece18.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece18.Prefab);
			BuildPiece buildPiece19 = new BuildPiece(_glassBundle, "BGP_GlassWall_Roof45");
			buildPiece19.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece19.Category.Set("GlassPieces-Iron");
			buildPiece19.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece19.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece19.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece19.Prefab);
			BuildPiece buildPiece20 = new BuildPiece(_glassBundle, "BGP_GlassWindow");
			buildPiece20.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece20.Category.Set("GlassPieces-Iron");
			buildPiece20.RequiredItems.Add("Iron", 4, recover: true);
			buildPiece20.RequiredItems.Add("BGP_Glass", 4, recover: true);
			buildPiece20.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece20.Prefab);
			BuildPiece buildPiece21 = new BuildPiece(_glassBundle, "BGP_GlassWindow_Half");
			buildPiece21.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece21.Category.Set("GlassPieces-Iron");
			buildPiece21.RequiredItems.Add("Iron", 3, recover: true);
			buildPiece21.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece21.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece21.Prefab);
			BuildPiece buildPiece22 = new BuildPiece(_glassBundle, "BGP_GlassWindow_Quarter");
			buildPiece22.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece22.Category.Set("GlassPieces-Iron");
			buildPiece22.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece22.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece22.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece22.Prefab);
			BuildPiece buildPiece23 = new BuildPiece(_glassBundle, "BGP_HorizontalBeam");
			buildPiece23.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece23.Category.Set("GlassPieces-Iron");
			buildPiece23.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece23.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece23.Prefab);
			BuildPiece buildPiece24 = new BuildPiece(_glassBundle, "BGP_HorizontalBeam_Half");
			buildPiece24.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece24.Category.Set("GlassPieces-Iron");
			buildPiece24.RequiredItems.Add("Iron", 1, recover: true);
			buildPiece24.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece24.Prefab);
			BuildPiece buildPiece25 = new BuildPiece(_glassBundle, "BGP_IronStair");
			buildPiece25.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece25.Category.Set("GlassPieces-Iron");
			buildPiece25.RequiredItems.Add("Iron", 4, recover: true);
			buildPiece25.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece25.Prefab);
			BuildPiece buildPiece26 = new BuildPiece(_glassBundle, "BGP_SilicaCollector");
			buildPiece26.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece26.Category.Set(BuildPieceCategory.Crafting);
			buildPiece26.RequiredItems.Add("SurtlingCore", 5, recover: true);
			buildPiece26.RequiredItems.Add("Iron", 15, recover: true);
			buildPiece26.RequiredItems.Add("Crystal", 5, recover: true);
			buildPiece26.RequiredItems.Add("BGP_Glass", 5, recover: true);
			buildPiece26.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			if (!Object.op_Implicit((Object)(object)buildPiece26.Prefab.GetComponent<Collector>()))
			{
				buildPiece26.Prefab.AddComponent<Collector>();
			}
			BuildPiece buildPiece27 = new BuildPiece(_glassBundle, "BGP_SlidingGlassDoor");
			buildPiece27.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece27.Category.Set("GlassPieces-Iron");
			buildPiece27.RequiredItems.Add("Iron", 10, recover: true);
			buildPiece27.RequiredItems.Add("BGP_Glass", 6, recover: true);
			buildPiece27.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece27.Prefab);
			WindowSetup.SlidingGlassDoor(buildPiece27.Prefab);
			BuildPiece buildPiece28 = new BuildPiece(_glassBundle, "BGP_SlidingGlassWindow");
			buildPiece28.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece28.Category.Set("GlassPieces-Iron");
			buildPiece28.RequiredItems.Add("Iron", 6, recover: true);
			buildPiece28.RequiredItems.Add("BGP_Glass", 4, recover: true);
			buildPiece28.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece28.Prefab);
			WindowSetup.SlidingGlassWindow(buildPiece28.Prefab);
			BuildPiece buildPiece29 = new BuildPiece(_glassBundle, "BGP_SlidingGlassWindow_Half");
			buildPiece29.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece29.Category.Set("GlassPieces-Iron");
			buildPiece29.RequiredItems.Add("Iron", 4, recover: true);
			buildPiece29.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece29.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece29.Prefab);
			WindowSetup.SlidingGlassWindow(buildPiece29.Prefab);
			BuildPiece buildPiece30 = new BuildPiece(_glassBundle, "BGP_VerticalBeam");
			buildPiece30.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece30.Category.Set("GlassPieces-Iron");
			buildPiece30.RequiredItems.Add("Iron", 2, recover: true);
			buildPiece30.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece30.Prefab);
			BuildPiece buildPiece31 = new BuildPiece(_glassBundle, "BGP_VerticalBeam_Half");
			buildPiece31.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece31.Category.Set("GlassPieces-Iron");
			buildPiece31.RequiredItems.Add("Iron", 1, recover: true);
			buildPiece31.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece30.Prefab);
		}

		private static void Copper()
		{
			BuildPiece buildPiece = new BuildPiece(_glassBundle, "BGP_DiagonalBeam26_Copper");
			buildPiece.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece.Category.Set("GlassPieces-Copper");
			buildPiece.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece.Prefab);
			BuildPiece buildPiece2 = new BuildPiece(_glassBundle, "BGP_DiagonalBeam45_Copper");
			buildPiece2.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece2.Category.Set("GlassPieces-Copper");
			buildPiece2.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece2.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece2.Prefab);
			BuildPiece buildPiece3 = new BuildPiece(_glassBundle, "BGP_GlassDoor_Copper");
			buildPiece3.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece3.Category.Set("GlassPieces-Copper");
			buildPiece3.RequiredItems.Add("Copper", 3, recover: true);
			buildPiece3.RequiredItems.Add("BGP_Glass", 4, recover: true);
			buildPiece3.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece3.Prefab);
			BuildPiece buildPiece4 = new BuildPiece(_glassBundle, "BGP_GlassFloorRoof_Copper");
			buildPiece4.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece4.Category.Set("GlassPieces-Copper");
			buildPiece4.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece4.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece4.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece4.Prefab);
			BuildPiece buildPiece5 = new BuildPiece(_glassBundle, "BGP_GlassFloorRoof_Half_Copper");
			buildPiece5.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece5.Category.Set("GlassPieces-Copper");
			buildPiece5.RequiredItems.Add("Copper", 1, recover: true);
			buildPiece5.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece5.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece5.Prefab);
			BuildPiece buildPiece6 = new BuildPiece(_glassBundle, "BGP_GlassHalfWall_Copper");
			buildPiece6.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece6.Category.Set("GlassPieces-Copper");
			buildPiece6.RequiredItems.Add("Copper", 1, recover: true);
			buildPiece6.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece6.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece6.Prefab);
			BuildPiece buildPiece7 = new BuildPiece(_glassBundle, "BGP_GlassHalfWall_Vertical_Copper");
			buildPiece7.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece7.Category.Set("GlassPieces-Copper");
			buildPiece7.RequiredItems.Add("Copper", 1, recover: true);
			buildPiece7.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece7.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece7.Prefab);
			BuildPiece buildPiece8 = new BuildPiece(_glassBundle, "BGP_GlassQuarterWall_Copper");
			buildPiece8.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece8.Category.Set("GlassPieces-Copper");
			buildPiece8.RequiredItems.Add("Copper", 1, recover: true);
			buildPiece8.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece8.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece8.Prefab);
			BuildPiece buildPiece9 = new BuildPiece(_glassBundle, "BGP_GlassRoof26_Copper");
			buildPiece9.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece9.Category.Set("GlassPieces-Copper");
			buildPiece9.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece9.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece9.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece9.Prefab);
			BuildPiece buildPiece10 = new BuildPiece(_glassBundle, "BGP_GlassRoof45_Copper");
			buildPiece10.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece10.Category.Set("GlassPieces-Copper");
			buildPiece10.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece10.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece10.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece10.Prefab);
			BuildPiece buildPiece11 = new BuildPiece(_glassBundle, "BGP_GlassRoof_ICorner26_Copper");
			buildPiece11.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece11.Category.Set("GlassPieces-Copper");
			buildPiece11.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece11.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece11.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece11.Prefab);
			BuildPiece buildPiece12 = new BuildPiece(_glassBundle, "BGP_GlassRoof_ICorner45_Copper");
			buildPiece12.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece12.Category.Set("GlassPieces-Copper");
			buildPiece12.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece12.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece12.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece12.Prefab);
			BuildPiece buildPiece13 = new BuildPiece(_glassBundle, "BGP_GlassRoof_OCorner26_Copper");
			buildPiece13.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece13.Category.Set("GlassPieces-Copper");
			buildPiece13.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece13.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece13.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece13.Prefab);
			BuildPiece buildPiece14 = new BuildPiece(_glassBundle, "BGP_GlassRoof_OCorner45_Copper");
			buildPiece14.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece14.Category.Set("GlassPieces-Copper");
			buildPiece14.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece14.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece14.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece14.Prefab);
			BuildPiece buildPiece15 = new BuildPiece(_glassBundle, "BGP_GlassRoof_Top26_Copper");
			buildPiece15.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece15.Category.Set("GlassPieces-Copper");
			buildPiece15.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece15.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece15.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece15.Prefab);
			BuildPiece buildPiece16 = new BuildPiece(_glassBundle, "BGP_GlassRoof_Top45_Copper");
			buildPiece16.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece16.Category.Set("GlassPieces-Copper");
			buildPiece16.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece16.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece16.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece16.Prefab);
			BuildPiece buildPiece17 = new BuildPiece(_glassBundle, "BGP_GlassWall_Copper");
			buildPiece17.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece17.Category.Set("GlassPieces-Copper");
			buildPiece17.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece17.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece17.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece17.Prefab);
			BuildPiece buildPiece18 = new BuildPiece(_glassBundle, "BGP_GlassWall_Roof26_Copper");
			buildPiece18.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece18.Category.Set("GlassPieces-Copper");
			buildPiece18.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece18.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece18.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece18.Prefab);
			BuildPiece buildPiece19 = new BuildPiece(_glassBundle, "BGP_GlassWall_Roof45_Copper");
			buildPiece19.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece19.Category.Set("GlassPieces-Copper");
			buildPiece19.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece19.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece19.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece19.Prefab);
			BuildPiece buildPiece20 = new BuildPiece(_glassBundle, "BGP_GlassWindow_Copper");
			buildPiece20.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece20.Category.Set("GlassPieces-Copper");
			buildPiece20.RequiredItems.Add("Copper", 4, recover: true);
			buildPiece20.RequiredItems.Add("BGP_Glass", 4, recover: true);
			buildPiece20.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece20.Prefab);
			BuildPiece buildPiece21 = new BuildPiece(_glassBundle, "BGP_GlassWindow_Half_Copper");
			buildPiece21.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece21.Category.Set("GlassPieces-Copper");
			buildPiece21.RequiredItems.Add("Copper", 3, recover: true);
			buildPiece21.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece21.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece21.Prefab);
			BuildPiece buildPiece22 = new BuildPiece(_glassBundle, "BGP_GlassWindow_Quarter_Copper");
			buildPiece22.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece22.Category.Set("GlassPieces-Copper");
			buildPiece22.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece22.RequiredItems.Add("BGP_Glass", 1, recover: true);
			buildPiece22.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece22.Prefab);
			BuildPiece buildPiece23 = new BuildPiece(_glassBundle, "BGP_HorizontalBeam_Copper");
			buildPiece23.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece23.Category.Set("GlassPieces-Copper");
			buildPiece23.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece23.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece23.Prefab);
			BuildPiece buildPiece24 = new BuildPiece(_glassBundle, "BGP_HorizontalBeam_Half_Copper");
			buildPiece24.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece24.Category.Set("GlassPieces-Copper");
			buildPiece24.RequiredItems.Add("Copper", 1, recover: true);
			buildPiece24.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece24.Prefab);
			BuildPiece buildPiece25 = new BuildPiece(_glassBundle, "BGP_IronStair_Copper");
			buildPiece25.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece25.Category.Set("GlassPieces-Copper");
			buildPiece25.RequiredItems.Add("Copper", 4, recover: true);
			buildPiece25.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece25.Prefab);
			BuildPiece buildPiece26 = new BuildPiece(_glassBundle, "BGP_SlidingGlassDoor_Copper");
			buildPiece26.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece26.Category.Set("GlassPieces-Copper");
			buildPiece26.RequiredItems.Add("Copper", 10, recover: true);
			buildPiece26.RequiredItems.Add("BGP_Glass", 6, recover: true);
			buildPiece26.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece26.Prefab);
			WindowSetup.SlidingGlassDoor(buildPiece26.Prefab);
			BuildPiece buildPiece27 = new BuildPiece(_glassBundle, "BGP_SlidingGlassWindow_Copper");
			buildPiece27.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece27.Category.Set("GlassPieces-Copper");
			buildPiece27.RequiredItems.Add("Copper", 6, recover: true);
			buildPiece27.RequiredItems.Add("BGP_Glass", 4, recover: true);
			buildPiece27.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece27.Prefab);
			WindowSetup.SlidingGlassWindow(buildPiece27.Prefab);
			BuildPiece buildPiece28 = new BuildPiece(_glassBundle, "BGP_SlidingGlassWindow_Half_Copper");
			buildPiece28.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece28.Category.Set("GlassPieces-Copper");
			buildPiece28.RequiredItems.Add("Copper", 4, recover: true);
			buildPiece28.RequiredItems.Add("BGP_Glass", 2, recover: true);
			buildPiece28.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece28.Prefab);
			WindowSetup.SlidingGlassWindow(buildPiece28.Prefab);
			BuildPiece buildPiece29 = new BuildPiece(_glassBundle, "BGP_VerticalBeam_Copper");
			buildPiece29.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece29.Category.Set("GlassPieces-Copper");
			buildPiece29.RequiredItems.Add("Copper", 2, recover: true);
			buildPiece29.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece29.Prefab);
			BuildPiece buildPiece30 = new BuildPiece(_glassBundle, "BGP_VerticalBeam_Half_Copper");
			buildPiece30.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece30.Category.Set("GlassPieces-Copper");
			buildPiece30.RequiredItems.Add("Copper", 1, recover: true);
			buildPiece30.SpecialProperties = new SpecialProperties
			{
				AdminOnly = false,
				NoConfig = false
			};
			ShaderReplacer.Replace(buildPiece30.Prefab);
		}

		private static void Others()
		{
			_pickable = PiecePrefabManager.RegisterPrefab(_glassBundle, "BGP_Pickable_SilicaOre");
			_silicaVein = PiecePrefabManager.RegisterPrefab(_glassBundle, "BGP_SilicaVein");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_sfx_build_hammer_metal");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_sfx_door_close");
			_sfxOpen = PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_sfx_door_open");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_sfx_metal_blocked");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_sfx_pickable_pick");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_sfx_rock_destroyed");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_sfx_rock_hit");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_vfx_HitSparks");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_vfx_pickable_pick");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_vfx_Place_piece");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_vfx_RockDestroyed");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_vfx_RockHit");
			PiecePrefabManager.RegisterPrefab(_glassBundle, "bgp_vfx_SawDust");
		}
	}
	public static class ShaderReplacer
	{
		private static readonly List<GameObject> GOToSwap;

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

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

		[HarmonyPriority(700)]
		private static void ReplaceShaderPatch()
		{
			foreach (Material item in Enumerable.Select(Enumerable.Where(Enumerable.SelectMany(Enumerable.Where(Enumerable.SelectMany(Enumerable.Select(GOToSwap, (GameObject gameObject) => gameObject.GetComponentsInChildren<Renderer>(true)), (Renderer[] renderers) => renderers, (Renderer[] renderers, Renderer renderer) => new { renderers, renderer }), <>h__TransparentIdentifier0 => (Object)(object)<>h__TransparentIdentifier0.renderer != (Object)null), <>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.renderer.sharedMaterials, (<>h__TransparentIdentifier0, Material material) => new { <>h__TransparentIdentifier0, material }), <>h__TransparentIdentifier1 => (Object)(object)<>h__TransparentIdentifier1.material != (Object)null), <>h__TransparentIdentifier1 => <>h__TransparentIdentifier1.material))
			{
				Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
				foreach (Shader val in array)
				{
					if (((Object)item.shader).name == ((Object)val).name)
					{
						item.shader = val;
					}
				}
			}
		}
	}
	public class Slider : MonoBehaviour
	{
		public bool m_canMove = true;

		public float m_speed;

		public int m_startPoint;

		public Transform[] m_points;

		public EffectList m_slideEffect;

		private int i;

		private bool m_reverse;

		private void Start()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			((Component)this).transform.position = m_points[m_startPoint].position;
			i = m_startPoint;
			m_slideEffect.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
			{
				new EffectData
				{
					m_prefab = SetupPrefabs._sfxOpen,
					m_enabled = true,
					m_variant = -1
				}
			};
		}

		private void Update()
		{
			//IL_0006: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (Vector3.Distance(((Component)this).transform.position, m_points[i].position) < 0.01f)
			{
				m_canMove = false;
				if (i == m_points.Length - 1)
				{
					m_reverse = true;
					i--;
					return;
				}
				if (i == 0)
				{
					m_reverse = false;
					i++;
					return;
				}
				if (m_reverse)
				{
					i--;
				}
				else
				{
					i++;
				}
			}
			if (m_canMove)
			{
				((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, m_points[i].position, m_speed * Time.deltaTime);
			}
		}
	}
	public class SliderSwitch : MonoBehaviour, Hoverable, Interactable
	{
		public Slider slider;

		public string m_name;

		private void Start()
		{
			m_name = ((Component)this).GetComponentInParent<Piece>().m_name;
			slider = ((Component)this).gameObject.GetComponent<Slider>();
		}

		public string GetHoverText()
		{
			return Localization.instance.Localize(m_name + "\n[<color=yellow><b>$KEY_Use</b></color>]$bgp_activate");
		}

		public string GetHoverName()
		{
			return m_name;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (hold)
			{
				return false;
			}
			if (slider.m_canMove)
			{
				return true;
			}
			slider.m_speed = 3f;
			slider.m_canMove = true;
			slider.m_slideEffect.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1);
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}
	}
	public class TriggerSwitch : MonoBehaviour
	{
		private Slider _slider;

		private void Start()
		{
			Piece componentInParent = ((Component)this).GetComponentInParent<Piece>();
			_slider = ((Component)componentInParent).gameObject.GetComponentInChildren<Slider>();
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_003b: 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)
			if (Plugin._automaticDoor.Value == Plugin.Toggle.On)
			{
				_slider.m_speed = 3f;
				_slider.m_canMove = true;
				_slider.m_slideEffect.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1);
			}
		}

		private void OnTriggerExit(Collider other)
		{
			//IL_003b: 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)
			if (Plugin._automaticDoor.Value == Plugin.Toggle.On)
			{
				_slider.m_speed = 3f;
				_slider.m_canMove = true;
				_slider.m_slideEffect.Create(((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform, 1f, -1);
			}
		}
	}
	public static class WindowSetup
	{
		private static ZNetScene _zNetScene => ZNetScene.instance;

		public static void SlidingGlassWindow(GameObject gameObject)
		{
			Transform val = Utils.FindChild(gameObject.transform, "window_panel", (IterativeSearchType)0);
			if (!Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<Slider>()))
			{
				Slider slider = ((Component)val).gameObject.AddComponent<Slider>();
				slider.m_canMove = false;
				slider.m_speed = 3f;
				slider.m_startPoint = 0;
				slider.m_points = (Transform[])(object)new Transform[2]
				{
					Utils.FindChild(gameObject.transform, "point_a", (IterativeSearchType)0),
					Utils.FindChild(gameObject.transform, "point_b", (IterativeSearchType)0)
				};
				((Component)val).gameObject.AddComponent<SliderSwitch>();
				Transform val2 = Utils.FindChild(gameObject.transform, "window_panel2", (IterativeSearchType)0);
				if (!Object.op_Implicit((Object)(object)((Component)val2).gameObject.GetComponent<Slider>()))
				{
					Slider slider2 = ((Component)val2).gameObject.AddComponent<Slider>();
					slider2.m_canMove = false;
					slider2.m_speed = 3f;
					slider2.m_startPoint = 0;
					slider2.m_points = (Transform[])(object)new Transform[2]
					{
						Utils.FindChild(gameObject.transform, "point_c", (IterativeSearchType)0),
						Utils.FindChild(gameObject.transform, "point_d", (IterativeSearchType)0)
					};
					((Component)val2).gameObject.AddComponent<SliderSwitch>();
				}
			}
		}

		public static void SlidingGlassDoor(GameObject gameObject)
		{
			Transform val = Utils.FindChild(gameObject.transform, "door_panel", (IterativeSearchType)0);
			if (!Object.op_Implicit((Object)(object)((Component)val).gameObject.GetComponent<Slider>()))
			{
				Slider slider = ((Component)val).gameObject.AddComponent<Slider>();
				slider.m_canMove = false;
				slider.m_speed = 3f;
				slider.m_startPoint = 0;
				slider.m_points = (Transform[])(object)new Transform[2]
				{
					Utils.FindChild(gameObject.transform, "point_a", (IterativeSearchType)0),
					Utils.FindChild(gameObject.transform, "point_b", (IterativeSearchType)0)
				};
				((Component)val).gameObject.AddComponent<SliderSwitch>();
				((Component)Utils.FindChild(gameObject.transform, "sliderSwitch", (IterativeSearchType)0)).gameObject.AddComponent<TriggerSwitch>();
			}
		}
	}
}
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)
		{
			Drops.Add(new DropTarget
			{
				creature = creatureName,
				chance = chance,
				min = min,
				max = max.GetValueOrDefault(min),
				levelMultiplier = levelMultiplier
			});
		}
	}
	internal struct DropTarget
	{
		public string creature;

		public int min;

		public int max;

		public float chance;

		public bool levelMultiplier;
	}
	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;

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

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

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

			public static Requirement[] toPieceReqs(ObjectDB objectDB, SerializedRequirements craft, SerializedRequirements upgrade)
			{
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0185: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Expected O, but got Unknown
				//IL_0194: Expected O, but got Unknown
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Expected O, but got Unknown
				ObjectDB objectDB2 = objectDB;
				Dictionary<string, Requirement> dictionary = Enumerable.ToDictionary(Enumerable.Where(craft.Reqs, (Requirement r) => r.itemName != ""), (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 = Enumerable.ToList(Enumerable.Where(dictionary.Values, (Requirement v) => v != null));
				foreach (Requirement item in Enumerable.Where(upgrade.Reqs, (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(objectDB2, r.itemName);
				}
			}
		}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		public static Configurability DefaultConfigurability = Configurability.Full;

		public Configurability? Configurable;

		private Configurability configurationVisible = Configurability.Full;

		private TraderConfig? traderConfig;

		public readonly GameObject Prefab;

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

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

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

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

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

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

		private static object? configManager;

		private static Localization? _english;

		private static BaseUnityPlugin? _plugin;

		private static bool hasConfigSync = true;

		private static object? _configSync;

		private Configurability configurability => Configurable ?? DefaultConfigurability;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

		public void ToggleConfigurationVisibility(Configurability visible)
		{
			configurationVisible = visible;
			if (itemDropConfigs.TryGetValue(this, out 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) != 0)
				{
					statsConfig.Value();
				}
			}
			reloadConfigDisplay();
			void Toggle(ConfigEntryBase cfg, Configurability check)
			{
				object[] tags = cfg.Description.Tags;
				for (int j = 0; j < tags.Length; j++)
				{
					if (tags[j] is ConfigurationManagerAttributes configurationManagerAttributes)
					{
						configurationManagerAttributes.Browsable = (visible & check) != 0 && (configurationManagerAttributes.browsability == null || configurationManagerAttributes.browsability());
					}
				}
			}
			void ToggleObj(object obj, Configurability check)
			{
				FieldInfo[] fields = obj.GetType().GetFields();
				for (int i = 0; i < fields.Length; i++)
				{
					object? value3 = fields[i].GetValue(obj);
					ConfigEntryBase val = (ConfigEntryBase)((value3 is ConfigEntryBase) ? value3 : null);
					if (val != null)
					{
						Toggle(val, check);
					}
				}
			}
		}

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

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

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

		internal static void Patch_FejdStartup()
		{
			//IL_0f3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f42: Unknown result type (might be due to invalid IL or missing references)
			//IL_2208: Unknown result type (might be due to invalid IL or missing references)
			//IL_2212: Expected O, but got Unknown
			//IL_1006: Unknown result type (might be due to invalid IL or missing references)
			//IL_1009: Unknown result type (might be due to invalid IL or missing references)
			//IL_105f: Expected I4, but got Unknown
			//IL_0c2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c36: Expected O, but got Unknown
			//IL_1193: Unknown result type (might be due to invalid IL or missing references)
			//IL_1196: Unknown result type (might be due to invalid IL or missing references)
			//IL_1198: Invalid comparison between Unknown and I4
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Expected O, but got Unknown
			//IL_119a: Unknown result type (might be due to invalid IL or missing references)
			//IL_119e: Invalid comparison between Unknown and I4
			//IL_0d4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d59: Expected O, but got Unknown
			//IL_0dfa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e04: Expected O, but got Unknown
			//IL_11a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_11a4: Invalid comparison between Unknown and I4
			//IL_0eae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb8: Expected O, but got Unknown
			//IL_139f: Unknown result type (might be due to invalid IL or missing references)
			//IL_13a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_13a4: Invalid comparison between Unknown and I4
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Expected O, but got Unknown
			//IL_13a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_13aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ac: Invalid comparison between Unknown and I4
			//IL_13ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_13b2: Invalid comparison between Unknown and I4
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Expected O, but got Unknown
			//IL_1487: Unknown result type (might be due to invalid IL or missing references)
			//IL_148c: Unknown result type (might be due to invalid IL or missing references)
			//IL_148e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1491: Invalid comparison between Unknown and I4
			//IL_1493: Unknown result type (might be due to invalid IL or missing references)
			//IL_1497: Invalid comparison between Unknown and I4
			//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bf: Expected O, but got Unknown
			//IL_1506: Unknown result type (might be due to invalid IL or missing references)
			//IL_1509: Unknown result type (might be due to invalid IL or missing references)
			//IL_150b: Invalid comparison between Unknown and I4
			//IL_150d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1511: Unknown result type (might be due to invalid IL or missing references)
			//IL_1513: Invalid comparison between Unknown and I4
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_079e: Expected O, but got Unknown
			//IL_1515: Unknown result type (might be due to invalid IL or missing references)
			//IL_1519: Invalid comparison between Unknown and I4
			//IL_1656: Unknown result type (might be due to invalid IL or missing references)
			//IL_1659: Invalid comparison between Unknown and I4
			//IL_089e: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a8: Expected O, but got Unknown
			//IL_1856: Unknown result type (might be due to invalid IL or missing references)
			//IL_185d: Invalid comparison between Unknown and I4
			//IL_1926: Unknown result type (might be due to invalid IL or missing references)
			//IL_192b: Unknown result type (might be due to invalid IL or missing references)
			//IL_192d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1931: Unknown result type (might be due to invalid IL or missing references)
			//IL_1933: Invalid comparison between Unknown and I4
			//IL_19a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_19a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_19a7: Invalid comparison between Unknown and I4
			//IL_15cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_15d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_19a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_19ad: Invalid comparison between Unknown and I4
			//IL_19af: Unknown result type (might be due to invalid IL or missing references)
			//IL_19b3: Invalid comparison between Unknown and I4
			//IL_1e20: Unknown result type (might be due to invalid IL or missing references)
			//IL_1e23: Invalid comparison between Unknown and I4
			Type type = Enumerable.FirstOrDefault(AppDomain.CurrentDomain.GetAssemblies(), (Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			if (DefaultConfigurability != 0)
			{
				bool saveOnConfigSet = plugin.Config.SaveOnConfigSet;
				plugin.Config.SaveOnConfigSet = false;
				foreach (Item item4 in Enumerable.Where(registeredItems, (Item i) => i.configurability != Configurability.Disabled))
				{
					Item item3 = item4;
					string name2 = item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
					string englishName = new Regex("['\\[\"\\]]").Replace(english.Localize(name2), "").Trim();
					string localizedName = Localization.instance.Localize(name2).Trim();
					int order = 0;
					if ((item3.configurability & Configurability.Recipe) != 0)
					{
						itemCraftConfigs[item3] = new Dictionary<string, ItemConfig>();
						foreach (string item5 in Enumerable.DefaultIfEmpty(item3.Recipes.Keys, ""))
						{
							string configKey = item5;
							string text = ((configKey == "") ? "" : (" (" + configKey + ")"));
							if (configKey == "")
							{
								Configurability? configurable = item3.Configurable;
								if (configurable.HasValue && item3.Crafting.Stations.Count == 0)
								{
									item3.Crafting.Add(CraftingTable.Disabled, 1);
								}
							}
							if (!item3.Recipes.ContainsKey(configKey) || item3.Recipes[configKey].Crafting.Stations.Count <= 0)
							{
								continue;
							}
							ItemConfig itemConfig2 = (itemCraftConfigs[item3][configKey] = new ItemConfig());
							ItemConfig cfg = itemConfig2;
							List<ConfigurationManagerAttributes> hideWhenNoneAttributes = new List<ConfigurationManagerAttributes>();
							cfg.table = config(englishName, "Crafting Station" + text, Enumerable.First(item3.Recipes[configKey].Crafting.Stations).Table, new ConfigDescription("Crafting station where " + englishName + " is available.", (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									Browsable = ((item3.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes customTableAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = CustomTableBrowsability,
								Browsable = (CustomTableBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.customTable = config(englishName, "Custom Crafting Station" + text, Enumerable.First(item3.Recipes[configKey].Crafting.Stations).custom ?? "", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { customTableAttributes }));
							cfg.table.SettingChanged += TableConfigChanged;
							cfg.customTable.SettingChanged += TableConfigChanged;
							ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = TableLevelBrowsability,
								Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							hideWhenNoneAttributes.Add(configurationManagerAttributes);
							cfg.tableLevel = config(englishName, "Crafting Station Level" + text, Enumerable.First(item3.Recipes[configKey].Crafting.Stations).level, new ConfigDescription("Required crafting station level to craft " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							cfg.tableLevel.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out List<Recipe> value6))
								{
									Enumerable.First(value6).m_minStationLevel = cfg.tableLevel.Value;
								}
							};
							if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1)
							{
								cfg.maximumTableLevel = config(englishName, "Maximum Crafting Station Level" + text, (item3.MaximumRequiredStationLevel == int.MaxValue) ? (Enumerable.First(item3.Recipes[configKey].Crafting.Stations).level + item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality - 1) : item3.MaximumRequiredStationLevel, new ConfigDescription("Maximum crafting station level to upgrade and repair " + englishName + ".", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }));
							}
							cfg.requireOneIngredient = config(englishName, "Require only one resource" + text, item3.Recipes[configKey].RequireOnlyOneIngredient ? Toggle.On : Toggle.Off, new ConfigDescription("Whether only one of the ingredients is needed to craft " + englishName, (AcceptableValueBase)null, new object[1]
							{
								new ConfigurationManagerAttributes
								{
									Order = (order -= 1),
									browsability = TableLevelBrowsability,
									Browsable = (TableLevelBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
									Category = localizedName
								}
							}));
							ConfigurationManagerAttributes qualityResultAttributes = new ConfigurationManagerAttributes
							{
								Order = (order -= 1),
								browsability = QualityResultBrowsability,
								Browsable = (QualityResultBrowsability() && (item3.configurationVisible & Configurability.Recipe) != 0),
								Category = localizedName
							};
							cfg.requireOneIngredient.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out List<Recipe> value5))
								{
									foreach (Recipe item6 in value5)
									{
										item6.m_requireOnlyOneIngredient = cfg.requireOneIngredient.Value == Toggle.On;
									}
								}
								qualityResultAttributes.Browsable = QualityResultBrowsability();
								reloadConfigDisplay();
							};
							cfg.qualityResultAmountMultiplier = config(englishName, "Quality Multiplier" + text, item3.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 }));
							cfg.qualityResultAmountMultiplier.SettingChanged += delegate
							{
								if (activeRecipes.ContainsKey(item3) && activeRecipes[item3].TryGetValue(configKey, out List<Recipe> value4))
								{
									foreach (Recipe item7 in value4)
									{
										item7.m_qualityResultAmountMultiplier = cfg.qualityResultAmountMultiplier.Value;
									}
								}
							};
							if ((!item3.Recipes[configKey].RequiredItems.Free || item3.Recipes[configKey].RequiredItems.Requirements.Count > 0) && Enumerable.All(item3.Recipes[configKey].RequiredItems.Requirements, (Requirement r) => r.amountConfig == null))
							{
								cfg.craft = itemConfig("Crafting Costs" + text, new SerializedRequirements(item3.Recipes[configKey].RequiredItems.Requirements).ToString(), "Item costs to craft " + englishName, isUpgrade: false);
							}
							if (item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_maxQuality > 1 && (!item3.Recipes[configKey].RequiredUpgradeItems.Free || item3.Recipes[configKey].RequiredUpgradeItems.Requirements.Count > 0) && Enumerable.All(item3.Recipes[configKey].RequiredUpgradeItems.Requirements, (Requirement r) => r.amountConfig == null))
							{
								cfg.upgrade = itemConfig("Upgrading Costs" + text, new SerializedRequirements(item3.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;