Decompiled source of ChebsNecromancy v5.0.2

plugins/ChebsValheimLibrary.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using ChebsValheimLibrary.Common;
using ChebsValheimLibrary.Items;
using ChebsValheimLibrary.Items.Armor.BlackMetal;
using ChebsValheimLibrary.Items.Armor.Bronze;
using ChebsValheimLibrary.Items.Armor.Iron;
using ChebsValheimLibrary.Items.Armor.Leather;
using ChebsValheimLibrary.Items.Armor.Leather.Lox;
using ChebsValheimLibrary.Items.Armor.Leather.Troll;
using ChebsValheimLibrary.Items.Armor.Leather.Wolf;
using ChebsValheimLibrary.Items.Armor.Mage;
using ChebsValheimLibrary.Items.Tools;
using ChebsValheimLibrary.Items.Weapons.BlackMetal;
using ChebsValheimLibrary.Items.Weapons.Bows;
using ChebsValheimLibrary.Items.Weapons.Bronze;
using ChebsValheimLibrary.Items.Weapons.Iron;
using ChebsValheimLibrary.Items.Weapons.Mage;
using ChebsValheimLibrary.Items.Weapons.Needle;
using ChebsValheimLibrary.Items.Weapons.Poison;
using ChebsValheimLibrary.Items.Weapons.Wood;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using SimpleJson;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Joshua Paul Woods")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Public Domain")]
[assembly: AssemblyDescription("A library which contains shared classes and things required by all my mods.")]
[assembly: AssemblyFileVersion("2.6.2.0")]
[assembly: AssemblyInformationalVersion("2.6.2.0+a24042c85ef3531a466a89c2e7aac3dcf5ac22ae")]
[assembly: AssemblyProduct("ChebsValheimLibrary")]
[assembly: AssemblyTitle("Cheb's Valheim Library")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/jpw1991/chebs-valheim-library")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.6.2.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ChebsValheimLibrary
{
	public class Base
	{
		public static readonly Version CurrentVersion = new Version("2.6.2");

		public static bool VersionCheck(Version version, out string message)
		{
			if (version.Major != CurrentVersion.Major)
			{
				message = "Major version difference detected! Please check your ChebsValheimLibrary.dll version! " + $"Mod expected {version}, but library version is {CurrentVersion}";
				return false;
			}
			if (version.Minor != CurrentVersion.Minor)
			{
				message = "Minor version difference detected! Please check your ChebsValheimLibrary.dll version! " + $"Mod expected {version}, but library version is {CurrentVersion}";
				return false;
			}
			if (version.Build < CurrentVersion.Build)
			{
				message = "Patch version difference detected. The mod expects an older ChebsValheimLibrary.dll version. This probably won't cause problems." + $"Mod expected {version}, but library version is {CurrentVersion}";
				return false;
			}
			message = "";
			return true;
		}

		public static GameObject LoadPrefabFromBundle(string prefabName, AssetBundle bundle, bool radeonFriendly)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			GameObject val = bundle.LoadAsset<GameObject>(prefabName);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogFatal((object)("LoadPrefabFromBundle: " + prefabName + " is null!"));
			}
			if (radeonFriendly)
			{
				ParticleSystem[] componentsInChildren = val.GetComponentsInChildren<ParticleSystem>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.Destroy((Object)(object)componentsInChildren[i]);
				}
				Humanoid val2 = default(Humanoid);
				if (val.TryGetComponent<Humanoid>(ref val2))
				{
					((Character)val2).m_deathEffects = new EffectList();
					val2.m_dropEffects = new EffectList();
					val2.m_equipEffects = new EffectList();
					val2.m_pickupEffects = new EffectList();
					val2.m_consumeItemEffects = new EffectList();
					((Character)val2).m_hitEffects = new EffectList();
					((Character)val2).m_jumpEffects = new EffectList();
					((Character)val2).m_slideEffects = new EffectList();
					val2.m_perfectBlockEffect = new EffectList();
					((Character)val2).m_tarEffects = new EffectList();
					((Character)val2).m_waterEffects = new EffectList();
					((Character)val2).m_flyingContinuousEffect = new EffectList();
				}
			}
			return val;
		}

		public static void LoadMinionItems(AssetBundle bundle, bool radeonFriendly)
		{
			List<Item> list = new List<Item>();
			list.Add(new SkeletonClub());
			list.Add(new SkeletonBow());
			list.Add(new SkeletonBow2());
			list.Add(new SkeletonBow3());
			list.Add(new SkeletonHelmetLeather());
			list.Add(new SkeletonHelmetBronze());
			list.Add(new SkeletonHelmetIron());
			list.Add(new SkeletonFireballLevel1());
			list.Add(new SkeletonFireballLevel2());
			list.Add(new SkeletonFireballLevel3());
			list.Add(new SkeletonMageCirclet());
			list.Add(new SkeletonAxe());
			list.Add(new BlackIronChest());
			list.Add(new BlackIronHelmet());
			list.Add(new BlackIronLegs());
			list.Add(new SkeletonHelmetBlackIron());
			list.Add(new SkeletonMace());
			list.Add(new SkeletonMace2());
			list.Add(new SkeletonMace3());
			list.Add(new SkeletonHelmetIronPoison());
			list.Add(new SkeletonHelmetBlackIronPoison());
			list.Add(new SkeletonHelmetLeatherPoison());
			list.Add(new SkeletonHelmetBronzePoison());
			list.Add(new SkeletonWoodAxe());
			list.Add(new SkeletonPickaxe());
			list.Add(new SkeletonAxeBlackMetal());
			list.Add(new SkeletonAxeBronze());
			list.Add(new SkeletonMaceBlackMetal());
			list.Add(new SkeletonMaceBronze());
			list.Add(new SkeletonMaceIron());
			list.Add(new SkeletonSwordBlackMetal());
			list.Add(new SkeletonSwordBronze());
			list.Add(new SkeletonSwordIron());
			list.Add(new SkeletonBowFire());
			list.Add(new SkeletonBowPoison());
			list.Add(new SkeletonBowFrost());
			list.Add(new SkeletonBowSilver());
			list.Add(new SkeletonMaceNeedle());
			list.Add(new HelmetLeatherTroll());
			list.Add(new HelmetLeatherWolf());
			list.Add(new HelmetLeatherLox());
			list.Add(new SkeletonHelmetLeatherTroll());
			list.Add(new SkeletonHelmetLeatherPoisonTroll());
			list.Add(new SkeletonArmorLeatherChestTroll());
			list.Add(new SkeletonArmorLeatherLegsTroll());
			list.Add(new SkeletonHelmetLeatherWolf());
			list.Add(new SkeletonHelmetLeatherPoisonWolf());
			list.Add(new SkeletonArmorLeatherChestWolf());
			list.Add(new SkeletonArmorLeatherLegsWolf());
			list.Add(new SkeletonHelmetLeatherLox());
			list.Add(new SkeletonHelmetLeatherPoisonLox());
			list.Add(new SkeletonArmorLeatherChestLox());
			list.Add(new SkeletonArmorLeatherLegsLox());
			list.ForEach(delegate(Item minionItem)
			{
				if (ItemManager.Instance.GetItem(minionItem.ItemName) == null)
				{
					GameObject prefab = LoadPrefabFromBundle(minionItem.PrefabName, bundle, radeonFriendly);
					ItemManager.Instance.AddItem(minionItem.GetCustomItemFromPrefab(prefab));
				}
			});
		}
	}
}
namespace ChebsValheimLibrary.Structures
{
	public class Structure : MonoBehaviour
	{
		public const float PlayerDetectionDistance = 150f;

		public static ChebsRecipe ChebsRecipeConfig;

		public static void UpdateRecipe()
		{
		}

		protected bool EnemiesNearby(out Character characterInRange, float radius)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			List<Character> list = new List<Character>();
			Character.GetCharactersInRange(((Component)this).transform.position, radius, list);
			using (IEnumerator<Character> enumerator = list.Where((Character character) => (Object)(object)character != (Object)null && (int)character.m_faction != 0 && !character.m_tamed).GetEnumerator())
			{
				if (enumerator.MoveNext())
				{
					Character current = enumerator.Current;
					characterInRange = current;
					return true;
				}
			}
			characterInRange = null;
			return false;
		}
	}
}
namespace ChebsValheimLibrary.PvP
{
	public class PvPManager
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static CoroutineHandler <0>__PvP_RPCServerReceive;

			public static CoroutineHandler <1>__PvP_RPCClientReceive;
		}

		public static bool HeavyLogging;

		private static CustomRPC _pvPrpc;

		private const string GetDictString = "CG_PvP_1";

		private const string UpdateDictString = "CG_PvP_2";

		private const string PvPrpcName = "PvPrpc";

		private static Dictionary<string, List<string>> _playerFriends;

		private static string AllyFileName => ZNet.instance.GetWorldName() + ".ChebsValheimLibrary.PvP.json";

		private static Dictionary<string, List<string>> PlayerFriends
		{
			get
			{
				if ((ZNetExtension.IsServerInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance)) && _playerFriends == null)
				{
					_playerFriends = new Dictionary<string, List<string>>();
					_playerFriends = ReadAllyFile();
				}
				return _playerFriends;
			}
			set
			{
				_playerFriends = value;
			}
		}

		public static void InitialFriendsListRequest()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			if (ZNetExtension.IsClientInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance))
			{
				ZPackage val = new ZPackage(Encoding.UTF8.GetBytes("CG_PvP_1 " + Player.m_localPlayer.GetPlayerID()));
				_pvPrpc.SendPackage(ZRoutedRpc.instance.GetServerPeerID(), val);
			}
		}

		public static List<string> GetPlayerFriends()
		{
			if (PlayerFriends == null || !PlayerFriends.TryGetValue(Player.m_localPlayer.GetPlayerName(), out var value))
			{
				return new List<string>();
			}
			return value;
		}

		public static bool Friendly(string minionMasterA, string minionMasterB)
		{
			if (PlayerFriends != null && PlayerFriends.TryGetValue(minionMasterA, out var value))
			{
				return value.Contains(minionMasterB);
			}
			return false;
		}

		public static void ConfigureRPC()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0035: 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_0040: Expected O, but got Unknown
			NetworkManager instance = NetworkManager.Instance;
			object obj = <>O.<0>__PvP_RPCServerReceive;
			if (obj == null)
			{
				CoroutineHandler val = PvP_RPCServerReceive;
				<>O.<0>__PvP_RPCServerReceive = val;
				obj = (object)val;
			}
			object obj2 = <>O.<1>__PvP_RPCClientReceive;
			if (obj2 == null)
			{
				CoroutineHandler val2 = PvP_RPCClientReceive;
				<>O.<1>__PvP_RPCClientReceive = val2;
				obj2 = (object)val2;
			}
			_pvPrpc = instance.AddRPC("PvPrpc", (CoroutineHandler)obj, (CoroutineHandler)obj2);
		}

		private static void UpdateAllyFile(string content)
		{
			string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AllyFileName);
			if (!File.Exists(text))
			{
				try
				{
					using FileStream fileStream = File.Create(text);
					fileStream.Close();
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Error creating " + text + ": " + ex.Message));
				}
			}
			try
			{
				using StreamWriter streamWriter = new StreamWriter(text, append: false);
				streamWriter.Write(content);
				streamWriter.Close();
			}
			catch (Exception ex2)
			{
				Logger.LogError((object)("Error writing to " + text + ": " + ex2.Message));
			}
		}

		private static Dictionary<string, List<string>> ReadAllyFile()
		{
			string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), AllyFileName);
			if (!File.Exists(text))
			{
				try
				{
					using FileStream fileStream = File.Create(text);
					fileStream.Close();
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Error creating " + text + ": " + ex.Message));
				}
			}
			string text2 = null;
			try
			{
				using StreamReader streamReader = new StreamReader(text);
				text2 = streamReader.ReadToEnd();
				streamReader.Close();
			}
			catch (Exception ex2)
			{
				Logger.LogError((object)("Error reading from " + text + ": " + ex2.Message));
			}
			if (text2 == null)
			{
				Logger.LogError((object)("Error reading " + text + ": content is null!"));
				return new Dictionary<string, List<string>>();
			}
			if (!(text2 == ""))
			{
				return SimpleJson.DeserializeObject<Dictionary<string, List<string>>>(text2);
			}
			return new Dictionary<string, List<string>>();
		}

		public static void UpdatePlayerFriendsDict(List<string> list, Player player = null)
		{
			UpdatePlayerFriendsDict(string.Join(",", list.Select((string s) => s.Trim())), player);
		}

		private static void UpdatePlayerFriendsDict(string list, Player player = null)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if ((Object)(object)player == (Object)null)
			{
				player = Player.m_localPlayer;
			}
			if ((Object)(object)player == (Object)null)
			{
				Logger.LogWarning((object)"UpdatePlayerFriendsDict m_localPlayer is null");
				return;
			}
			string s = "CG_PvP_2;" + player.GetPlayerName() + ";" + list;
			ZPackage val = new ZPackage(Encoding.UTF8.GetBytes(s));
			_pvPrpc.SendPackage(ZRoutedRpc.instance.GetServerPeerID(), val);
		}

		private static IEnumerator PvP_RPCServerReceive(long sender, ZPackage package)
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				yield return null;
			}
			if (ZNetExtension.IsServerInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance))
			{
				byte[] array = package.GetArray();
				string @string = Encoding.UTF8.GetString(array);
				if (@string.StartsWith("CG_PvP_1"))
				{
					if (HeavyLogging)
					{
						Logger.LogInfo((object)"PvP_RPCServerReceive CG_PvP_1");
					}
					string text = SimpleJson.SerializeObject((object)((IEnumerable<KeyValuePair<string, List<string>>>)PlayerFriends).ToDictionary((Func<KeyValuePair<string, List<string>>, string>)((KeyValuePair<string, List<string>> kvp) => kvp.Key), (Func<KeyValuePair<string, List<string>>, object>)((KeyValuePair<string, List<string>> kvp) => kvp.Value)));
					_pvPrpc.SendPackage(sender, new ZPackage(Encoding.UTF8.GetBytes("CG_PvP_1;" + text)));
				}
				else if (@string.StartsWith("CG_PvP_2"))
				{
					if (HeavyLogging)
					{
						Logger.LogInfo((object)"PvP_RPCServerReceive CG_PvP_2");
					}
					string[] array2 = @string.Split(new char[1] { ';' });
					if (array2.Length != 3)
					{
						Logger.LogError((object)$"Failed to parse payload ({array2.Length})");
					}
					string key = array2[1];
					string[] source = array2[2].Split(new char[1] { ',' });
					PlayerFriends[key] = source.ToList();
					string text2 = SimpleJson.SerializeObject((object)((IEnumerable<KeyValuePair<string, List<string>>>)PlayerFriends).ToDictionary((Func<KeyValuePair<string, List<string>>, string>)((KeyValuePair<string, List<string>> kvp) => kvp.Key), (Func<KeyValuePair<string, List<string>>, object>)((KeyValuePair<string, List<string>> kvp) => kvp.Value)));
					string text3 = "CG_PvP_1;" + text2;
					if (HeavyLogging)
					{
						Logger.LogMessage((object)("PvP_RPCServerReceive CG_PvP_2 sending to all peers: " + text3));
					}
					_pvPrpc.SendPackage(ZNet.instance.m_peers, new ZPackage(Encoding.UTF8.GetBytes(text3)));
					UpdateAllyFile(text2);
				}
			}
			yield return null;
		}

		private static IEnumerator PvP_RPCClientReceive(long sender, ZPackage package)
		{
			byte[] array = package.GetArray();
			if (array.Length != 0)
			{
				string @string = Encoding.UTF8.GetString(array);
				if (@string.StartsWith("CG_PvP_1"))
				{
					if (HeavyLogging)
					{
						Logger.LogInfo((object)("PvP_RPCClientReceive decoded: " + @string));
					}
					string[] array2 = @string.Split(new char[1] { ';' });
					if (array2.Length != 2)
					{
						Logger.LogError((object)$"Failed to parse payload ({array2.Length})");
					}
					PlayerFriends = SimpleJson.DeserializeObject<Dictionary<string, List<string>>>(array2[1]);
				}
			}
			else if (HeavyLogging)
			{
				Logger.LogInfo((object)"PvP_RPCClientReceive received no data");
			}
			yield return null;
		}
	}
}
namespace ChebsValheimLibrary.Minions
{
	public class ChebGonazMinion : MonoBehaviour
	{
		public enum CleanupType
		{
			None,
			Time,
			Logout
		}

		public enum DropType
		{
			Nothing,
			JustResources,
			Everything
		}

		public enum State
		{
			Waiting,
			Roaming,
			Following
		}

		public enum ArmorType
		{
			None,
			Leather,
			LeatherTroll,
			LeatherWolf,
			LeatherLox,
			Bronze,
			Iron,
			BlackMetal
		}

		public bool canBeCommanded = true;

		public const string MinionOwnershipZdoKey = "UndeadMinionMaster";

		public const string MinionDropsZdoKey = "UndeadMinionDrops";

		public const string MinionWaitPosZdoKey = "UndeadMinionWaitPosition";

		public const string MinionWaitObjectName = "UndeadMinionWaitPositionObject";

		public int createdOrder;

		private static readonly int VehicleLayer = LayerMask.NameToLayer("vehicle");

		private static List<Transform> _deathCrates = new List<Transform>();

		public bool ItemsDropped { get; private set; }

		private Vector3 StatusRoaming => Vector3.negativeInfinity;

		private Vector3 StatusFollowing => Vector3.positiveInfinity;

		public string UndeadMinionMaster
		{
			get
			{
				ZNetView val = default(ZNetView);
				if (!((Component)this).TryGetComponent<ZNetView>(ref val))
				{
					return "";
				}
				return val.GetZDO().GetString("UndeadMinionMaster", "");
			}
			set
			{
				ZNetView val = default(ZNetView);
				if (((Component)this).TryGetComponent<ZNetView>(ref val))
				{
					val.GetZDO().Set("UndeadMinionMaster", value);
				}
				else
				{
					Logger.LogError((object)("Cannot SetUndeadMinionMaster to " + value + " because it has no ZNetView component."));
				}
			}
		}

		public State Status
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				Vector3 waitPosition = GetWaitPosition();
				if (((Vector3)(ref waitPosition)).Equals(StatusFollowing))
				{
					return State.Following;
				}
				if (!((Vector3)(ref waitPosition)).Equals(StatusRoaming))
				{
					return State.Waiting;
				}
				return State.Roaming;
			}
		}

		public bool DepositIntoNearbyDeathCrate(CharacterDrop characterDrop, float range = 15f)
		{
			_deathCrates.RemoveAll((Transform t) => (Object)(object)t == (Object)null);
			Container val = default(Container);
			foreach (Transform item in _deathCrates.OrderBy((Transform t) => Vector3.Distance(t.position, ((Component)this).transform.position) < range))
			{
				if (characterDrop.m_drops.Count < 1)
				{
					break;
				}
				if (!((Component)item).TryGetComponent<Container>(ref val))
				{
					continue;
				}
				Inventory inventory = val.GetInventory();
				if (inventory == null)
				{
					continue;
				}
				List<Drop> list = new List<Drop>();
				foreach (Drop drop in characterDrop.m_drops)
				{
					if (inventory.CanAddItem(drop.m_prefab, -1))
					{
						inventory.AddItem(drop.m_prefab, drop.m_amountMax);
					}
					else
					{
						list.Add(drop);
					}
				}
				characterDrop.m_drops = list;
			}
			if (characterDrop.m_drops.Count < 1)
			{
				ItemsDropped = true;
				return ItemsDropped;
			}
			Container val2 = CreateDeathCrate();
			if ((Object)(object)val2 != (Object)null)
			{
				Inventory inv = val2.GetInventory();
				List<Drop> unsuccessful = new List<Drop>();
				characterDrop.m_drops.ForEach(delegate(Drop drop)
				{
					if (!inv.AddItem(drop.m_prefab, drop.m_amountMax))
					{
						unsuccessful.Add(drop);
					}
				});
				characterDrop.m_drops = unsuccessful;
				ItemsDropped = unsuccessful.Count == 0;
			}
			return ItemsDropped;
		}

		private Container CreateDeathCrate()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("CargoCrate"), ((Component)this).transform.position + Vector3.up, Quaternion.identity);
			_deathCrates.Add(val.transform);
			return val.GetComponent<Container>();
		}

		public static ArmorType DetermineArmorType(Inventory inventory, int armorBlackIronRequired, int armorIronRequired, int armorBronzeRequired, int armorLeatherRequired)
		{
			if (inventory.CountItems("$item_blackmetal", -1, true) >= armorBlackIronRequired)
			{
				return ArmorType.BlackMetal;
			}
			if (inventory.CountItems("$item_iron", -1, true) >= armorIronRequired)
			{
				return ArmorType.Iron;
			}
			if (inventory.CountItems("$item_bronze", -1, true) >= armorBronzeRequired)
			{
				return ArmorType.Bronze;
			}
			if (inventory.CountItems("$item_trollhide", -1, true) >= armorLeatherRequired)
			{
				return ArmorType.LeatherTroll;
			}
			if (inventory.CountItems("$item_wolfpelt", -1, true) >= armorLeatherRequired)
			{
				return ArmorType.LeatherWolf;
			}
			if (inventory.CountItems("$item_loxpelt", -1, true) >= armorLeatherRequired)
			{
				return ArmorType.LeatherLox;
			}
			foreach (string item in new List<string> { "$item_leatherscraps", "$item_deerhide", "$item_scalehide" })
			{
				if (inventory.CountItems(item, -1, true) >= armorLeatherRequired)
				{
					return ArmorType.Leather;
				}
			}
			return ArmorType.None;
		}

		public static bool CanSpawn(MemoryConfigEntry<string, List<string>> itemsCost, Inventory inventory, out string message)
		{
			return CanSpawn(itemsCost.Value, inventory, out message);
		}

		public static bool CanSpawn(string itemsCost, Inventory inventory, out string message)
		{
			return CanSpawn(itemsCost?.Split(new char[1] { ',' }).ToList(), inventory, out message);
		}

		public static bool CanSpawn(List<string> itemsCost, Inventory inventory, out string message)
		{
			message = "";
			List<Tuple<bool, string>> list = new List<Tuple<bool, string>>();
			foreach (string item2 in itemsCost)
			{
				string[] array = item2.Split(new char[1] { ':' });
				if (array.Length != 2)
				{
					message = "[1] Error in config for ItemsCost - please revise: (" + item2 + ")";
					Logger.LogError((object)message);
					return false;
				}
				string item = array[0];
				if (!int.TryParse(array[1], out var result))
				{
					message = "[2] Error in config for ItemsCost - please revise: (" + item2 + ")";
					Logger.LogError((object)message);
					return false;
				}
				Tuple<int, string, List<string>> tuple = CountItems(item, inventory);
				bool flag = tuple.Item1 >= result;
				message = (flag ? "" : ("Not enough " + string.Join("/", tuple.Item3)));
				list.Add(new Tuple<bool, string>(flag, message));
			}
			Tuple<bool, string> tuple2 = list.Find((Tuple<bool, string> t) => !t.Item1);
			if (tuple2 != null)
			{
				message = tuple2.Item2;
				return false;
			}
			return true;
		}

		public static void ConsumeRequirements(MemoryConfigEntry<string, List<string>> itemsCost, Inventory inventory)
		{
			ConsumeRequirements(itemsCost.Value, inventory);
		}

		public static void ConsumeRequirements(string itemsCost, Inventory inventory)
		{
			ConsumeRequirements(itemsCost?.Split(new char[1] { ',' }).ToList(), inventory);
		}

		protected static void ConsumeRequirements(List<string> itemsCost, Inventory inventory)
		{
			foreach (string item in itemsCost)
			{
				string[] array = item.Split(new char[1] { ':' });
				if (array.Length != 2)
				{
					Logger.LogError((object)"Error in config for ItemsCost - please revise.");
					break;
				}
				string text = array[0];
				if (!int.TryParse(array[1], out var result))
				{
					Logger.LogError((object)"Error in config for ItemsCost - please revise.");
					break;
				}
				int num = 0;
				string[] array2 = text.Split(new char[1] { '|' });
				foreach (string text2 in array2)
				{
					if (num >= result)
					{
						break;
					}
					GameObject prefab = ZNetScene.instance.GetPrefab(text2);
					if ((Object)(object)prefab == (Object)null)
					{
						Logger.LogError((object)("Error processing config for ItemsCost: " + text + " doesn't exist."));
						return;
					}
					string text3 = prefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_name;
					int num2 = inventory.CountItems(text3, -1, true);
					for (int j = 0; j < num2; j++)
					{
						if (num >= result)
						{
							break;
						}
						inventory.RemoveItem(text3, 1, -1, true);
						num++;
					}
				}
			}
		}

		protected static void GenerateDeathDrops(CharacterDrop characterDrop, MemoryConfigEntry<string, List<string>> itemsCost)
		{
			List<string> value = itemsCost.Value;
			GenerateDeathDrops(characterDrop, value);
		}

		protected static void GenerateDeathDrops(CharacterDrop characterDrop, string itemsCost)
		{
			List<string> itemsCost2 = itemsCost?.Split(new char[1] { ',' }).ToList();
			GenerateDeathDrops(characterDrop, itemsCost2);
		}

		protected static void GenerateDeathDrops(CharacterDrop characterDrop, List<string> itemsCost)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00c8: 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_00df: Expected O, but got Unknown
			foreach (string item in itemsCost)
			{
				string[] array = item.Split(new char[1] { ':' });
				if (array.Length != 2)
				{
					Logger.LogError((object)"Error in config for ItemsCost - please revise.");
					break;
				}
				string text = array[0];
				if (!int.TryParse(array[1], out var result))
				{
					Logger.LogError((object)"Error in config for ItemsCost - please revise.");
					break;
				}
				string[] array2 = text.Split(new char[1] { '|' });
				int num = 0;
				if (num < array2.Length)
				{
					string text2 = array2[num];
					GameObject prefab = ZNetScene.instance.GetPrefab(text2);
					if ((Object)(object)prefab == (Object)null)
					{
						Logger.LogError((object)("Error processing config for ItemsCost: " + text2 + " doesn't exist."));
						break;
					}
					characterDrop.m_drops.Add(new Drop
					{
						m_prefab = prefab,
						m_onePerPlayer = false,
						m_amountMin = result,
						m_amountMax = result,
						m_chance = 1f
					});
				}
			}
		}

		private static Tuple<int, string, List<string>> CountItems(string item, Inventory inventory)
		{
			int num = 0;
			List<string> list = new List<string>();
			string[] array = item.Split(new char[1] { '|' });
			foreach (string text in array)
			{
				GameObject prefab = ZNetScene.instance.GetPrefab(text);
				if ((Object)(object)prefab == (Object)null)
				{
					string text2 = "Error processing config for ItemsCost: " + text + " doesn't exist.";
					Logger.LogError((object)text2);
					return new Tuple<int, string, List<string>>(0, text2, list);
				}
				string text3 = prefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_name;
				list.Add(text3);
				int num2 = inventory.CountItems(text3, -1, true);
				num += num2;
			}
			return new Tuple<int, string, List<string>>(num, "", list);
		}

		private void OnCollisionEnter(Collision collision)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Character component = collision.gameObject.GetComponent<Character>();
			if ((Object)(object)component != (Object)null && (int)component.m_faction == 0 && (Object)(object)((Component)component).GetComponent<ChebGonazMinion>() == (Object)null)
			{
				Physics.IgnoreCollision(collision.collider, ((Component)this).GetComponent<Collider>());
			}
			else if ((Object)(object)collision.gameObject.GetComponentInParent<Vagon>() != (Object)null)
			{
				Physics.IgnoreCollision(collision.collider, ((Component)this).GetComponent<Collider>());
			}
		}

		public void Kill()
		{
			Character val = default(Character);
			if (((Component)this).TryGetComponent<Character>(ref val))
			{
				if (!val.IsDead())
				{
					val.SetHealth(0f);
				}
			}
			else
			{
				Logger.LogError((object)("Cannot kill " + ((Object)this).name + " because it has no Character component."));
			}
		}

		public bool BelongsToPlayer(string playerName)
		{
			ZNetView val = default(ZNetView);
			if (((Component)this).TryGetComponent<ZNetView>(ref val))
			{
				return val.GetZDO().GetString("UndeadMinionMaster", "").ToLower()
					.Trim()
					.Equals(playerName.ToLower().Trim());
			}
			return false;
		}

		public void RecordDrops(CharacterDrop characterDrop)
		{
			ZNetView val = default(ZNetView);
			if (((Component)this).TryGetComponent<ZNetView>(ref val))
			{
				string text = "";
				List<string> drops = new List<string>();
				characterDrop.m_drops.ForEach(delegate(Drop drop)
				{
					drops.Add($"{((Object)drop.m_prefab).name}:{drop.m_amountMax}");
				});
				text = string.Join(",", drops);
				val.GetZDO().Set("UndeadMinionDrops", string.Join(",", text));
			}
			else
			{
				Logger.LogError((object)("Cannot record drops because " + ((Object)this).name + " has no ZNetView component."));
			}
		}

		public void RestoreDrops()
		{
			ZNetView val = default(ZNetView);
			if (((Component)this).TryGetComponent<ZNetView>(ref val))
			{
				CharacterDrop characterDrop = ((Component)this).gameObject.GetComponent<CharacterDrop>();
				if ((Object)(object)characterDrop == (Object)null)
				{
					characterDrop = ((Component)this).gameObject.AddComponent<CharacterDrop>();
				}
				string @string = val.GetZDO().GetString("UndeadMinionDrops", "");
				if (!(@string == ""))
				{
					new List<string>(@string.Split(new char[1] { ',' })).ForEach(delegate(string dropString)
					{
						string[] array = dropString.Split(new char[1] { ':' });
						string prefabName = array[0];
						int amount = int.Parse(array[1]);
						AddOrUpdateDrop(characterDrop, prefabName, amount);
					});
				}
			}
			else
			{
				Logger.LogError((object)("Cannot record drops because " + ((Object)this).name + " has no ZNetView component."));
			}
		}

		protected void RecordWaitPosition(Vector3 waitPos)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			ZNetView val = default(ZNetView);
			if (((Component)this).TryGetComponent<ZNetView>(ref val))
			{
				if (!val.IsOwner())
				{
					val.ClaimOwnership();
				}
				val.GetZDO().Set("UndeadMinionWaitPosition", waitPos);
			}
			else
			{
				Logger.LogError((object)$"Cannot RecordWaitPosition {waitPos} because it has no ZNetView component.");
			}
		}

		protected Vector3 GetWaitPosition()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			ZNetView val = default(ZNetView);
			if (((Component)this).TryGetComponent<ZNetView>(ref val))
			{
				return val.GetZDO().GetVec3("UndeadMinionWaitPosition", StatusRoaming);
			}
			Logger.LogError((object)"Cannot GetWaitPosition because it has no ZNetView component.");
			return StatusRoaming;
		}

		public void RoamFollowOrWait()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			Vector3 waitPosition = GetWaitPosition();
			MonsterAI val2 = default(MonsterAI);
			if (((Vector3)(ref waitPosition)).Equals(StatusFollowing))
			{
				Player val = Player.GetAllPlayers().Find((Player p) => BelongsToPlayer(p.GetPlayerName()));
				if ((Object)(object)val == (Object)null)
				{
					Logger.LogError((object)(((Object)this).name + " should be following but has no associated player. Roaming instead."));
					Roam();
				}
				else
				{
					Follow(((Component)val).gameObject);
				}
			}
			else if (((Vector3)(ref waitPosition)).Equals(StatusRoaming))
			{
				Roam();
			}
			else if (!((Component)this).TryGetComponent<MonsterAI>(ref val2))
			{
				Logger.LogError((object)(((Object)this).name + " cannot WaitAtRecordedPosition because it has no MonsterAI component."));
			}
			else
			{
				GameObject val3 = new GameObject("UndeadMinionWaitPositionObject");
				val3.transform.position = waitPosition;
				val2.SetFollowTarget(val3);
			}
		}

		public void Follow(GameObject followObject)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			MonsterAI val = default(MonsterAI);
			if (!((Component)this).TryGetComponent<MonsterAI>(ref val))
			{
				Logger.LogError((object)"Cannot Follow because it has no MonsterAI component.");
				return;
			}
			GameObject followTarget = val.GetFollowTarget();
			if ((Object)(object)followTarget != (Object)null && ((Object)followTarget).name == "UndeadMinionWaitPositionObject")
			{
				Object.Destroy((Object)(object)followTarget);
			}
			RecordWaitPosition(StatusFollowing);
			val.SetFollowTarget(followObject);
		}

		public void Wait(Vector3 waitPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			RecordWaitPosition(waitPosition);
			RoamFollowOrWait();
		}

		public void Roam()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			RecordWaitPosition(StatusRoaming);
			MonsterAI val = default(MonsterAI);
			if (!((Component)this).TryGetComponent<MonsterAI>(ref val))
			{
				Logger.LogError((object)("Cannot Roam because " + ((Object)this).name + " has no MonsterAI component!"));
				return;
			}
			GameObject followTarget = val.GetFollowTarget();
			if ((Object)(object)followTarget != (Object)null && ((Object)followTarget).name == "UndeadMinionWaitPositionObject")
			{
				Object.Destroy((Object)(object)followTarget);
			}
			val.SetFollowTarget((GameObject)null);
		}

		public static T FindClosest<T>(Transform targetTransform, float radius, int mask, Func<T, bool> where, bool interactable) where T : Component
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			ZNetView val = default(ZNetView);
			return (from t in (from c in Physics.OverlapSphere(targetTransform.position, radius, mask)
					where (Object)(object)((Component)c).GetComponentInParent<T>() != (Object)null
					select ((Component)c).GetComponentInParent<T>() into c
					where !interactable || (((Component)c).TryGetComponent<ZNetView>(ref val) && val.IsValid())
					select c).Where(@where)
				orderby Vector3.Distance(((Component)t).transform.position, targetTransform.position)
				select t).FirstOrDefault();
		}

		public static List<T> FindNearby<T>(Transform targetTransform, float radius, int mask, Func<T, bool> where, bool interactable) where T : Component
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			ZNetView val = default(ZNetView);
			return (from c in Physics.OverlapSphere(targetTransform.position, radius, mask)
				where (Object)(object)((Component)c).GetComponentInParent<T>() != (Object)null
				select ((Component)c).GetComponentInParent<T>() into c
				where !interactable || (((Component)c).TryGetComponent<ZNetView>(ref val) && val.IsValid())
				select c).Where(where).ToList();
		}

		public static void AddOrUpdateDrop(CharacterDrop characterDrop, string prefabName, int amount)
		{
			//IL_0048: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			Drop val = ((IEnumerable<Drop>)characterDrop.m_drops).FirstOrDefault((Func<Drop, bool>)((Drop drop) => ((Object)drop.m_prefab).name.Equals(prefabName)));
			if (val != null)
			{
				val.m_amountMin = amount;
				val.m_amountMax = amount;
				val.m_chance = 1f;
				return;
			}
			characterDrop.m_drops.Add(new Drop
			{
				m_prefab = ZNetScene.instance.GetPrefab(prefabName),
				m_onePerPlayer = true,
				m_amountMin = amount,
				m_amountMax = amount,
				m_chance = 1f
			});
		}

		public virtual void Awake()
		{
		}
	}
	public class FreshMinion : MonoBehaviour
	{
	}
	public class NukeRock : NukeTree
	{
		protected override void Nuke()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			Destructible componentInParent = ((Component)this).GetComponentInParent<Destructible>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				HitData val = new HitData();
				val.m_damage.m_pickaxe = 500f;
				val.m_toolTier = 100;
				componentInParent.Damage(val);
				return;
			}
			MineRock5 componentInParent2 = ((Component)this).GetComponentInParent<MineRock5>();
			Bounds bounds;
			if ((Object)(object)componentInParent2 != (Object)null)
			{
				for (int i = 0; i < componentInParent2.m_hitAreas.Count; i++)
				{
					HitArea val2 = componentInParent2.m_hitAreas[i];
					if (val2.m_health > 0f)
					{
						HitData val3 = new HitData();
						val3.m_damage.m_damage = val2.m_health;
						bounds = val2.m_collider.bounds;
						val3.m_point = ((Bounds)(ref bounds)).center;
						val3.m_toolTier = 100;
						componentInParent2.DamageArea(i, val3);
					}
				}
				return;
			}
			MineRock componentInParent3 = ((Component)this).GetComponentInParent<MineRock>();
			if (!((Object)(object)componentInParent3 != (Object)null))
			{
				return;
			}
			HitArea val5 = default(HitArea);
			for (int j = 0; j < componentInParent3.m_hitAreas.Length; j++)
			{
				Collider val4 = componentInParent3.m_hitAreas[j];
				if (((Component)val4).TryGetComponent<HitArea>(ref val5) && val5.m_health > 0f)
				{
					HitData val6 = new HitData();
					val6.m_damage.m_damage = val5.m_health;
					bounds = val4.bounds;
					val6.m_point = ((Bounds)(ref bounds)).center;
					val6.m_toolTier = 100;
					componentInParent2.DamageArea(j, val6);
				}
			}
		}
	}
	public class NukeTree : MonoBehaviour
	{
		public const float NukeAfter = 120f;

		private IEnumerator Start()
		{
			yield return (object)new WaitForSeconds(120f);
			Nuke();
			Object.Destroy((Object)(object)this);
		}

		protected virtual void Nuke()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			HitData val = new HitData();
			val.m_damage.m_chop = 999f;
			val.m_toolTier = 4;
			Destructible componentInParent = ((Component)this).GetComponentInParent<Destructible>();
			if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.GetDestructibleType() == 2)
			{
				componentInParent.Damage(val);
				return;
			}
			TreeLog componentInParent2 = ((Component)this).GetComponentInParent<TreeLog>();
			if ((Object)(object)componentInParent2 != (Object)null)
			{
				componentInParent2.Damage(val);
				return;
			}
			TreeBase componentInParent3 = ((Component)this).GetComponentInParent<TreeBase>();
			if ((Object)(object)componentInParent3 != (Object)null)
			{
				componentInParent3.Damage(val);
			}
		}
	}
}
namespace ChebsValheimLibrary.Minions.AI
{
	public class MinerAI : MonoBehaviour
	{
		private float _nextCheck;

		private float _lastChat;

		private MonsterAI _monsterAI;

		private Humanoid _humanoid;

		private List<string> _rocksList;

		private string _status;

		private bool _inContact;

		public virtual string RockInternalIDsList => "";

		public virtual float RoamRange => 0f;

		public virtual float LookRadius => 0f;

		public virtual float UpdateDelay => 0f;

		public virtual float ToolDamage => 6f;

		public virtual short ToolTier => 2;

		public virtual float ChatInterval => 5f;

		public virtual float ChatDistance => 5f;

		public string Status
		{
			get
			{
				return _status;
			}
			protected set
			{
				_status = value;
			}
		}

		public void LookForMineableObjects()
		{
			if ((Object)(object)_monsterAI.GetFollowTarget() != (Object)null)
			{
				return;
			}
			int mask = (1 << LayerMask.NameToLayer("static_solid")) | (1 << LayerMask.NameToLayer("Default_small"));
			Transform val = (from c in ChebGonazMinion.FindNearby<Transform>(((Component)this).transform, LookRadius, mask, (Func<Transform, bool>)Hittable, interactable: false)
				select (c, (((Object)c).name.Contains("_Tin") || ((Object)c).name.Contains("silver") || ((Object)c).name.Contains("copper")) ? 1 : 2) into t
				orderby t.Item2, Vector3.Distance(((Component)this).transform.position, t.c.position)
				select t).FirstOrDefault().ToTuple()?.Item1;
			if ((Object)(object)val != (Object)null)
			{
				_monsterAI.SetFollowTarget(((Component)val).gameObject);
				NukeRock nukeRock = default(NukeRock);
				if (!((Component)val).TryGetComponent<NukeRock>(ref nukeRock))
				{
					((Component)val).gameObject.AddComponent<NukeRock>();
				}
			}
		}

		public void UpdateToolProperties()
		{
			GameObject[] randomWeapon = _humanoid.m_randomWeapon;
			object obj;
			if (randomWeapon == null)
			{
				obj = null;
			}
			else
			{
				GameObject? obj2 = randomWeapon.FirstOrDefault();
				obj = ((obj2 != null) ? obj2.GetComponent<ItemDrop>() : null);
			}
			ItemDrop val = (ItemDrop)obj;
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to update tool properties: tool is null");
				return;
			}
			val.m_itemData.m_shared.m_damages.m_pickaxe = ToolDamage;
			val.m_itemData.m_shared.m_toolTier = ToolTier;
		}

		protected virtual void Awake()
		{
			_rocksList = RockInternalIDsList.Split(new char[1] { ',' }).ToList();
			_monsterAI = ((Component)this).GetComponent<MonsterAI>();
			_humanoid = ((Component)this).GetComponent<Humanoid>();
			_monsterAI.m_alertRange = 1f;
			((BaseAI)_monsterAI).m_randomMoveRange = RoamRange;
			UpdateToolProperties();
		}

		protected virtual void FixedUpdate()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			GameObject followTarget = _monsterAI.GetFollowTarget();
			if ((Object)(object)followTarget != (Object)null)
			{
				Player val = default(Player);
				if (followTarget.TryGetComponent<Player>(ref val))
				{
					string text = LocalizationManager.Instance.TryTranslate("$chebgonaz_minionstatus_following");
					_status = text + " " + val.GetPlayerName();
					return;
				}
				if (ChatInterval != 0f && Time.time > _lastChat + ChatInterval)
				{
					_lastChat = Time.time;
					List<Player> list = new List<Player>();
					Player.GetPlayersInRange(((Component)this).transform.position, ChatDistance, list);
					if (list.Count > 0)
					{
						string text2 = LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_target");
						Chat.instance.SetNpcText(((Component)this).gameObject, Vector3.up, 5f, 10f, "", text2 + ": " + ((Object)followTarget.gameObject).name, false);
					}
				}
				Vector3 position = followTarget.transform.position;
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(position.x, ((Component)this).transform.position.y, position.z);
				((Component)this).transform.LookAt(val2);
				TryAttack();
			}
			if (Time.time > _nextCheck)
			{
				_nextCheck = Time.time + UpdateDelay + Random.value;
				LookForMineableObjects();
				_status = (((Object)(object)_monsterAI.GetFollowTarget() != (Object)null) ? (LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_target") + ": (" + ((Object)_monsterAI.GetFollowTarget()).name + ").") : LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_cantfindtarget"));
				((Character)_humanoid).m_name = _status;
			}
		}

		private void TryAttack()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_017f: Expected O, but got Unknown
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			GameObject followTarget = _monsterAI.GetFollowTarget();
			if (!((Object)(object)followTarget != (Object)null) || !_inContact || !_monsterAI.DoAttack((Character)null, false))
			{
				return;
			}
			Destructible componentInParent = followTarget.GetComponentInParent<Destructible>();
			if ((Object)(object)componentInParent != (Object)null && componentInParent.m_minToolTier <= ToolTier)
			{
				HitData val = new HitData();
				val.m_damage.m_pickaxe = ToolDamage;
				val.m_toolTier = ToolTier;
				componentInParent.Damage(val);
				return;
			}
			MineRock5 componentInParent2 = followTarget.GetComponentInParent<MineRock5>();
			Bounds bounds;
			if ((Object)(object)componentInParent2 != (Object)null && componentInParent2.m_minToolTier <= ToolTier)
			{
				for (int i = 0; i < componentInParent2.m_hitAreas.Count; i++)
				{
					HitArea val2 = componentInParent2.m_hitAreas[i];
					if (val2.m_health > 0f)
					{
						HitData val3 = new HitData();
						val3.m_damage.m_damage = ToolDamage;
						bounds = val2.m_collider.bounds;
						val3.m_point = ((Bounds)(ref bounds)).center;
						val3.m_toolTier = ToolTier;
						componentInParent2.DamageArea(i, val3);
					}
				}
				return;
			}
			MineRock componentInParent3 = followTarget.GetComponentInParent<MineRock>();
			if (!((Object)(object)componentInParent3 != (Object)null) || componentInParent3.m_minToolTier > ToolTier)
			{
				return;
			}
			HitArea val5 = default(HitArea);
			for (int j = 0; j < componentInParent3.m_hitAreas.Length; j++)
			{
				Collider val4 = componentInParent3.m_hitAreas[j];
				if (((Component)val4).TryGetComponent<HitArea>(ref val5) && val5.m_health > 0f)
				{
					HitData val6 = new HitData();
					val6.m_damage.m_damage = ToolDamage;
					bounds = val4.bounds;
					val6.m_point = ((Bounds)(ref bounds)).center;
					val6.m_toolTier = ToolTier;
					componentInParent2.DamageArea(j, val6);
				}
			}
		}

		private void OnCollisionEnter(Collision collision)
		{
			_inContact = Hittable((collision != null) ? collision.gameObject : null);
		}

		private void OnCollisionExit(Collision other)
		{
			_inContact = Hittable((other != null) ? other.gameObject : null);
		}

		private bool Hittable(Transform t)
		{
			return Hittable(((Component)t).gameObject);
		}

		private bool Hittable(GameObject go)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			if ((Object)(object)go == (Object)null)
			{
				return false;
			}
			Destructible componentInParent = go.GetComponentInParent<Destructible>();
			if (_rocksList.FirstOrDefault(delegate(string rocksListName)
			{
				Transform parent = go.transform.parent;
				return (Object)(object)parent != (Object)null && rocksListName.Contains(((Object)parent).name);
			}) == null && (!((Object)(object)componentInParent != (Object)null) || (int)componentInParent.m_destructibleType != 1 || !((Object)(object)((Component)componentInParent).GetComponent<Container>() == (Object)null) || !((Object)(object)((Component)componentInParent).GetComponent<Pickable>() == (Object)null)) && !((Object)(object)go.GetComponentInParent<MineRock5>() != (Object)null))
			{
				return (Object)(object)go.GetComponentInParent<MineRock>() != (Object)null;
			}
			return true;
		}
	}
	public class WoodcutterAI : MonoBehaviour
	{
		private float _nextCheck;

		private float _lastChat;

		private MonsterAI _monsterAI;

		private Humanoid _humanoid;

		private readonly int _defaultMask = LayerMask.GetMask(new string[1] { "Default" });

		private static List<Transform> _transforms = new List<Transform>();

		private string _status;

		private bool _inContact;

		private bool _chopping;

		public virtual float RoamRange => 0f;

		public virtual float LookRadius => 0f;

		public virtual float UpdateDelay => 0f;

		public virtual float ToolDamage => 6f;

		public virtual short ToolTier => 2;

		public virtual float ChatInterval => 5f;

		public virtual float ChatDistance => 5f;

		public string Status
		{
			get
			{
				return _status;
			}
			protected set
			{
				_status = value;
			}
		}

		public void LookForCuttableObjects()
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Invalid comparison between Unknown and I4
			if ((Object)(object)_monsterAI.GetFollowTarget() != (Object)null)
			{
				return;
			}
			_transforms.RemoveAll((Transform a) => (Object)(object)a == (Object)null);
			Transform val = ChebGonazMinion.FindClosest<Transform>(((Component)this).transform, LookRadius, _defaultMask, (Func<Transform, bool>)((Transform a) => !_transforms.Contains(a)), interactable: false);
			if ((Object)(object)val == (Object)null)
			{
				val = (from t in _transforms.Where(delegate(Transform t)
					{
						//IL_0011: Unknown result type (might be due to invalid IL or missing references)
						//IL_0017: Invalid comparison between Unknown and I4
						Destructible componentInParent4 = ((Component)t).GetComponentInParent<Destructible>();
						if ((Object)(object)componentInParent4 != (Object)null && (int)componentInParent4.GetDestructibleType() == 2 && componentInParent4.m_minToolTier <= ToolTier)
						{
							return true;
						}
						TreeLog componentInParent5 = ((Component)t).GetComponentInParent<TreeLog>();
						if ((Object)(object)componentInParent5 != (Object)null && componentInParent5.m_minToolTier <= ToolTier)
						{
							return true;
						}
						TreeBase componentInParent6 = ((Component)t).GetComponentInParent<TreeBase>();
						return ((Object)(object)componentInParent6 != (Object)null && componentInParent6.m_minToolTier <= ToolTier) ? true : false;
					})
					orderby Vector3.Distance(t.position, ((Component)this).transform.position)
					select t).FirstOrDefault();
			}
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			Destructible componentInParent = ((Component)val).GetComponentInParent<Destructible>();
			NukeTree nukeTree = default(NukeTree);
			if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.GetDestructibleType() == 2)
			{
				_transforms.Add(val);
				_monsterAI.SetFollowTarget(((Component)componentInParent).gameObject);
				_status = "Moving to stump.";
				if (!((Component)val).TryGetComponent<NukeTree>(ref nukeTree))
				{
					((Component)val).gameObject.AddComponent<NukeTree>();
				}
				return;
			}
			TreeLog componentInParent2 = ((Component)val).GetComponentInParent<TreeLog>();
			if ((Object)(object)componentInParent2 != (Object)null)
			{
				_transforms.Add(val);
				_monsterAI.SetFollowTarget(((Component)componentInParent2).gameObject);
				_status = "Moving to log.";
				if (!((Component)val).TryGetComponent<NukeTree>(ref nukeTree))
				{
					((Component)val).gameObject.AddComponent<NukeTree>();
				}
				return;
			}
			TreeBase componentInParent3 = ((Component)val).GetComponentInParent<TreeBase>();
			if ((Object)(object)componentInParent3 != (Object)null)
			{
				_transforms.Add(val);
				_monsterAI.SetFollowTarget(((Component)componentInParent3).gameObject);
				_status = "Moving to tree.";
				if (!((Component)val).TryGetComponent<NukeTree>(ref nukeTree))
				{
					((Component)val).gameObject.AddComponent<NukeTree>();
				}
			}
		}

		public void UpdateToolProperties()
		{
			GameObject[] randomWeapon = _humanoid.m_randomWeapon;
			object obj;
			if (randomWeapon == null)
			{
				obj = null;
			}
			else
			{
				GameObject? obj2 = randomWeapon.FirstOrDefault();
				obj = ((obj2 != null) ? obj2.GetComponent<ItemDrop>() : null);
			}
			ItemDrop val = (ItemDrop)obj;
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to update tool properties: tool is null");
				return;
			}
			val.m_itemData.m_shared.m_damages.m_chop = ToolDamage;
			val.m_itemData.m_shared.m_toolTier = ToolTier;
		}

		protected virtual void Awake()
		{
			_monsterAI = ((Component)this).GetComponent<MonsterAI>();
			_humanoid = ((Component)this).GetComponent<Humanoid>();
			_monsterAI.m_alertRange = 1f;
			((BaseAI)_monsterAI).m_randomMoveRange = RoamRange;
			UpdateToolProperties();
		}

		protected virtual void FixedUpdate()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			GameObject followTarget = _monsterAI.GetFollowTarget();
			if ((Object)(object)followTarget != (Object)null)
			{
				Player val = default(Player);
				if (followTarget.TryGetComponent<Player>(ref val))
				{
					string text = LocalizationManager.Instance.TryTranslate("$chebgonaz_minionstatus_following");
					_status = text + " " + val.GetPlayerName();
					return;
				}
				if (ChatInterval != 0f && Time.time > _lastChat + ChatInterval)
				{
					_lastChat = Time.time;
					List<Player> list = new List<Player>();
					Player.GetPlayersInRange(((Component)this).transform.position, ChatDistance, list);
					if (list.Count > 0)
					{
						string text2 = LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_target");
						Chat.instance.SetNpcText(((Component)this).gameObject, Vector3.up, 5f, 10f, "", text2 + ": " + ((Object)followTarget.gameObject).name, false);
					}
				}
				Vector3 position = followTarget.transform.position;
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(position.x, ((Component)this).transform.position.y, position.z);
				((Component)this).transform.LookAt(val2);
				TryAttack(val2);
			}
			if (Time.time > _nextCheck)
			{
				_nextCheck = Time.time + UpdateDelay + Random.value;
				LookForCuttableObjects();
				if ((Object)(object)_monsterAI.GetFollowTarget() == (Object)null)
				{
					_status = LocalizationManager.Instance.TryTranslate("$chebgonaz_worker_cantfindtarget");
				}
				((Character)_humanoid).m_name = _status;
			}
		}

		private void TryAttack(Vector3 lookAtPos)
		{
			//IL_0046: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Invalid comparison between Unknown and I4
			if ((Object)(object)_humanoid == (Object)null || (Object)(object)_monsterAI == (Object)null || _chopping)
			{
				return;
			}
			GameObject followTarget = _monsterAI.GetFollowTarget();
			if (!((Object)(object)followTarget != (Object)null) || (!_inContact && !(Vector3.Distance(lookAtPos, ((Component)this).transform.position) < 1.5f)))
			{
				return;
			}
			Destructible destructible = followTarget.GetComponentInParent<Destructible>();
			if ((Object)(object)destructible != (Object)null && (int)destructible.GetDestructibleType() == 2)
			{
				((MonoBehaviour)this).StartCoroutine(Chop(destructible.m_health, (IDestructible)(object)destructible, () => destructible.m_health));
				return;
			}
			TreeLog treeLog = followTarget.GetComponentInParent<TreeLog>();
			if ((Object)(object)treeLog != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(Chop(treeLog.m_health, (IDestructible)(object)treeLog, () => treeLog.m_health));
				return;
			}
			TreeBase tree = followTarget.GetComponentInParent<TreeBase>();
			if ((Object)(object)tree != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(Chop(tree.m_health, (IDestructible)(object)treeLog, () => tree.m_health));
			}
		}

		private IEnumerator Chop(float healthBeforeAttack, IDestructible destructible, Func<float> healthAfterDamaged)
		{
			_chopping = true;
			_monsterAI.DoAttack((Character)null, false);
			yield return (object)new WaitForSeconds(2f);
			if (healthAfterDamaged() < healthBeforeAttack)
			{
				_chopping = false;
				yield break;
			}
			HitData val = new HitData();
			val.m_damage.m_chop = ToolDamage;
			val.m_toolTier = ToolTier;
			if (destructible != null)
			{
				destructible.Damage(val);
			}
			_chopping = false;
		}

		private void OnCollisionEnter(Collision collision)
		{
			_inContact = Hittable((collision != null) ? collision.gameObject : null);
		}

		private void OnCollisionExit(Collision other)
		{
			_inContact = Hittable((other != null) ? other.gameObject : null);
		}

		private bool Hittable(GameObject go)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			Destructible componentInParent = go.GetComponentInParent<Destructible>();
			if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.GetDestructibleType() == 2)
			{
				return true;
			}
			if ((Object)(object)go.GetComponentInParent<TreeLog>() != (Object)null)
			{
				return true;
			}
			if ((Object)(object)go.GetComponentInParent<TreeBase>() != (Object)null)
			{
				return true;
			}
			return false;
		}
	}
}
namespace ChebsValheimLibrary.Items
{
	public enum CraftingTable
	{
		None,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("blackforge")]
		BlackForge
	}
	public class Item
	{
		public ConfigEntry<bool> Allowed;

		protected float DoOnUpdateDelay;

		public virtual string ItemName => "";

		public virtual string PrefabName => "";

		public virtual string NameLocalization => "";

		public virtual string DescriptionLocalization => "";

		protected virtual string DefaultRecipe => "";

		public virtual void CreateConfigs(BaseUnityPlugin plugin)
		{
		}

		public virtual void UpdateRecipe()
		{
		}

		public virtual void UpdateRecipe(ConfigEntry<CraftingTable> craftingStationRequired, ConfigEntry<string> craftingCost, ConfigEntry<int> craftingStationLevel)
		{
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Expected O, but got Unknown
			ItemManager instance = ItemManager.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				CustomItem item = instance.GetItem(ItemName);
				if (item == null)
				{
					obj = null;
				}
				else
				{
					CustomRecipe recipe = item.Recipe;
					obj = ((recipe != null) ? recipe.Recipe : null);
				}
			}
			Recipe val = (Recipe)obj;
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)("Failed to update recipe for " + ItemName + " because ItemManager returned null for " + ItemName + "."));
				return;
			}
			if (craftingStationRequired == null)
			{
				Logger.LogError((object)("Failed to update recipe for " + ItemName + " because CraftingStationRequired is null."));
				return;
			}
			if (craftingCost == null)
			{
				Logger.LogError((object)("Failed to update recipe for " + ItemName + " because CraftingCost is null."));
				return;
			}
			if (craftingStationLevel == null)
			{
				Logger.LogError((object)("Failed to update recipe for " + ItemName + " because CraftingStationLevel is null."));
				return;
			}
			string name = InternalName.GetName(craftingStationRequired.Value);
			val.m_minStationLevel = craftingStationLevel.Value;
			PrefabManager instance2 = PrefabManager.Instance;
			GameObject val2 = ((instance2 != null) ? instance2.GetPrefab(name) : null);
			if ((Object)(object)val2 == (Object)null)
			{
				Logger.LogError((object)("Failed to update recipe for " + ItemName + " because of failure to get " + name + " from ZNetScene.instance."));
				return;
			}
			val.m_craftingStation = val2.GetComponent<CraftingStation>();
			List<Requirement> list = new List<Requirement>();
			string[] array = craftingCost.Value.Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { ':' });
				string text = array2[0];
				int num = int.Parse(array2[1]);
				PrefabManager instance3 = PrefabManager.Instance;
				GameObject val3 = ((instance3 != null) ? instance3.GetPrefab(text) : null);
				if ((Object)(object)val3 == (Object)null)
				{
					Logger.LogError((object)("Failed to update recipe for " + ItemName + " because of failure to get " + text + "'s prefab from ZNetScene.instance."));
				}
				else
				{
					list.Add(new Requirement
					{
						m_amount = num,
						m_amountPerLevel = num * 2,
						m_resItem = val3.GetComponent<ItemDrop>()
					});
				}
			}
			val.m_resources = list.ToArray();
		}

		protected void SetRecipeReqs(ItemConfig recipeConfig, ConfigEntry<string> craftingCost, ConfigEntry<CraftingTable> craftingStationRequired, ConfigEntry<int> craftingStationLevel)
		{
			recipeConfig.CraftingStation = ((InternalName)typeof(CraftingTable).GetMember(craftingStationRequired.Value.ToString())[0].GetCustomAttributes(typeof(InternalName)).First()).Name;
			if (Enumerable.Contains(craftingCost.Value, ','))
			{
				string[] array = craftingCost.Value.Split(new char[1] { ',' });
				for (int i = 0; i < array.Length; i++)
				{
					AddMaterial(array[i]);
				}
			}
			else
			{
				AddMaterial(craftingCost.Value);
			}
			recipeConfig.MinStationLevel = craftingStationLevel.Value;
			void AddMaterial(string material)
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Expected O, but got Unknown
				string[] array2 = material.Split(new char[1] { ':' });
				string text = array2[0];
				int num = int.Parse(array2[1]);
				recipeConfig.AddRequirement(new RequirementConfig(text, num, num * 2, false));
			}
		}

		public virtual void DoOnUpdate()
		{
		}

		public virtual CustomItem GetCustomItemFromPrefab(GameObject prefab, bool fixReference = true)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.Name = NameLocalization;
			val.Description = DescriptionLocalization;
			CustomItem val2 = new CustomItem(prefab, fixReference, val);
			if ((Object)(object)val2.ItemPrefab == (Object)null)
			{
				Logger.LogError((object)("GetCustomItemFromPrefab: " + PrefabName + "'s ItemPrefab is null!"));
				return null;
			}
			return val2;
		}
	}
}
namespace ChebsValheimLibrary.Items.Weapons.Wood
{
	public class SkeletonClub : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonClub";

		public override string PrefabName => "ChebGonaz_SkeletonClub.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonclub_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonclub_desc";
	}
}
namespace ChebsValheimLibrary.Items.Weapons.Poison
{
	public class SkeletonMace : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonMace";

		public override string PrefabName => "ChebGonaz_SkeletonMace.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonmace_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonmace_desc";
	}
	public class SkeletonMace2 : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonMace2";

		public override string PrefabName => "ChebGonaz_SkeletonMace2.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonmace_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonmace_desc";
	}
	public class SkeletonMace3 : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonMace3";

		public override string PrefabName => "ChebGonaz_SkeletonMace3.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonmace_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonmace_desc";
	}
}
namespace ChebsValheimLibrary.Items.Weapons.Needle
{
	public class SkeletonMaceNeedle : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonMaceNeedle";

		public override string PrefabName => "ChebGonaz_SkeletonMaceNeedle.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonmaceneedle_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonmaceneedle_desc";
	}
}
namespace ChebsValheimLibrary.Items.Weapons.Mage
{
	public class SkeletonFireballLevel1 : Item
	{
		public override string ItemName => "ChebGonaz_FireballLevel1";

		public override string PrefabName => "ChebGonaz_FireballLevel1.prefab";

		public override string NameLocalization => "$item_chebgonaz_fireballlevel1_name";

		public override string DescriptionLocalization => "$item_chebgonaz_fireballlevel1_desc";
	}
	public class SkeletonFireballLevel2 : Item
	{
		public override string ItemName => "ChebGonaz_FireballLevel2";

		public override string PrefabName => "ChebGonaz_FireballLevel2.prefab";

		public override string NameLocalization => "$item_chebgonaz_fireballlevel2_name";

		public override string DescriptionLocalization => "$item_chebgonaz_fireballlevel2_desc";
	}
	public class SkeletonFireballLevel3 : Item
	{
		public override string ItemName => "ChebGonaz_FireballLevel3";

		public override string PrefabName => "ChebGonaz_FireballLevel3.prefab";

		public override string NameLocalization => "$item_chebgonaz_fireballlevel3_name";

		public override string DescriptionLocalization => "$item_chebgonaz_fireballlevel3_desc";
	}
}
namespace ChebsValheimLibrary.Items.Weapons.Iron
{
	public class SkeletonAxe : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonAxe";

		public override string PrefabName => "ChebGonaz_SkeletonAxe.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonaxe_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonaxe_desc";
	}
	public class SkeletonMaceIron : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonMaceIron";

		public override string PrefabName => "ChebGonaz_SkeletonMaceIron.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonmaceiron_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonmaceiron_desc";
	}
	public class SkeletonSwordIron : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonSwordIron";

		public override string PrefabName => "ChebGonaz_SkeletonSwordIron.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonswordiron_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonswordiron_desc";
	}
}
namespace ChebsValheimLibrary.Items.Weapons.Bronze
{
	public class SkeletonAxeBronze : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonAxeBronze";

		public override string PrefabName => "ChebGonaz_SkeletonAxeBronze.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonaxebronze_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonaxebronze_desc";
	}
	public class SkeletonMaceBronze : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonMaceBronze";

		public override string PrefabName => "ChebGonaz_SkeletonMaceBronze.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonmacebronze_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonmacebronze_desc";
	}
	public class SkeletonSwordBronze : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonSwordBronze";

		public override string PrefabName => "ChebGonaz_SkeletonSwordBronze.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonswordbronze_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonswordbronze_desc";
	}
}
namespace ChebsValheimLibrary.Items.Weapons.Bows
{
	public class SkeletonBow : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonBow";

		public override string PrefabName => "ChebGonaz_SkeletonBow.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonbow_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonbow_desc";
	}
	public class SkeletonBow2 : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonBow2";

		public override string PrefabName => "ChebGonaz_SkeletonBow2.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonbow2_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonbow2_desc";
	}
	public class SkeletonBow3 : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonBow3";

		public override string PrefabName => "ChebGonaz_SkeletonBow3.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonbow3_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonbow3_desc";
	}
	public class SkeletonBowFire : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonBowFire";

		public override string PrefabName => "ChebGonaz_SkeletonBowFire.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonbowfire_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonbowfire_desc";
	}
	public class SkeletonBowFrost : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonBowFrost";

		public override string PrefabName => "ChebGonaz_SkeletonBowFrost.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonbowfrost_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonbowfrost_desc";
	}
	public class SkeletonBowPoison : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonBowPoison";

		public override string PrefabName => "ChebGonaz_SkeletonBowPoison.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonbowpoison_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonbowpoison_desc";
	}
	public class SkeletonBowSilver : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonBowSilver";

		public override string PrefabName => "ChebGonaz_SkeletonBowSilver.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonbowsilver_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonbowsilver_desc";
	}
}
namespace ChebsValheimLibrary.Items.Weapons.BlackMetal
{
	public class SkeletonAxeBlackMetal : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonAxeBlackMetal";

		public override string PrefabName => "ChebGonaz_SkeletonAxeBlackMetal.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonaxeblackmetal_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonaxeblackmetal_desc";
	}
	public class SkeletonMaceBlackMetal : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonMaceBlackMetal";

		public override string PrefabName => "ChebGonaz_SkeletonMaceBlackMetal.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonmaceblackmetal_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonmaceblackmetal_desc";
	}
	public class SkeletonSwordBlackMetal : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonSwordBlackMetal";

		public override string PrefabName => "ChebGonaz_SkeletonSwordBlackMetal.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonswordblackmetal_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonswordblackmetal_desc";
	}
}
namespace ChebsValheimLibrary.Items.Tools
{
	public class SkeletonPickaxe : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonPickaxe";

		public override string PrefabName => "ChebGonaz_SkeletonPickaxe.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonpickaxe_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonpickaxe_desc";
	}
	public class SkeletonWoodAxe : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonWoodAxe";

		public override string PrefabName => "ChebGonaz_SkeletonWoodAxe.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonaxe_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonaxe_desc";
	}
}
namespace ChebsValheimLibrary.Items.Armor.Mage
{
	public class SkeletonMageCirclet : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonMageCirclet";

		public override string PrefabName => "ChebGonaz_SkeletonMageCirclet.prefab";

		public override string NameLocalization => "$item_chebgonaz_magecirclet_name";

		public override string DescriptionLocalization => "$item_chebgonaz_magecirclet_desc";
	}
}
namespace ChebsValheimLibrary.Items.Armor.Leather
{
	public class SkeletonHelmetLeather : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetLeather";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetLeather.prefab";

		public override string NameLocalization => "$item_helmet_leather";

		public override string DescriptionLocalization => "$item_helmet_leather_description";
	}
	public class SkeletonHelmetLeatherPoison : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherPoison";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherPoison.prefab";

		public override string NameLocalization => "$item_helmet_leather";

		public override string DescriptionLocalization => "$item_helmet_leather_description";
	}
}
namespace ChebsValheimLibrary.Items.Armor.Leather.Wolf
{
	public class HelmetLeatherWolf : Item
	{
		public override string ItemName => "ChebGonaz_HelmetLeatherWolf";

		public override string PrefabName => "ChebGonaz_HelmetLeatherWolf.prefab";

		public override string NameLocalization => "$item_helmet_leather_wolf";

		public override string DescriptionLocalization => "$item_helmet_leather_description_wolf";
	}
	public class SkeletonArmorLeatherChestWolf : Item
	{
		public override string ItemName => "ChebGonaz_ArmorLeatherChestWolf";

		public override string PrefabName => "ChebGonaz_ArmorLeatherChestWolf.prefab";

		public override string NameLocalization => "$item_chest_leather_wolf";

		public override string DescriptionLocalization => "$item_chest_leather_description_wolf";
	}
	public class SkeletonArmorLeatherLegsWolf : Item
	{
		public override string ItemName => "ChebGonaz_ArmorLeatherLegsWolf";

		public override string PrefabName => "ChebGonaz_ArmorLeatherLegsWolf.prefab";

		public override string NameLocalization => "$item_legs_leather_wolf";

		public override string DescriptionLocalization => "$item_legs_leather_description_wolf";
	}
	public class SkeletonHelmetLeatherPoisonWolf : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherPoisonWolf";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherPoisonWolf.prefab";

		public override string NameLocalization => "$item_helmet_leather_wolf_poison";

		public override string DescriptionLocalization => "$item_helmet_leather_wolf_poison_desc";
	}
	public class SkeletonHelmetLeatherWolf : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherWolf";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherWolf.prefab";

		public override string NameLocalization => "$item_helmet_leather_wolf";

		public override string DescriptionLocalization => "$item_helmet_leather_description_wolf";
	}
}
namespace ChebsValheimLibrary.Items.Armor.Leather.Troll
{
	public class SkeletonArmorLeatherChestTroll : Item
	{
		public override string ItemName => "ChebGonaz_ArmorLeatherChestTroll";

		public override string PrefabName => "ChebGonaz_ArmorLeatherChestTroll.prefab";

		public override string NameLocalization => "$item_chest_leather_troll";

		public override string DescriptionLocalization => "$item_chest_leather_description_troll";
	}
	public class SkeletonArmorLeatherLegsTroll : Item
	{
		public override string ItemName => "ChebGonaz_ArmorLeatherLegsTroll";

		public override string PrefabName => "ChebGonaz_ArmorLeatherLegsTroll.prefab";

		public override string NameLocalization => "$item_legs_leather_troll";

		public override string DescriptionLocalization => "$item_legs_leather_description_troll";
	}
	public class SkeletonHelmetLeatherPoisonTroll : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherPoisonTroll";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherPoisonTroll.prefab";

		public override string NameLocalization => "$item_helmet_leather_troll_poison";

		public override string DescriptionLocalization => "$item_helmet_leather_description_troll_poison";
	}
	public class SkeletonHelmetLeatherTroll : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherTroll";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherTroll.prefab";

		public override string NameLocalization => "$item_helmet_leather_troll";

		public override string DescriptionLocalization => "$item_helmet_leather_description_troll";
	}
}
namespace ChebsValheimLibrary.Items.Armor.Leather.Lox
{
	public class HelmetLeatherLox : Item
	{
		public override string ItemName => "ChebGonaz_HelmetLeatherLox";

		public override string PrefabName => "ChebGonaz_HelmetLeatherLox.prefab";

		public override string NameLocalization => "$item_helmet_leather_lox";

		public override string DescriptionLocalization => "$item_helmet_leather_description_lox";
	}
	public class SkeletonArmorLeatherChestLox : Item
	{
		public override string ItemName => "ChebGonaz_ArmorLeatherChestLox";

		public override string PrefabName => "ChebGonaz_ArmorLeatherChestLox.prefab";

		public override string NameLocalization => "$item_chest_leather_lox";

		public override string DescriptionLocalization => "$item_chest_leather_description_lox";
	}
	public class SkeletonArmorLeatherLegsLox : Item
	{
		public override string ItemName => "ChebGonaz_ArmorLeatherLegsLox";

		public override string PrefabName => "ChebGonaz_ArmorLeatherLegsLox.prefab";

		public override string NameLocalization => "$item_legs_leather_lox";

		public override string DescriptionLocalization => "$item_legs_leather_description_lox";
	}
	public class SkeletonHelmetLeatherLox : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherLox";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherLox.prefab";

		public override string NameLocalization => "$item_helmet_leather_lox";

		public override string DescriptionLocalization => "$item_helmet_leather_description_lox";
	}
	public class SkeletonHelmetLeatherPoisonLox : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetLeatherPoisonLox";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetLeatherPoisonLox.prefab";

		public override string NameLocalization => "$item_helmet_leather_troll_lox";

		public override string DescriptionLocalization => "$item_helmet_leather_description_lox_poison";
	}
	public class HelmetLeatherTroll : Item
	{
		public override string ItemName => "ChebGonaz_HelmetLeatherTroll";

		public override string PrefabName => "ChebGonaz_HelmetLeatherTroll.prefab";

		public override string NameLocalization => "$item_helmet_leather_troll";

		public override string DescriptionLocalization => "$item_helmet_leather_description_troll";
	}
}
namespace ChebsValheimLibrary.Items.Armor.Iron
{
	public class SkeletonHelmetIron : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetIron";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetIron.prefab";

		public override string NameLocalization => "$item_helmet_iron";

		public override string DescriptionLocalization => "$item_helmet_iron_description";
	}
	public class SkeletonHelmetIronPoison : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetIronPoison";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetIronPoison.prefab";

		public override string NameLocalization => "$item_helmet_iron";

		public override string DescriptionLocalization => "$item_helmet_iron_description";
	}
}
namespace ChebsValheimLibrary.Items.Armor.Bronze
{
	public class SkeletonHelmetBronze : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetBronze";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetBronze.prefab";

		public override string NameLocalization => "$item_helmet_bronze";

		public override string DescriptionLocalization => "$item_helmet_bronze_description";
	}
	public class SkeletonHelmetBronzePoison : Item
	{
		public override string ItemName => "ChebGonaz_SkeletonHelmetBronzePoison";

		public override string PrefabName => "ChebGonaz_SkeletonHelmetBronzePoison.prefab";

		public override string NameLocalization => "$item_helmet_bronze";

		public override string DescriptionLocalization => "$item_helmet_bronze_description";
	}
}
namespace ChebsValheimLibrary.Items.Armor.BlackMetal
{
	public class BlackIronChest : Item
	{
		public override string ItemName => "ChebGonaz_ArmorBlackIronChest";

		public override string PrefabName => "ChebGonaz_ArmorBlackIronChest.prefab";

		public override string NameLocalization => "$item_chebgonaz_blackironchest_name";

		public override string DescriptionLocalization => "$item_chebgonaz_blackironchest_desc";

		protected override string DefaultRecipe => "BlackMetal:5";
	}
	public class BlackIronHelmet : Item
	{
		public override string ItemName => "ChebGonaz_HelmetBlackIron";

		public override string PrefabName => "ChebGonaz_HelmetBlackIron.prefab";

		public override string NameLocalization => "$item_chebgonaz_blackironhelmet_name";

		public override string DescriptionLocalization => "$item_chebgonaz_blackironhelmet_desc";

		protected override string DefaultRecipe => "BlackMetal:5";
	}
	public class BlackIronLegs : Item
	{
		public override string ItemName => "ChebGonaz_ArmorBlackIronLegs";

		public override string PrefabName => "ChebGonaz_ArmorBlackIronLegs.prefab";

		public override string NameLocalization => "$item_chebgonaz_blackironlegs_name";

		public override string DescriptionLocalization => "$item_chebgonaz_blackironlegs_desc";

		protected override string DefaultRecipe => "BlackMetal:5";
	}
	public class SkeletonHelmetBlackIron : Item
	{
		public override string ItemName => "ChebGonaz_HelmetBlackIronSkeleton";

		public override string PrefabName => "ChebGonaz_HelmetBlackIronSkeleton.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonblackironhelmet_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonblackironhelmet_desc";
	}
	public class SkeletonHelmetBlackIronPoison : Item
	{
		public override string ItemName => "ChebGonaz_HelmetBlackIronSkeletonPoison";

		public override string PrefabName => "ChebGonaz_HelmetBlackIronSkeletonPoison.prefab";

		public override string NameLocalization => "$item_chebgonaz_skeletonblackironhelmet_name";

		public override string DescriptionLocalization => "$item_chebgonaz_skeletonblackironhelmet_desc";
	}
}
namespace ChebsValheimLibrary.Common
{
	public class ChebsRecipe
	{
		public string RecipeValue = "<Prefab1>:<quantity>[[,<PreFab2>:<quantity>], ...]";

		public ConfigEntry<bool> Allowed { get; set; }

		public ConfigEntry<string> CraftingCost { get; set; }

		public string DefaultRecipe { get; set; }

		public string PieceTable { get; set; }

		public string PieceCategory { get; set; }

		public string PieceName { get; set; }

		public string PieceDescription { get; set; }

		public string PrefabName { get; set; }

		public string IconName { get; set; }

		public string ObjectName { get; set; }

		public virtual void UpdateRecipe(ConfigEntry<string> craftingCost)
		{
			//IL_006f: 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)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			string text = PrefabName.Split(new char[1] { '.' })[0];
			Piece piece = PieceManager.Instance.GetPiece(text).Piece;
			List<Requirement> list = new List<Requirement>();
			string[] array = craftingCost.Value.Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string[] array2 = array[i].Split(new char[1] { ':' });
				string text2 = array2[0];
				int num = int.Parse(array2[1]);
				list.Add(new Requirement
				{
					m_amount = num,
					m_amountPerLevel = num * 2,
					m_resItem = ZNetScene.instance.GetPrefab(text2).GetComponent<ItemDrop>()
				});
			}
			piece.m_resources = list.ToArray();
		}

		public CustomPiece GetCustomPieceFromPrefab(GameObject prefab, Sprite icon, bool fixReference = true)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			PieceConfig val = new PieceConfig
			{
				Name = PieceName,
				Description = PieceDescription
			};
			if (Allowed.Value)
			{
				if (string.IsNullOrEmpty(CraftingCost.Value))
				{
					CraftingCost.Value = DefaultRecipe;
				}
				SetRecipeReqs(val, CraftingCost);
			}
			else
			{
				val.Enabled = false;
			}
			val.Icon = icon;
			val.PieceTable = PieceTable;
			val.Category = PieceCategory;
			CustomPiece val2 = new CustomPiece(prefab, fixReference, val);
			if ((Object)(object)val2.PiecePrefab == (Object)null)
			{
				Logger.LogError((object)("AddCustomPieces: " + PrefabName + "'s PiecePrefab is null!"));
				return null;
			}
			return val2;
		}

		private void SetRecipeReqs(PieceConfig config, ConfigEntry<string> craftingCost)
		{
			if (Enumerable.Contains(craftingCost.Value, ','))
			{
				string[] array = craftingCost.Value.Split(new char[1] { ',' });
				for (int i = 0; i < array.Length; i++)
				{
					addMaterial(array[i]);
				}
			}
			else
			{
				addMaterial(craftingCost.Value);
			}
			void addMaterial(string material)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				string[] array2 = material.Split(new char[1] { ':' });
				string text = array2[0];
				int num = int.Parse(array2[1]);
				config.AddRequirement(new RequirementConfig(text, num, 0, true));
			}
		}
	}
	public class InternalName : Attribute
	{
		public readonly string Name;

		public InternalName(string internalName)
		{
			Name = internalName;
		}

		public static string GetName(Enum value)
		{
			Type type = value.GetType();
			string name = Enum.GetName(type, value);
			return (type.GetField(name).GetCustomAttributes(typeof(InternalName), inherit: false).FirstOrDefault() as InternalName)?.Name ?? value.ToString();
		}
	}
	public class MemoryConfigEntry<T, TT>
	{
		private readonly Func<T, TT> _processValueFunc;

		private T _lastKnownValue;

		private TT _processedValue;

		private readonly ConfigEntry<T> _configEntry;

		public TT Value => _processedValue;

		public ConfigEntry<T> ConfigEntry => _configEntry;

		public MemoryConfigEntry(ConfigEntry<T> configEntry, Func<T, TT> processValueFunc)
		{
			_configEntry = configEntry;
			_processValueFunc = processValueFunc;
			_lastKnownValue = _configEntry.Value;
			_processedValue = _processValueFunc(_lastKnownValue);
			if (configEntry == null)
			{
				Logger.LogError((object)"MemoryConfigEntry: configEntry is null!");
			}
			else
			{
				_configEntry.SettingChanged += OnConfigEntryValueChanged;
			}
		}

		private void OnConfigEntryValueChanged(object sender, EventArgs args)
		{
			T value = _configEntry.Value;
			if (value == null)
			{
				Logger.LogError((object)"MemoryConfigEntry.OnConfigEntryValueChanged: value is null!");
			}
			else if (!EqualityComparer<T>.Default.Equals(value, _lastKnownValue))
			{
				Logger.LogInfo((object)$"MemoryConfigEntry.OnConfigEntryValueChanged: value is new! {value}");
				_lastKnownValue = value;
				_processedValue = _processValueFunc(value);
			}
		}
	}
	public static class Weather
	{
		public enum Env
		{
			None,
			[InternalName("Clear")]
			Clear,
			[InternalName("Twilight_Clear")]
			TwilightClear,
			[InternalName("Misty")]
			Misty,
			[InternalName("Darklands_dark")]
			DarklandsDark,
			[InternalName("Heath_clear")]
			HeathClear,
			[InternalName("DeepForest")]
			DeepForest,
			[InternalName("Mist")]
			Mist,
			[InternalName("GDKing")]
			GDKing,
			[InternalName("Rain")]
			Rain,
			[InternalName("LightRain")]
			LightRain,
			[InternalName("ThunderStorm")]
			ThunderStorm,
			[InternalName("Eikthyr")]
			Eikthyr,
			[InternalName("GoblinKing")]
			GoblinKing,
			[InternalName("nofogts")]
			Nofogts,
			[InternalName("SwampRain")]
			SwampRain,
			[InternalName("Bonemass")]
			Bonemass,
			[InternalName("Snow")]
			Snow,
			[InternalName("Twilight_Snow")]
			TwilightSnow,
			[InternalName("Twilight_SnowStorm")]
			TwilightSnowStorm,
			[InternalName("SnowStorm")]
			SnowStorm,
			[InternalName("Moder")]
			Moder,
			[InternalName("Ashrain")]
			Ashrain,
			[InternalName("Crypt")]
			Crypt,
			[InternalName("SunkenCrypt")]
			SunkenCrypt
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}

plugins/ChebsNecromancy.dll

Decompiled 4 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using ChebsNecromancy.Commands;
using ChebsNecromancy.Commands.Appearance;
using ChebsNecromancy.CustomPrefabs;
using ChebsNecromancy.Items.Armor.Minions;
using ChebsNecromancy.Items.Armor.Player;
using ChebsNecromancy.Items.Wands;
using ChebsNecromancy.Items.Weapons.Minions;
using ChebsNecromancy.Minions;
using ChebsNecromancy.Minions.Draugr;
using ChebsNecromancy.Minions.Skeletons;
using ChebsNecromancy.Minions.Skeletons.WorkerAI;
using ChebsNecromancy.Options;
using ChebsNecromancy.PvPOptions;
using ChebsNecromancy.Structures;
using ChebsValheimLibrary;
using ChebsValheimLibrary.Common;
using ChebsValheimLibrary.Items;
using ChebsValheimLibrary.Minions;
using ChebsValheimLibrary.Minions.AI;
using ChebsValheimLibrary.PvP;
using ChebsValheimLibrary.Structures;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.GUI;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using SimpleJson;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Cheb Gonaz")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("5.0.2.0")]
[assembly: AssemblyInformationalVersion("5.0.2.0+891d01c8d9d5c40abf9ea45d77b68c0ef0ed2821")]
[assembly: AssemblyProduct("Cheb's Necromancy")]
[assembly: AssemblyTitle("Cheb's Necromancy")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("5.0.2.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ChebsNecromancy
{
	[BepInPlugin("com.chebgonaz.ChebsNecromancy", "ChebsNecromancy", "5.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	internal class BasePlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.chebgonaz.ChebsNecromancy";

		public const string PluginName = "ChebsNecromancy";

		public const string PluginVersion = "5.0.2";

		private const string ConfigFileName = "com.chebgonaz.ChebsNecromancy.cfg";

		private static readonly string ConfigFileFullPath = Path.Combine(Paths.ConfigPath, "com.chebgonaz.ChebsNecromancy.cfg");

		public readonly Version ChebsValheimLibraryVersion = new Version("2.6.2");

		private readonly Harmony harmony = new Harmony("com.chebgonaz.ChebsNecromancy");

		public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

		private readonly List<Wand> wands = new List<Wand>
		{
			new SkeletonWand(),
			new DraugrWand(),
			new OrbOfBeckoning()
		};

		public const string NecromancySkillIdentifier = "friendlyskeletonwand_necromancy_skill";

		private readonly SpectralShroud spectralShroudItem = new SpectralShroud();

		private readonly NecromancerHood necromancersHoodItem = new NecromancerHood();

		private readonly NecromancerCape necromancerCapeItem = new NecromancerCape();

		private float inputDelay;

		public static SE_Stats SetEffectNecromancyArmor;

		public static SE_Stats SetEffectNecromancyArmor2;

		public AcceptableValueList<bool> BoolValue = new AcceptableValueList<bool>(new bool[2] { true, false });

		public AcceptableValueRange<float> FloatQuantityValue = new AcceptableValueRange<float>(1f, 1000f);

		public AcceptableValueRange<int> IntQuantityValue = new AcceptableValueRange<int>(1, 1000);

		public static ConfigEntry<bool> HeavyLogging;

		public static ConfigEntry<bool> PvPAllowed;

		public static ConfigEntry<bool> RadeonFriendly;

		public static ConfigEntry<bool> NoWraithSmoke;

		public static ConfigEntry<int> BoneFragmentsDroppedAmountMin;

		public static ConfigEntry<int> BoneFragmentsDroppedAmountMax;

		public static ConfigEntry<float> BoneFragmentsDroppedChance;

		public static ConfigEntry<int> ArmorLeatherScrapsRequiredConfig;

		public static ConfigEntry<int> ArmorBronzeRequiredConfig;

		public static ConfigEntry<int> ArmorIronRequiredConfig;

		public static ConfigEntry<int> ArmorBlackIronRequiredConfig;

		public static ConfigEntry<int> NeedlesRequiredConfig;

		public static ConfigEntry<bool> DurabilityDamage;

		public static ConfigEntry<float> DurabilityDamageWarrior;

		public static ConfigEntry<float> DurabilityDamageMage;

		public static ConfigEntry<float> DurabilityDamageArcher;

		public static ConfigEntry<float> DurabilityDamagePoison;

		public static ConfigEntry<float> DurabilityDamageLeather;

		public static ConfigEntry<float> DurabilityDamageBronze;

		public static ConfigEntry<float> DurabilityDamageIron;

		public static ConfigEntry<float> DurabilityDamageBlackIron;

		private bool _chebsMercenariesActive;

		private void Awake()
		{
			string text = default(string);
			if (!Base.VersionCheck(ChebsValheimLibraryVersion, ref text))
			{
				Logger.LogWarning((object)text);
			}
			CreateConfigValues();
			Phylactery.ConfigureRPC();
			PvPManager.ConfigureRPC();
			LoadChebGonazAssetBundle();
			PrefabManager.OnVanillaPrefabsAvailable += delegate
			{
				foreach (Material item in SkeletonMinion.Bones.Values.ToList())
				{
					PrefabExtension.FixReferences((object)item);
				}
			};
			harmony.PatchAll();
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new KillAllMinions());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SummonAllMinions());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new KillAllNeckros());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SetMinionOwnership());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SetNeckroHome());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new TeleportNeckros());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SetBoneColor());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new SetEyeColor());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new ShowOptions());
			foreach (ConsoleCommand pvpCommand in new List<ConsoleCommand>
			{
				(ConsoleCommand)(object)new PvPAddFriend(),
				(ConsoleCommand)(object)new PvPRemoveFriend(),
				(ConsoleCommand)(object)new PvPListFriends()
			})
			{
				if (!CommandManager.Instance.CustomCommands.ToList().Exists((ConsoleCommand c) => c.Name == pvpCommand.Name))
				{
					CommandManager.Instance.AddConsoleCommand(pvpCommand);
				}
			}
			((MonoBehaviour)this).StartCoroutine(Phylactery.PhylacteriesCheck());
			SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)((!attr.InitialSynchronization) ? "Syncing configuration changes from server..." : "Syncing initial configuration..."));
				UpdateAllRecipes();
				((MonoBehaviour)this).StartCoroutine(RequestPvPDict());
			};
			((MonoBehaviour)this).StartCoroutine(WatchConfigFile());
			_chebsMercenariesActive = Chainloader.PluginInfos.TryGetValue("com.chebgonaz.chebsmercenaries", out var _);
		}

		private IEnumerator RequestPvPDict()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)ZNet.instance != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null));
			PvPManager.InitialFriendsListRequest();
		}

		private byte[] GetFileHash(string fileName)
		{
			HashAlgorithm hashAlgorithm = HashAlgorithm.Create();
			using FileStream inputStream = new FileStream(fileName, FileMode.Open, FileAccess.Read);
			return hashAlgorithm.ComputeHash(inputStream);
		}

		private IEnumerator WatchConfigFile()
		{
			byte[] lastHash = GetFileHash(ConfigFileFullPath);
			while (true)
			{
				yield return (object)new WaitForSeconds(5f);
				byte[] fileHash = GetFileHash(ConfigFileFullPath);
				if (!fileHash.SequenceEqual(lastHash))
				{
					lastHash = fileHash;
					ReadConfigValues();
				}
			}
		}

		private void ReadConfigValues()
		{
			try
			{
				bool flag = ZNetExtension.IsServerInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Read updated config values (admin/local={flag})");
				if (flag)
				{
					((BaseUnityPlugin)this).Config.Reload();
				}
				UpdateAllRecipes();
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)string.Format("There was an issue loading your {0}: {1}", "com.chebgonaz.ChebsNecromancy.cfg", arg));
			}
		}

		private void UpdateAllRecipes()
		{
			wands.ForEach(delegate(Wand wand)
			{
				((Item)wand).UpdateRecipe();
			});
			((Item)necromancersHoodItem).UpdateRecipe();
			((Item)spectralShroudItem).UpdateRecipe();
			SpiritPylon.UpdateRecipe();
			RefuelerPylon.UpdateRecipe();
			NeckroGathererPylon.UpdateRecipe();
			BatBeacon.UpdateRecipe();
			FarmingPylon.UpdateRecipe();
			RepairPylon.UpdateRecipe();
			TreasurePylon.UpdateRecipe();
			Phylactery.UpdateRecipe();
		}

		public ConfigEntry<T> ModConfig<T>(string group, string name, T defaultValue, string description = "", AcceptableValueBase acceptableValues = null, bool serverSync = false, params object[] tags)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description + (serverSync ? " [Synced with Server]" : " [Not Synced with Server]"), acceptableValues, new object[2]
			{
				(object)new ConfigurationManagerAttributes
				{
					IsAdminOnly = serverSync
				},
				tags
			});
			return ((BaseUnityPlugin)this).Config.Bind<T>(group, name, defaultValue, val);
		}

		private void CreateConfigValues()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Expected O, but got Unknown
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Expected O, but got Unknown
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Expected O, but got Unknown
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Expected O, but got Unknown
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Expected O, but got Unknown
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Expected O, but got Unknown
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Expected O, but got Unknown
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Expected O, but got Unknown
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Expected O, but got Unknown
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Expected O, but got Unknown
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Expected O, but got Unknown
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Expected O, but got Unknown
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Expected O, but got Unknown
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Expected O, but got Unknown
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Expected O, but got Unknown
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Expected O, but got Unknown
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Expected O, but got Unknown
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Expected O, but got Unknown
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Expected O, but got Unknown
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Expected O, but got Unknown
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Expected O, but got Unknown
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			HeavyLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("General (Client)", "HeavyLogging", false, new ConfigDescription("Switch on to fill the logs with excessive logging to assist with debugging.", (AcceptableValueBase)null, Array.Empty<object>()));
			PvPAllowed = ((BaseUnityPlugin)this).Config.Bind<bool>("General (Server Synced)", "PvPAllowed", false, new ConfigDescription("Whether minions will target and attack other players and their minions.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			RadeonFriendly = ((BaseUnityPlugin)this).Config.Bind<bool>("General (Client)", "RadeonFriendly", false, new ConfigDescription("ONLY set this to true if you have graphical issues with the mod. It will disable all particle effects for the mod's prefabs which seem to give users with Radeon cards trouble for unknown reasons. If you have problems with lag it might also help to switchthis setting on.", (AcceptableValueBase)null, Array.Empty<object>()));
			OptionsGUI.CreateConfigs((BaseUnityPlugin)(object)this, "com.chebgonaz.ChebsNecromancy");
			NoWraithSmoke = ((BaseUnityPlugin)this).Config.Bind<bool>("General (Client)", "NoWraithSmoke", false, new ConfigDescription("Set this to true if you want to disable smoke on the wraith.", (AcceptableValueBase)null, Array.Empty<object>()));
			BoneFragmentsDroppedAmountMin = ((BaseUnityPlugin)this).Config.Bind<int>("General (Server Synced)", "BoneFragmentsDroppedAmountMin", 1, new ConfigDescription("The minimum amount of bones dropped by creatures.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			BoneFragmentsDroppedAmountMax = ((BaseUnityPlugin)this).Config.Bind<int>("General (Server Synced)", "BoneFragmentsDroppedAmountMax", 3, new ConfigDescription("The maximum amount of bones dropped by creatures.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			BoneFragmentsDroppedChance = ((BaseUnityPlugin)this).Config.Bind<float>("General (Server Synced)", "BoneFragmentsDroppedChance", 0.25f, new ConfigDescription("The chance of bones dropped by creatures (0 = 0%, 1 = 100%).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			ArmorLeatherScrapsRequiredConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General (Server Synced)", "ArmorLeatherScrapsRequired", 2, new ConfigDescription("The amount of LeatherScraps required to craft a minion in leather armor.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			ArmorBronzeRequiredConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General (Server Synced)", "ArmorBronzeRequired", 1, new ConfigDescription("The amount of Bronze required to craft a minion in bronze armor.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			ArmorIronRequiredConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General (Server Synced)", "ArmoredIronRequired", 1, new ConfigDescription("The amount of Iron required to craft a minion in iron armor.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			ArmorBlackIronRequiredConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General (Server Synced)", "ArmorBlackIronRequired", 1, new ConfigDescription("The amount of Black Metal required to craft a minion in black iron armor.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			NeedlesRequiredConfig = ((BaseUnityPlugin)this).Config.Bind<int>("General (Server Synced)", "NeedlesRequired", 5, new ConfigDescription("The amount of needles required to craft a needle warrior.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DurabilityDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("General (Server Synced)", "DurabilityDamage", true, new ConfigDescription("Whether using a wand damages its durability.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DurabilityDamageWarrior = ((BaseUnityPlugin)this).Config.Bind<float>("General (Server Synced)", "DurabilityDamageWarrior", 1f, new ConfigDescription("How much creating a warrior damages a wand.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DurabilityDamageArcher = ((BaseUnityPlugin)this).Config.Bind<float>("General (Server Synced)", "DurabilityDamageArcher", 3f, new ConfigDescription("How much creating an archer damages a wand.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DurabilityDamageMage = ((BaseUnityPlugin)this).Config.Bind<float>("General (Server Synced)", "DurabilityDamageMage", 5f, new ConfigDescription("How much creating a mage damages a wand.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DurabilityDamagePoison = ((BaseUnityPlugin)this).Config.Bind<float>("General (Server Synced)", "DurabilityDamagePoison", 5f, new ConfigDescription("How much creating a poison skeleton damages a wand.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DurabilityDamageLeather = ((BaseUnityPlugin)this).Config.Bind<float>("General (Server Synced)", "DurabilityDamageLeather", 1f, new ConfigDescription("How much armoring the minion in leather damages the wand (value is added on top of damage from minion type).", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DurabilityDamageBronze = ((BaseUnityPlugin)this).Config.Bind<float>("General (Server Synced)", "DurabilityDamageBronze", 1f, new ConfigDescription("How much armoring the minion in bronze damages the wand (value is added on top of damage from minion type)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DurabilityDamageIron = ((BaseUnityPlugin)this).Config.Bind<float>("General (Server Synced)", "DurabilityDamageIron", 1f, new ConfigDescription("How much armoring the minion in iron damages the wand (value is added on top of damage from minion type)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DurabilityDamageBlackIron = ((BaseUnityPlugin)this).Config.Bind<float>("General (Server Synced)", "DurabilityDamageBlackIron", 1f, new ConfigDescription("How much armoring the minion in black iron damages the wand (value is added on top of damage from minion type)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			UndeadMinion.CreateConfigs((BaseUnityPlugin)(object)this);
			SkeletonMinion.CreateConfigs((BaseUnityPlugin)(object)this);
			PoisonSkeletonMinion.CreateConfigs(this);
			SkeletonArcherFireMinion.CreateConfigs(this);
			SkeletonArcherFrostMinion.CreateConfigs(this);
			SkeletonArcherPoisonMinion.CreateConfigs(this);
			SkeletonArcherSilverMinion.CreateConfigs(this);
			SkeletonArcherTier1Minion.CreateConfigs(this);
			SkeletonArcherTier2Minion.CreateConfigs(this);
			SkeletonArcherTier3Minion.CreateConfigs(this);
			SkeletonMageMinion.CreateConfigs(this);
			SkeletonWarriorMinion.CreateConfigs(this);
			SkeletonWoodcutterMinion.CreateConfigs(this);
			SkeletonMinerMinion.CreateConfigs(this);
			SkeletonPriestMinion.CreateConfigs(this);
			DraugrMinion.CreateConfigs((BaseUnityPlugin)(object)this);
			DraugrWarriorMinion.CreateConfigs(this);
			DraugrArcherFireMinion.CreateConfigs(this);
			DraugrArcherFrostMinion.CreateConfigs(this);
			DraugrArcherPoisonMinion.CreateConfigs(this);
			DraugrArcherSilverMinion.CreateConfigs(this);
			DraugrArcherTier1Minion.CreateConfigs(this);
			DraugrArcherTier2Minion.CreateConfigs(this);
			DraugrArcherTier3Minion.CreateConfigs(this);
			GuardianWraithMinion.CreateConfigs((BaseUnityPlugin)(object)this);
			LeechMinion.CreateConfigs(this);
			BattleNeckroMinion.CreateConfigs(this);
			wands.ForEach(delegate(Wand w)
			{
				((Item)w).CreateConfigs((BaseUnityPlugin)(object)this);
			});
			((Item)spectralShroudItem).CreateConfigs((BaseUnityPlugin)(object)this);
			((Item)necromancersHoodItem).CreateConfigs((BaseUnityPlugin)(object)this);
			SpiritPylon.CreateConfigs(this);
			RefuelerPylon.CreateConfigs(this);
			NeckroGathererPylon.CreateConfigs(this);
			BatBeacon.CreateConfigs(this);
			BatLantern.CreateConfigs(this);
			FarmingPylon.CreateConfigs(this);
			RepairPylon.CreateConfigs(this);
			TreasurePylon.CreateConfigs(this);
			Phylactery.CreateConfigs(this);
			NeckroGathererMinion.CreateConfigs((BaseUnityPlugin)(object)this);
			PvPOptionsGUI.CreateConfigs((BaseUnityPlugin)(object)this, "com.chebgonaz.ChebsNecromancy");
		}

		private void LoadChebGonazAssetBundle()
		{
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Expected O, but got Unknown
			string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			if (directoryName == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Unable to load asset bundle: Failed to get mod directory");
				return;
			}
			string text = Path.Combine(directoryName, "chebgonaz");
			if (!File.Exists(text))
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Unable to load asset bundle: File doesn't exist " + text));
				return;
			}
			AssetBundle chebgonazAssetBundle = AssetUtils.LoadAssetBundle(text);
			try
			{
				SetEffectNecromancyArmor = LoadSetEffectFromBundle("SetEffect_NecromancyArmor", chebgonazAssetBundle);
				SetEffectNecromancyArmor2 = LoadSetEffectFromBundle("SetEffect_NecromancyArmor2", chebgonazAssetBundle);
				foreach (string item in new List<string> { "sfx_orbofbeckoning_launch" })
				{
					GameObject val = Base.LoadPrefabFromBundle(item, chebgonazAssetBundle, RadeonFriendly.Value);
					PrefabManager.Instance.AddPrefab(val);
				}
				GameObject val2 = Base.LoadPrefabFromBundle(((Item)spectralShroudItem).PrefabName, chebgonazAssetBundle, RadeonFriendly.Value);
				ItemManager.Instance.AddItem(((Item)spectralShroudItem).GetCustomItemFromPrefab(val2, true));
				GameObject val3 = Base.LoadPrefabFromBundle(((Item)necromancersHoodItem).PrefabName, chebgonazAssetBundle, RadeonFriendly.Value);
				ItemManager.Instance.AddItem(((Item)necromancersHoodItem).GetCustomItemFromPrefab(val3, true));
				SkeletonPriestHoodItem skeletonPriestHoodItem = new SkeletonPriestHoodItem();
				GameObject val4 = Base.LoadPrefabFromBundle(((Item)skeletonPriestHoodItem).PrefabName, chebgonazAssetBundle, RadeonFriendly.Value);
				ItemManager.Instance.AddItem(((Item)skeletonPriestHoodItem).GetCustomItemFromPrefab(val4, true));
				List<Item> list = new List<Item>();
				list.Add((Item)(object)new SkeletonPriestHealLevel1Item());
				list.Add((Item)(object)new SkeletonPriestHealLevel2Item());
				list.Add((Item)(object)new SkeletonPriestHealLevel3Item());
				list.ForEach(delegate(Item healItem)
				{
					GameObject val18 = Base.LoadPrefabFromBundle(healItem.PrefabName, chebgonazAssetBundle, RadeonFriendly.Value);
					ItemManager.Instance.AddItem(healItem.GetCustomItemFromPrefab(val18, true));
				});
				NecromancerCape.LoadEmblems(chebgonazAssetBundle);
				GameObject orbOfBeckoningProjectilePrefab = Base.LoadPrefabFromBundle("ChebGonaz_OrbOfBeckoningProjectile.prefab", chebgonazAssetBundle, RadeonFriendly.Value);
				orbOfBeckoningProjectilePrefab.AddComponent<OrbOfBeckoningProjectile>();
				Base.LoadMinionItems(chebgonazAssetBundle, RadeonFriendly.Value);
				wands.ForEach(delegate(Wand wand)
				{
					GameObject val17 = Base.LoadPrefabFromBundle(((Item)wand).PrefabName, chebgonazAssetBundle, RadeonFriendly.Value);
					wand.CreateButtons();
					KeyHintManager.Instance.AddKeyHint(wand.GetKeyHint());
					if (wand is OrbOfBeckoning)
					{
						val17.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackProjectile = orbOfBeckoningProjectilePrefab;
					}
					ItemManager.Instance.AddItem(((Item)wand).GetCustomItemFromPrefab(val17, true));
				});
				GameObject val5 = Base.LoadPrefabFromBundle("ChebGonaz_LargeCargoCrate.prefab", chebgonazAssetBundle, RadeonFriendly.Value);
				PrefabManager.Instance.AddPrefab(new CustomPrefab(val5, false));
				UndeadMinion.LoadEyes(chebgonazAssetBundle);
				SkeletonMinion.LoadBoneColors(chebgonazAssetBundle);
				List<string> list2 = new List<string>();
				foreach (DraugrMinion.DraugrType value in Enum.GetValues(typeof(DraugrMinion.DraugrType)))
				{
					if (value != 0)
					{
						list2.Add(InternalName.GetName((Enum)value) + ".prefab");
					}
				}
				foreach (SkeletonMinion.SkeletonType value2 in Enum.GetValues(typeof(SkeletonMinion.SkeletonType)))
				{
					if (value2 != 0)
					{
						list2.Add(InternalName.GetName((Enum)value2) + ".prefab");
					}
				}
				list2.Add("ChebGonaz_GuardianWraith.prefab");
				list2.Add("ChebGonaz_SpiritPylonGhost.prefab");
				list2.Add("ChebGonaz_NeckroGatherer.prefab");
				list2.Add("ChebGonaz_Bat.prefab");
				list2.Add("ChebGonaz_BattleNeckro.prefab");
				foreach (LeechMinion.LeechType value3 in Enum.GetValues(typeof(LeechMinion.LeechType)))
				{
					if (value3 != 0)
					{
						list2.Add(InternalName.GetName((Enum)value3) + ".prefab");
					}
				}
				list2.ForEach(delegate(string prefabName)
				{
					//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
					//IL_06f7: Expected O, but got Unknown
					if (HeavyLogging.Value)
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Loading " + prefabName + " from asset bundle..."));
					}
					GameObject val16 = Base.LoadPrefabFromBundle(prefabName, chebgonazAssetBundle, RadeonFriendly.Value || (NoWraithSmoke.Value && prefabName.Equals("ChebGonaz_GuardianWraith.prefab")));
					switch (prefabName)
					{
					case "ChebGonaz_DraugrWarrior.prefab":
					case "ChebGonaz_DraugrWarriorTier2.prefab":
					case "ChebGonaz_DraugrWarriorTier3.prefab":
					case "ChebGonaz_DraugrWarriorTier4.prefab":
					case "ChebGonaz_DraugrWarriorNeedle.prefab":
						val16.AddComponent<DraugrWarriorMinion>();
						break;
					case "ChebGonaz_DraugrArcher.prefab":
						val16.AddComponent<DraugrArcherTier1Minion>();
						break;
					case "ChebGonaz_DraugrArcherTier2.prefab":
						val16.AddComponent<DraugrArcherTier2Minion>();
						break;
					case "ChebGonaz_DraugrArcherTier3.prefab":
						val16.AddComponent<DraugrArcherTier3Minion>();
						break;
					case "ChebGonaz_DraugrArcherPoison.prefab":
						val16.AddComponent<DraugrArcherPoisonMinion>();
						break;
					case "ChebGonaz_DraugrArcherFire.prefab":
						val16.AddComponent<DraugrArcherFireMinion>();
						break;
					case "ChebGonaz_DraugrArcherFrost.prefab":
						val16.AddComponent<DraugrArcherFrostMinion>();
						break;
					case "ChebGonaz_DraugrArcherSilver.prefab":
						val16.AddComponent<DraugrArcherSilverMinion>();
						break;
					case "ChebGonaz_SkeletonWarrior.prefab":
					case "ChebGonaz_SkeletonWarriorTier2.prefab":
					case "ChebGonaz_SkeletonWarriorTier3.prefab":
					case "ChebGonaz_SkeletonWarriorTier4.prefab":
					case "ChebGonaz_SkeletonWarriorNeedle.prefab":
						val16.AddComponent<SkeletonWarriorMinion>();
						break;
					case "ChebGonaz_SkeletonArcher.prefab":
						val16.AddComponent<SkeletonArcherTier1Minion>();
						break;
					case "ChebGonaz_SkeletonArcherTier2.prefab":
						val16.AddComponent<SkeletonArcherTier2Minion>();
						break;
					case "ChebGonaz_SkeletonArcherTier3.prefab":
						val16.AddComponent<SkeletonArcherTier3Minion>();
						break;
					case "ChebGonaz_SkeletonArcherPoison.prefab":
						val16.AddComponent<SkeletonArcherPoisonMinion>();
						break;
					case "ChebGonaz_SkeletonArcherFire.prefab":
						val16.AddComponent<SkeletonArcherFireMinion>();
						break;
					case "ChebGonaz_SkeletonArcherFrost.prefab":
						val16.AddComponent<SkeletonArcherFrostMinion>();
						break;
					case "ChebGonaz_SkeletonArcherSilver.prefab":
						val16.AddComponent<SkeletonArcherSilverMinion>();
						break;
					case "ChebGonaz_SkeletonMage.prefab":
					case "ChebGonaz_SkeletonMageTier2.prefab":
					case "ChebGonaz_SkeletonMageTier3.prefab":
						val16.AddComponent<SkeletonMageMinion>();
						break;
					case "ChebGonaz_PoisonSkeleton2.prefab":
					case "ChebGonaz_PoisonSkeleton3.prefab":
					case "ChebGonaz_PoisonSkeleton.prefab":
						val16.AddComponent<PoisonSkeletonMinion>();
						break;
					case "ChebGonaz_SkeletonWoodcutter.prefab":
						val16.AddComponent<SkeletonWoodcutterMinion>();
						break;
					case "ChebGonaz_SkeletonMiner.prefab":
						val16.AddComponent<SkeletonMinerMinion>();
						break;
					case "ChebGonaz_GuardianWraith.prefab":
						val16.AddComponent<GuardianWraithMinion>();
						break;
					case "ChebGonaz_SpiritPylonGhost.prefab":
						val16.AddComponent<SpiritPylonGhostMinion>();
						break;
					case "ChebGonaz_NeckroGatherer.prefab":
						val16.AddComponent<NeckroGathererMinion>();
						break;
					case "ChebGonaz_Bat.prefab":
						val16.AddComponent<BatBeaconBatMinion>();
						break;
					case "ChebGonaz_BattleNeckro.prefab":
						val16.AddComponent<BattleNeckroMinion>();
						break;
					case "ChebGonaz_Leech.prefab":
						val16.AddComponent<LeechMinion>();
						break;
					case "ChebGonaz_SkeletonPriestTier2.prefab":
					case "ChebGonaz_SkeletonPriestTier3.prefab":
					case "ChebGonaz_SkeletonPriest.prefab":
						val16.AddComponent<SkeletonPriestMinion>();
						break;
					default:
						((BaseUnityPlugin)this).Logger.LogError((object)("Unknown prefab " + prefabName));
						break;
					}
					CreatureManager.Instance.AddCreature(new CustomCreature(val16, true));
				});
				GameObject val6 = chebgonazAssetBundle.LoadAsset<GameObject>(SpiritPylon.ChebsRecipeConfig.PrefabName);
				val6.AddComponent<SpiritPylon>();
				PieceManager.Instance.AddPiece(SpiritPylon.ChebsRecipeConfig.GetCustomPieceFromPrefab(val6, chebgonazAssetBundle.LoadAsset<Sprite>(SpiritPylon.ChebsRecipeConfig.IconName), true));
				GameObject val7 = chebgonazAssetBundle.LoadAsset<GameObject>(RefuelerPylon.ChebsRecipeConfig.PrefabName);
				val7.AddComponent<RefuelerPylon>();
				PieceManager.Instance.AddPiece(RefuelerPylon.ChebsRecipeConfig.GetCustomPieceFromPrefab(val7, chebgonazAssetBundle.LoadAsset<Sprite>(RefuelerPylon.ChebsRecipeConfig.IconName), true));
				GameObject val8 = chebgonazAssetBundle.LoadAsset<GameObject>(NeckroGathererPylon.ChebsRecipeConfig.PrefabName);
				val8.AddComponent<NeckroGathererPylon>();
				PieceManager.Instance.AddPiece(NeckroGathererPylon.ChebsRecipeConfig.GetCustomPieceFromPrefab(val8, chebgonazAssetBundle.LoadAsset<Sprite>(NeckroGathererPylon.ChebsRecipeConfig.IconName), true));
				GameObject val9 = chebgonazAssetBundle.LoadAsset<GameObject>(BatBeacon.ChebsRecipeConfig.PrefabName);
				val9.AddComponent<BatBeacon>();
				PieceManager.Instance.AddPiece(BatBeacon.ChebsRecipeConfig.GetCustomPieceFromPrefab(val9, chebgonazAssetBundle.LoadAsset<Sprite>(BatBeacon.ChebsRecipeConfig.IconName), true));
				GameObject val10 = chebgonazAssetBundle.LoadAsset<GameObject>(BatLantern.ChebsRecipeConfig.PrefabName);
				val10.AddComponent<BatLantern>();
				PieceManager.Instance.AddPiece(BatLantern.ChebsRecipeConfig.GetCustomPieceFromPrefab(val10, chebgonazAssetBundle.LoadAsset<Sprite>(BatLantern.ChebsRecipeConfig.IconName), true));
				GameObject val11 = chebgonazAssetBundle.LoadAsset<GameObject>(FarmingPylon.ChebsRecipeConfig.PrefabName);
				val11.AddComponent<FarmingPylon>();
				PieceManager.Instance.AddPiece(FarmingPylon.ChebsRecipeConfig.GetCustomPieceFromPrefab(val11, chebgonazAssetBundle.LoadAsset<Sprite>(FarmingPylon.ChebsRecipeConfig.IconName), true));
				GameObject val12 = chebgonazAssetBundle.LoadAsset<GameObject>(RepairPylon.ChebsRecipeConfig.PrefabName);
				val12.AddComponent<RepairPylon>();
				PieceManager.Instance.AddPiece(RepairPylon.ChebsRecipeConfig.GetCustomPieceFromPrefab(val12, chebgonazAssetBundle.LoadAsset<Sprite>(RepairPylon.ChebsRecipeConfig.IconName), true));
				GameObject val13 = chebgonazAssetBundle.LoadAsset<GameObject>(TreasurePylon.ChebsRecipeConfig.PrefabName);
				val13.AddComponent<TreasurePylon>();
				PieceManager.Instance.AddPiece(TreasurePylon.ChebsRecipeConfig.GetCustomPieceFromPrefab(val13, chebgonazAssetBundle.LoadAsset<Sprite>(TreasurePylon.ChebsRecipeConfig.IconName), true));
				GameObject val14 = chebgonazAssetBundle.LoadAsset<GameObject>("ChebGonaz_TreasurePylonEffect");
				PrefabManager.Instance.AddPrefab(val14);
				GameObject val15 = chebgonazAssetBundle.LoadAsset<GameObject>(Phylactery.ChebsRecipeConfig.PrefabName);
				val15.AddComponent<Phylactery>();
				PieceManager.Instance.AddPiece(Phylactery.ChebsRecipeConfig.GetCustomPieceFromPrefab(val15, chebgonazAssetBundle.LoadAsset<Sprite>(Phylactery.ChebsRecipeConfig.IconName), true));
				Sprite iconSprite = chebgonazAssetBundle.LoadAsset<Sprite>("necromancy_icon.png");
				AddNecromancy(iconSprite);
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while loading assets: {arg}");
			}
			finally
			{
				chebgonazAssetBundle.Unload(false);
			}
			static SE_Stats LoadSetEffectFromBundle(string setEffectName, AssetBundle bundle)
			{
				SE_Stats obj = bundle.LoadAsset<SE_Stats>(setEffectName);
				if ((Object)(object)obj == (Object)null)
				{
					Logger.LogError((object)("LoadSetEffectFromBundle: " + setEffectName + " is null!"));
				}
				return obj;
			}
		}

		private void AddNecromancy(Sprite iconSprite)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002e: Expected O, but got Unknown
			//IL_0034: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			SkillConfig val = new SkillConfig
			{
				Name = "$friendlyskeletonwand_necromancy",
				Description = "$friendlyskeletonwand_necromancy_desc",
				Icon = iconSprite,
				Identifier = "friendlyskeletonwand_necromancy_skill"
			};
			SkillManager.Instance.AddSkill(val);
			SetEffectNecromancyArmor.m_skillLevel = SkillManager.Instance.GetSkill("friendlyskeletonwand_necromancy_skill").m_skill;
			SetEffectNecromancyArmor.m_skillLevelModifier = SpectralShroud.NecromancySkillBonus.Value;
			SetEffectNecromancyArmor2.m_skillLevel = SkillManager.Instance.GetSkill("friendlyskeletonwand_necromancy_skill").m_skill;
			SetEffectNecromancyArmor2.m_skillLevelModifier = NecromancerHood.NecromancySkillBonus.Value;
		}

		private void Update()
		{
			if (ZInput.instance != null)
			{
				if (Time.time > inputDelay)
				{
					wands.ForEach(delegate(Wand wand)
					{
						if (wand.HandleInputs())
						{
							inputDelay = Time.time + 0.5f;
						}
					});
				}
				if (OptionsGUI.OptionsButton != null && ZInput.GetButtonUp(OptionsGUI.OptionsButton.Name))
				{
					OptionsGUI.TogglePanel();
				}
				if (!_chebsMercenariesActive && PvPOptionsGUI.OptionsButton != null && ZInput.GetButtonUp(PvPOptionsGUI.OptionsButton.Name))
				{
					PvPOptionsGUI.TogglePanel();
				}
			}
			((Item)spectralShroudItem).DoOnUpdate();
		}
	}
}
namespace ChebsNecromancy.Structures
{
	internal class BatBeacon : Structure
	{
		public static ConfigEntry<float> SightRadius;

		public static ConfigEntry<float> BatDuration;

		public static ConfigEntry<float> DelayBetweenBats;

		public static ConfigEntry<int> MaxBats;

		protected List<GameObject> SpawnedBats = new List<GameObject>();

		private float batLastSpawnedAt;

		public static ChebsRecipe ChebsRecipeConfig = new ChebsRecipe
		{
			DefaultRecipe = "FineWood:10,Silver:5,Guck:15",
			IconName = "chebgonaz_batpylon_icon.png",
			PieceTable = "_HammerPieceTable",
			PieceCategory = "Misc",
			PieceName = "$chebgonaz_batbeacon_name",
			PieceDescription = "$chebgonaz_batbeacon_desc",
			PrefabName = "ChebGonaz_BatBeacon.prefab",
			ObjectName = MethodBase.GetCurrentMethod().DeclaringType.Name
		};

		public static void UpdateRecipe()
		{
			ChebsRecipeConfig.UpdateRecipe(ChebsRecipeConfig.CraftingCost);
		}

		public static void CreateConfigs(BasePlugin plugin)
		{
			ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BatBeaconAllowed", true, "Whether making a Spirit Pylon is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BatBeaconBuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build the bat beacon. None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true);
			SightRadius = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BatBeaconSightRadius", 30f, "How far a bat beacon can see enemies.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			BatDuration = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BatBeaconGhostDuration", 30f, "How long a bat persists.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			DelayBetweenBats = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BatBeaconDelayBetweenBats", 0.5f, "How long a bat beacon wait before being able to spawn another bat.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			MaxBats = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BatBeaconMaxBats", 15, "The maximum number of bats that a bat beacon can spawn.", (AcceptableValueBase)(object)plugin.IntQuantityValue, true);
		}

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(LookForEnemies());
		}

		private IEnumerator LookForEnemies()
		{
			Piece piece = ((Component)this).GetComponent<Piece>();
			yield return (object)new WaitWhile((Func<bool>)(() => !piece.IsPlacedByPlayer()));
			Character target = default(Character);
			while (true)
			{
				yield return (object)new WaitForSeconds(2f);
				if (!piece.m_nview.IsOwner())
				{
					continue;
				}
				for (int num = SpawnedBats.Count - 1; num >= 0; num--)
				{
					if ((Object)(object)SpawnedBats[num] == (Object)null)
					{
						SpawnedBats.RemoveAt(num);
					}
				}
				if (((Structure)this).EnemiesNearby(ref target, SightRadius.Value) && SpawnedBats.Count < MaxBats.Value && Time.time > batLastSpawnedAt + DelayBetweenBats.Value)
				{
					batLastSpawnedAt = Time.time;
					GameObject val = SpawnFriendlyBat();
					val.GetComponent<MonsterAI>().SetTarget(target);
					SpawnedBats.Add(val);
				}
			}
		}

		protected GameObject SpawnFriendlyBat()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			int level = 1;
			string text = "ChebGonaz_Bat";
			GameObject prefab = ZNetScene.instance.GetPrefab(text);
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				Logger.LogError((object)("spawning " + text + " failed!"));
				return null;
			}
			GameObject obj = Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position + ((Component)this).transform.forward * 2f + Vector3.up, Quaternion.identity);
			obj.GetComponent<Character>().SetLevel(level);
			return obj;
		}
	}
	internal class BatLantern : BatBeacon
	{
		public new static readonly ChebsRecipe ChebsRecipeConfig = new ChebsRecipe
		{
			DefaultRecipe = "FineWood:10,Silver:5,Guck:15",
			IconName = "chebgonaz_batlantern_icon.png",
			PieceTable = "_HammerPieceTable",
			PieceCategory = "Misc",
			PieceName = "$chebgonaz_batlantern_name",
			PieceDescription = "$chebgonaz_batlantern_desc",
			PrefabName = "ChebGonaz_BatLantern.prefab",
			ObjectName = MethodBase.GetCurrentMethod().DeclaringType.Name
		};

		public new static void CreateConfigs(BasePlugin plugin)
		{
			ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BatLanternAllowed", true, "Whether making a bat lantern is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BatLanternBuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build the bat lantern. None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true);
		}
	}
	internal class FarmingPylon : Structure
	{
		public static ConfigEntry<float> SightRadius;

		public static ConfigEntry<float> UpdateInterval;

		public static MemoryConfigEntry<string, List<string>> PickableList;

		private const string DefaultPickables = "Pickable_Barley,Pickable_Barley_Wild,Pickable_Carrot,Pickable_Dandelion,Pickable_Flax,Pickable_Flax_Wild,Pickable_Mushroom,Pickable_Mushroom_blue,Pickable_Mushroom_JotunPuffs,Pickable_Mushroom_Magecap,Pickable_Mushroom_yellow,Pickable_Onion,Pickable_SeedCarrot,Pickable_SeedOnion,Pickable_SeedTurnip,Pickable_Thistle,Pickable_Turnip";

		private int _itemMask;

		private int _pieceMaskNonSolid;

		public static ChebsRecipe ChebsRecipeConfig = new ChebsRecipe
		{
			DefaultRecipe = "FineWood:15,IronNails:15,SurtlingCore:1",
			IconName = "chebgonaz_farmingpylon_icon.png",
			PieceTable = "_HammerPieceTable",
			PieceCategory = "Misc",
			PieceName = "$chebgonaz_farmingpylon_name",
			PieceDescription = "$chebgonaz_farmingpylon_desc",
			PrefabName = "ChebGonaz_FarmingPylon.prefab",
			ObjectName = MethodBase.GetCurrentMethod().DeclaringType.Name
		};

		public static void CreateConfigs(BasePlugin plugin)
		{
			ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "FarmingPylonAllowed", true, "Whether making a Farming Pylon is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "FarmingPylonBuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build a Farming Pylon. None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true);
			SightRadius = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "FarmingPylonSightRadius", 30f, "How far a Farming Pylon can reach  and crops.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			UpdateInterval = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "FarmingPylonUpdateInterval", 5f, "How long a Farming Pylon waits between checking containers and crops (lower values may negatively impact performance).", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			PickableList = new MemoryConfigEntry<string, List<string>>(plugin.ModConfig(ChebsRecipeConfig.ObjectName, "FarmingPylonPickableList", "Pickable_Barley,Pickable_Barley_Wild,Pickable_Carrot,Pickable_Dandelion,Pickable_Flax,Pickable_Flax_Wild,Pickable_Mushroom,Pickable_Mushroom_blue,Pickable_Mushroom_JotunPuffs,Pickable_Mushroom_Magecap,Pickable_Mushroom_yellow,Pickable_Onion,Pickable_SeedCarrot,Pickable_SeedOnion,Pickable_SeedTurnip,Pickable_Thistle,Pickable_Turnip", "A list of pickable IDs.", null, true), (Func<string, List<string>>)((string s) => (from str in s?.Split(new char[1] { ',' })
				select str.Trim()).ToList()));
		}

		public static void UpdateRecipe()
		{
			ChebsRecipeConfig.UpdateRecipe(ChebsRecipeConfig.CraftingCost);
		}

		private void Awake()
		{
			_itemMask = LayerMask.GetMask(new string[1] { "item" });
			_pieceMaskNonSolid = LayerMask.GetMask(new string[1] { "piece_nonsolid" });
			ArmorStand armorStand = default(ArmorStand);
			if (((Component)this).TryGetComponent<ArmorStand>(ref armorStand))
			{
				armorStand.m_slots.ForEach(delegate(ArmorStandSlot slot)
				{
					slot.m_switch.m_hoverText = armorStand.m_name;
				});
			}
			((MonoBehaviour)this).StartCoroutine(LookForCrops());
		}

		private IEnumerator LookForCrops()
		{
			Piece piece = ((Component)this).GetComponent<Piece>();
			yield return (object)new WaitWhile((Func<bool>)(() => !piece.IsPlacedByPlayer()));
			while (true)
			{
				yield return (object)new WaitForSeconds(UpdateInterval.Value);
				if (!piece.m_nview.IsOwner())
				{
					continue;
				}
				List<Player> playersInRange = new List<Player>();
				Player.GetPlayersInRange(((Component)this).transform.position, 150f, playersInRange);
				if (playersInRange.Count >= 1)
				{
					yield return (object)new WaitWhile((Func<bool>)(() => playersInRange[0].IsSleeping()));
					PickPickables();
				}
			}
		}

		private void PickPickables()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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)
			Vector3 position = ((Component)this).transform.position;
			Collider[] array = Physics.OverlapSphere(position, SightRadius.Value, _pieceMaskNonSolid).Concat(Physics.OverlapSphere(position, SightRadius.Value, _itemMask)).ToArray();
			if (array.Length < 1)
			{
				return;
			}
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				Pickable pickable = ((Component)val).GetComponentInParent<Pickable>();
				if ((Object)(object)pickable != (Object)null && PickableList.Value.Exists((string item) => ((Object)pickable).name.Contains(item)))
				{
					pickable.m_nview.InvokeRPC("RPC_Pick", Array.Empty<object>());
				}
			}
		}
	}
	internal class NeckroGathererPylon : Structure
	{
		public static ConfigEntry<float> SpawnInterval;

		public static MemoryConfigEntry<string, List<string>> NeckroCost;

		private Container _container;

		public static ChebsRecipe ChebsRecipeConfig = new ChebsRecipe
		{
			DefaultRecipe = "Stone:15,NeckTail:25,SurtlingCore:1",
			IconName = "chebgonaz_neckrogathererpylon_icon.png",
			PieceTable = "_HammerPieceTable",
			PieceCategory = "Misc",
			PieceName = "$chebgonaz_neckrogathererpylon_name",
			PieceDescription = "$chebgonaz_neckrogathererpylon_desc",
			PrefabName = "ChebGonaz_NeckroGathererPylon.prefab",
			ObjectName = MethodBase.GetCurrentMethod().DeclaringType.Name
		};

		private bool CanSpawnNeckro
		{
			get
			{
				bool result = false;
				foreach (string item in NeckroCost.Value)
				{
					string[] array = item.Split(new char[1] { ':' });
					if (array.Length != 2)
					{
						Logger.LogError((object)"Error in config for Neckro Gatherer Costs - please revise.");
						return false;
					}
					string text = array[0];
					if (!int.TryParse(array[1], out var result2))
					{
						Logger.LogError((object)"Error in config for Neckro Gatherer Costs - please revise.");
						return false;
					}
					GameObject prefab = ZNetScene.instance.GetPrefab(text);
					if ((Object)(object)prefab == (Object)null)
					{
						Logger.LogError((object)("Error processing config for Neckro Gatherer Costs: " + text + " doesn't exist."));
						return false;
					}
					if (_container.GetInventory().CountItems(prefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_name, -1, true) >= result2)
					{
						result = true;
					}
				}
				return result;
			}
		}

		public static void CreateConfigs(BasePlugin plugin)
		{
			ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "NeckroGathererPylonAllowed", true, "Whether making a the pylon is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "NeckroGathererPylonBuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build the pylon. None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true);
			SpawnInterval = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "NeckroGathererSpawnInterval", 60f, "How often the pylon will attempt to create a Neckro Gatherer.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			NeckroCost = new MemoryConfigEntry<string, List<string>>(plugin.ModConfig(ChebsRecipeConfig.ObjectName, "NeckroGathererCost", "NeckTail:1", "The items that are consumed when creating a Neckro Gatherer. Please use a comma-delimited list of prefab names with a : and integer for amount.", null, true), (Func<string, List<string>>)((string s) => (from str in s?.Split(new char[1] { ',' })
				select str.Trim()).ToList()));
		}

		public static void UpdateRecipe()
		{
			ChebsRecipeConfig.UpdateRecipe(ChebsRecipeConfig.CraftingCost);
		}

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(SpawnNeckros());
		}

		private IEnumerator SpawnNeckros()
		{
			Piece piece = ((Component)this).GetComponent<Piece>();
			yield return (object)new WaitWhile((Func<bool>)(() => !piece.IsPlacedByPlayer()));
			_container = ((Component)this).gameObject.AddComponent<Container>();
			_container.m_name = "$chebgonaz_neckrogathererpylon_name";
			_container.GetInventory().m_name = Localization.instance.Localize(_container.m_name);
			while (true)
			{
				yield return (object)new WaitForSeconds(SpawnInterval.Value);
				if (!piece.m_nview.IsOwner())
				{
					continue;
				}
				List<Player> playersInRange = new List<Player>();
				Player.GetPlayersInRange(((Component)this).transform.position, 150f, playersInRange);
				if (playersInRange.Count >= 1)
				{
					yield return (object)new WaitWhile((Func<bool>)(() => playersInRange[0].IsSleeping()));
					SpawnNeckro();
				}
			}
		}

		private void ConsumeRequirements()
		{
			foreach (string item in NeckroCost.Value)
			{
				string[] array = item.Split(new char[1] { ':' });
				if (array.Length != 2)
				{
					Logger.LogError((object)"Error in config for Neckro Gatherer Costs - please revise.");
					break;
				}
				string text = array[0];
				if (!int.TryParse(array[1], out var result))
				{
					Logger.LogError((object)"Error in config for Neckro Gatherer Costs - please revise.");
					break;
				}
				GameObject prefab = ZNetScene.instance.GetPrefab(text);
				if ((Object)(object)prefab == (Object)null)
				{
					Logger.LogError((object)("Error processing config for Neckro Gatherer Costs: " + text + " doesn't exist."));
					break;
				}
				string text2 = prefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_name;
				_container.GetInventory().RemoveItem(text2, result, -1, true);
			}
		}

		protected void SpawnNeckro()
		{
			//IL_0006: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			Player closestPlayer = Player.GetClosestPlayer(((Component)this).transform.position, NeckroGathererMinion.LookRadius.Value);
			if (Object.op_Implicit((Object)(object)closestPlayer) && CanSpawnNeckro)
			{
				ConsumeRequirements();
				int level = 1;
				string text = "ChebGonaz_NeckroGatherer";
				GameObject prefab = ZNetScene.instance.GetPrefab(text);
				if (!Object.op_Implicit((Object)(object)prefab))
				{
					Logger.LogError((object)("spawning " + text + " failed!"));
					return;
				}
				GameObject obj = Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position + ((Component)this).transform.forward * 2f + Vector3.up, Quaternion.identity);
				obj.GetComponent<Character>().SetLevel(level);
				((ChebGonazMinion)obj.GetComponent<NeckroGathererMinion>()).UndeadMinionMaster = closestPlayer.GetPlayerName();
				obj.AddComponent<FreshMinion>();
			}
		}
	}
	internal class Phylactery : Structure
	{
		private struct ItemInfoHolder
		{
			public string Name;

			public int Stack;

			public float Durability;

			public Vector2i GridPosition;

			public bool Equipped;

			public int Quality;

			public int Variant;

			public long CrafterID;

			public string CrafterName;

			public Dictionary<string, string> CustomData;

			public int WorldLevel;

			public bool PickedUp;

			public ItemInfoHolder(string name, int stack, float durability, Vector2i gridPosition, bool equipped, int quality, int variant, long crafterID, string crafterName, Dictionary<string, string> customData, int worldLevel, bool pickedUp)
			{
				//IL_0016: 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)
				Name = name;
				Stack = stack;
				Durability = durability;
				GridPosition = gridPosition;
				Equipped = equipped;
				Quality = quality;
				Variant = variant;
				CrafterID = crafterID;
				CrafterName = crafterName;
				CustomData = customData;
				WorldLevel = worldLevel;
				PickedUp = pickedUp;
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static CoroutineHandler <0>__PhylacteryCheckRPCServerReceive;

			public static CoroutineHandler <1>__PhylacteryCheckRPCClientReceive;
		}

		public static readonly int PhylacteryHash = StringExtensionMethods.GetStableHashCode("ChebGonaz_Phylactery");

		public static ConfigEntry<string> FuelPrefab;

		public static bool HasPhylactery;

		public static Vector3 PhylacteryLocation = Vector3.zero;

		private Container _container;

		private Inventory _inventory;

		public static CustomRPC PhylacteryCheckRPC;

		private const string PhylacteryCheckString1 = "CG_1";

		private const string PhylacteryCheckString2 = "CG_2";

		private const string PhylacteryConsumeFuelString1 = "CG_3";

		public static ChebsRecipe ChebsRecipeConfig = new ChebsRecipe
		{
			DefaultRecipe = "Stone:100,Coal:100",
			IconName = "chebgonaz_phylactery_icon.png",
			PieceTable = "_HammerPieceTable",
			PieceCategory = "Misc",
			PieceName = "$chebgonaz_phylactery_name",
			PieceDescription = "$chebgonaz_phylactery_desc",
			PrefabName = "ChebGonaz_Phylactery.prefab",
			ObjectName = MethodBase.GetCurrentMethod()?.DeclaringType?.Name
		};

		public static void UpdateRecipe()
		{
			ChebsRecipeConfig.UpdateRecipe(ChebsRecipeConfig.CraftingCost);
		}

		public static void CreateConfigs(BasePlugin plugin)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "PhylacteryAllowed", true, "Whether making a Phylactery  is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "PhylacteryBuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build a Phylactery . None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true);
			FuelPrefab = ((BaseUnityPlugin)plugin).Config.Bind<string>(ChebsRecipeConfig.ObjectName, "Fuel", "DragonEgg", new ConfigDescription("The prefab name that is consumed as fuel.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
		}

		public static void ConfigureRPC()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0035: 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_0040: Expected O, but got Unknown
			NetworkManager instance = NetworkManager.Instance;
			object obj = <>O.<0>__PhylacteryCheckRPCServerReceive;
			if (obj == null)
			{
				CoroutineHandler val = PhylacteryCheckRPCServerReceive;
				<>O.<0>__PhylacteryCheckRPCServerReceive = val;
				obj = (object)val;
			}
			object obj2 = <>O.<1>__PhylacteryCheckRPCClientReceive;
			if (obj2 == null)
			{
				CoroutineHandler val2 = PhylacteryCheckRPCClientReceive;
				<>O.<1>__PhylacteryCheckRPCClientReceive = val2;
				obj2 = (object)val2;
			}
			PhylacteryCheckRPC = instance.AddRPC("PhylacteryCheckRPC", (CoroutineHandler)obj, (CoroutineHandler)obj2);
		}

		private static bool PhylacteryZDOHasFuel(ZDO zdo)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			string value = FuelPrefab.Value;
			int num = 0;
			string @string = zdo.GetString(ZDOVars.s_items, "");
			if (string.IsNullOrEmpty(@string))
			{
				if (BasePlugin.HeavyLogging.Value)
				{
					Logger.LogInfo((object)"Phylactery's s_items appears empty.");
				}
				return false;
			}
			ZPackage val = new ZPackage(@string);
			int num2 = val.ReadInt();
			int num3 = val.ReadInt();
			if (num2 == 106)
			{
				for (int i = 0; i < num3; i++)
				{
					string text = val.ReadString();
					val.ReadInt();
					val.ReadSingle();
					val.ReadVector2i();
					val.ReadBool();
					val.ReadInt();
					val.ReadInt();
					val.ReadLong();
					val.ReadString();
					Dictionary<string, string> dictionary = new Dictionary<string, string>();
					int num4 = val.ReadInt();
					for (int j = 0; j < num4; j++)
					{
						dictionary[val.ReadString()] = val.ReadString();
					}
					val.ReadInt();
					val.ReadBool();
					if (BasePlugin.HeavyLogging.Value)
					{
						Logger.LogInfo((object)("Found " + text + " in phylactery's inventory"));
					}
					if (text == value)
					{
						num++;
					}
				}
			}
			else
			{
				for (int k = 0; k < num3; k++)
				{
					string text2 = val.ReadString();
					val.ReadInt();
					val.ReadSingle();
					val.ReadVector2i();
					val.ReadBool();
					if (num2 >= 101)
					{
						val.ReadInt();
					}
					if (num2 >= 102)
					{
						val.ReadInt();
					}
					if (num2 >= 103)
					{
						val.ReadLong();
						val.ReadString();
					}
					Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
					if (num2 >= 104)
					{
						int num5 = val.ReadInt();
						for (int l = 0; l < num5; l++)
						{
							string key = val.ReadString();
							string value2 = val.ReadString();
							dictionary2[key] = value2;
						}
					}
					if (num2 >= 105)
					{
						val.ReadInt();
					}
					if (num2 >= 106)
					{
						val.ReadBool();
					}
					if (BasePlugin.HeavyLogging.Value)
					{
						Logger.LogInfo((object)("Found " + text2 + " in phylactery's inventory"));
					}
					if (text2 == value)
					{
						num++;
					}
				}
			}
			return num > 0;
		}

		public static void RemoveFuelFromPhylactery(ZDO zdo)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			string value = FuelPrefab.Value;
			List<ItemInfoHolder> list = new List<ItemInfoHolder>();
			bool flag = false;
			string @string = zdo.GetString(ZDOVars.s_items, "");
			if (string.IsNullOrEmpty(@string))
			{
				Logger.LogError((object)"Trying to remove fuel from phylactery, but s_items is empty.");
				return;
			}
			ZPackage val = new ZPackage(@string);
			int num = val.ReadInt();
			int num2 = val.ReadInt();
			if (num == 106)
			{
				for (int i = 0; i < num2; i++)
				{
					string text = val.ReadString();
					int stack = val.ReadInt();
					float durability = val.ReadSingle();
					Vector2i gridPosition = val.ReadVector2i();
					bool equipped = val.ReadBool();
					int quality = val.ReadInt();
					int variant = val.ReadInt();
					long crafterID = val.ReadLong();
					string crafterName = val.ReadString();
					Dictionary<string, string> dictionary = new Dictionary<string, string>();
					int num3 = val.ReadInt();
					for (int j = 0; j < num3; j++)
					{
						dictionary[val.ReadString()] = val.ReadString();
					}
					int worldLevel = val.ReadInt();
					bool pickedUp = val.ReadBool();
					if (BasePlugin.HeavyLogging.Value)
					{
						Logger.LogInfo((object)("Found " + text + " in phylactery's inventory"));
					}
					if (text == value && !flag)
					{
						flag = true;
					}
					else
					{
						list.Add(new ItemInfoHolder(text, stack, durability, gridPosition, equipped, quality, variant, crafterID, crafterName, dictionary, worldLevel, pickedUp));
					}
				}
			}
			else
			{
				for (int k = 0; k < num2; k++)
				{
					string text2 = val.ReadString();
					int stack2 = val.ReadInt();
					float durability2 = val.ReadSingle();
					Vector2i gridPosition2 = val.ReadVector2i();
					bool equipped2 = val.ReadBool();
					int quality2 = 1;
					if (num >= 101)
					{
						quality2 = val.ReadInt();
					}
					int variant2 = 0;
					if (num >= 102)
					{
						variant2 = val.ReadInt();
					}
					long crafterID2 = 0L;
					string crafterName2 = "";
					if (num >= 103)
					{
						crafterID2 = val.ReadLong();
						crafterName2 = val.ReadString();
					}
					Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
					if (num >= 104)
					{
						int num4 = val.ReadInt();
						for (int l = 0; l < num4; l++)
						{
							string key = val.ReadString();
							string value2 = val.ReadString();
							dictionary2[key] = value2;
						}
					}
					int worldLevel2 = 0;
					if (num >= 105)
					{
						worldLevel2 = val.ReadInt();
					}
					bool pickedUp2 = false;
					if (num >= 106)
					{
						pickedUp2 = val.ReadBool();
					}
					if (BasePlugin.HeavyLogging.Value)
					{
						Logger.LogInfo((object)("Found " + text2 + " in phylactery's inventory"));
					}
					if (text2 == value && !flag)
					{
						flag = true;
					}
					else
					{
						list.Add(new ItemInfoHolder(text2, stack2, durability2, gridPosition2, equipped2, quality2, variant2, crafterID2, crafterName2, dictionary2, worldLevel2, pickedUp2));
					}
				}
			}
			ZPackage val2 = new ZPackage();
			val2.Write(106);
			val2.Write(list.Count);
			foreach (ItemInfoHolder item in list)
			{
				val2.Write(item.Name);
				val2.Write(item.Stack);
				val2.Write(item.Durability);
				val2.Write(item.GridPosition);
				val2.Write(item.Equipped);
				val2.Write(item.Quality);
				val2.Write(item.Variant);
				val2.Write(item.CrafterID);
				val2.Write(item.CrafterName);
				val2.Write(item.CustomData.Count);
				foreach (KeyValuePair<string, string> customDatum in item.CustomData)
				{
					val2.Write(customDatum.Key);
					val2.Write(customDatum.Value);
				}
				val2.Write(item.WorldLevel);
				val2.Write(item.PickedUp);
			}
			string @base = val2.GetBase64();
			zdo.Set(ZDOVars.s_items, @base);
		}

		private static IEnumerator PhylacteryCheckRPCServerReceive(long sender, ZPackage package)
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				yield return null;
			}
			if (ZNetExtension.IsServerInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance))
			{
				byte[] array = package.GetArray();
				string @string = Encoding.UTF8.GetString(array);
				if (@string.StartsWith("CG_1"))
				{
					if (BasePlugin.HeavyLogging.Value)
					{
						Logger.LogInfo((object)$"Received request from {sender} to check for an existing phylactery ({@string}).");
					}
					string[] array2 = @string.Split(new char[1] { ' ' });
					long playerCreatorID2 = 0L;
					if (array2.Length < 2 || !long.TryParse(array2[1], out playerCreatorID2))
					{
						Logger.LogError((object)$"Failed to parse playerCreatorID out of payload ({array2.Length})");
					}
					ZDO val = (from zdo in ZDOMan.instance.m_objectsByID.Values.ToList().FindAll((ZDO zdo) => zdo.GetPrefab() == PhylacteryHash)
						where zdo.GetLong(ZDOVars.s_creator, 0L) == playerCreatorID2
						select zdo).ToList().FirstOrDefault();
					if (val != null)
					{
						if (BasePlugin.HeavyLogging.Value)
						{
							Logger.LogInfo((object)"Phylactery found belonging to player.");
						}
						byte[] bytes;
						if (!PhylacteryZDOHasFuel(val))
						{
							bytes = Encoding.UTF8.GetBytes("CG_2");
						}
						else
						{
							Encoding uTF = Encoding.UTF8;
							Vector3 position = val.m_position;
							bytes = uTF.GetBytes("CG_2" + ((object)(Vector3)(ref position)).ToString());
						}
						byte[] array3 = bytes;
						PhylacteryCheckRPC.SendPackage(sender, new ZPackage(array3));
					}
					else if (BasePlugin.HeavyLogging.Value)
					{
						Logger.LogInfo((object)"no phylactery found for player.");
					}
				}
				else if (@string.StartsWith("CG_3"))
				{
					if (BasePlugin.HeavyLogging.Value)
					{
						Logger.LogInfo((object)$"Received request from {sender} to consume fuel.");
					}
					string[] array4 = @string.Split(new char[1] { ' ' });
					long playerCreatorID = 0L;
					if (array4.Length < 2 || !long.TryParse(array4[1], out playerCreatorID))
					{
						Logger.LogError((object)$"Failed to parse playerCreatorID out of payload ({array4.Length})");
					}
					ZDO val2 = (from zdo in ZDOMan.instance.m_objectsByID.Values.ToList().FindAll((ZDO zdo) => zdo.GetPrefab() == PhylacteryHash)
						where zdo.GetLong(ZDOVars.s_creator, 0L) == playerCreatorID
						select zdo).ToList().FirstOrDefault();
					if (val2 != null)
					{
						RemoveFuelFromPhylactery(val2);
					}
				}
				else if (@string.StartsWith("CG_2"))
				{
					if (BasePlugin.HeavyLogging.Value)
					{
						Logger.LogInfo((object)$"Received request from {sender} for phylactery location.");
					}
					ReceivePhylacteryLocation(@string, sender);
				}
			}
			yield return null;
		}

		private static void ReceivePhylacteryLocation(string decoded, long sender)
		{
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if (BasePlugin.HeavyLogging.Value)
			{
				Logger.LogInfo((object)$"ReceivePhylacteryLocation {decoded} {sender}");
			}
			string[] array = decoded.Replace("CG_2", "").Replace("(", "").Replace(")", "")
				.Replace(" ", "")
				.Split(new char[1] { ',' });
			if (array.Length != 3)
			{
				HasPhylactery = false;
				return;
			}
			if (BasePlugin.HeavyLogging.Value)
			{
				Logger.LogInfo((object)(array[0] + " " + array[1] + " " + array[2]));
			}
			Vector3 phylacteryLocation = new Vector3(float.Parse(array[0]), float.Parse(array[1]), float.Parse(array[2]));
			HasPhylactery = true;
			PhylacteryLocation = phylacteryLocation;
		}

		public static IEnumerator PhylacteryCheckRPCClientReceive(long sender, ZPackage package)
		{
			if (BasePlugin.HeavyLogging.Value)
			{
				Logger.LogMessage((object)"PhylacteryCheckRPCClientReceive");
			}
			byte[] array = package.GetArray();
			if (array.Length >= 3)
			{
				string @string = Encoding.UTF8.GetString(array);
				if (@string.StartsWith("CG_2"))
				{
					ReceivePhylacteryLocation(@string, sender);
				}
			}
			yield return null;
		}

		public static IEnumerator PhylacteriesCheck()
		{
			while (true)
			{
				yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)ZNet.instance != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null));
				if (ZNetExtension.IsClientInstance(ZNet.instance) || ZNetExtension.IsLocalInstance(ZNet.instance))
				{
					ZPackage val = new ZPackage(Encoding.UTF8.GetBytes("CG_1 " + Player.m_localPlayer.GetPlayerID()));
					PhylacteryCheckRPC.SendPackage(ZRoutedRpc.instance.GetServerPeerID(), val);
				}
				yield return (object)new WaitForSeconds(5f);
			}
		}

		public static void RequestConsumptionOfFuelForPlayerPhylactery()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			ZPackage val = new ZPackage(Encoding.UTF8.GetBytes("CG_3 " + Player.m_localPlayer.GetPlayerID()));
			PhylacteryCheckRPC.SendPackage(ZRoutedRpc.instance.GetServerPeerID(), val);
		}

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(Wait());
		}

		private IEnumerator Wait()
		{
			Piece piece = ((Component)this).GetComponent<Piece>();
			yield return (object)new WaitWhile((Func<bool>)(() => !piece.IsPlacedByPlayer()));
			_container = ((Component)this).gameObject.AddComponent<Container>();
			_container.m_name = "$chebgonaz_phylactery_name";
			_inventory = _container.GetInventory();
			_inventory.m_name = Localization.instance.Localize(_container.m_name);
		}
	}
	internal class RefuelerPylon : Structure
	{
		public static ConfigEntry<float> SightRadius;

		public static ConfigEntry<float> RefuelerUpdateInterval;

		public static ConfigEntry<bool> ManageFireplaces;

		public static ConfigEntry<bool> ManageSmelters;

		public static ConfigEntry<bool> ManageCookingStations;

		private readonly int pieceMask = LayerMask.GetMask(new string[1] { "piece" });

		private readonly int pieceMaskNonSolid = LayerMask.GetMask(new string[1] { "piece_nonsolid" });

		private Container _container;

		private Inventory _inventory;

		public static ChebsRecipe ChebsRecipeConfig = new ChebsRecipe
		{
			DefaultRecipe = "Stone:15,Coal:15,BoneFragments:15,SurtlingCore:1",
			IconName = "chebgonaz_refuelerpylon_icon.png",
			PieceTable = "_HammerPieceTable",
			PieceCategory = "Misc",
			PieceName = "$chebgonaz_refuelerpylon_name",
			PieceDescription = "$chebgonaz_refuelerpylon_desc",
			PrefabName = "ChebGonaz_RefuelerPylon.prefab",
			ObjectName = MethodBase.GetCurrentMethod().DeclaringType.Name
		};

		public static void UpdateRecipe()
		{
			ChebsRecipeConfig.UpdateRecipe(ChebsRecipeConfig.CraftingCost);
		}

		public static void CreateConfigs(BasePlugin plugin)
		{
			ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RefuelerPylonAllowed", true, "Whether making a Refueler Pylon is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RefuelerPylonBuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build a Refueler Pylon. None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true);
			SightRadius = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RefuelerPylonSightRadius", 30f, "How far a Refueler Pylon can reach containers.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			RefuelerUpdateInterval = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RefuelerPylonUpdateInterval", 5f, "How long a Refueler Pylon waits between checking containers (lower values may negatively impact performance).", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			ManageFireplaces = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "ManageFireplaces", true, "Whether making a Refueler Pylon will manage fireplaces.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ManageSmelters = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "ManageSmelters", true, "Whether making a Refueler Pylon will manage smelters.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ManageCookingStations = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "ManageCookingStations", true, "Whether making a Refueler Pylon will manage cooking stations.", (AcceptableValueBase)(object)plugin.BoolValue, true);
		}

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(LookForPieces());
		}

		private IEnumerator LookForPieces()
		{
			Piece piece = ((Component)this).GetComponent<Piece>();
			yield return (object)new WaitWhile((Func<bool>)(() => !piece.IsPlacedByPlayer()));
			_container = ((Component)this).gameObject.AddComponent<Container>();
			_container.m_name = "$chebgonaz_refuelerpylon_name";
			_inventory = _container.GetInventory();
			_inventory.m_name = Localization.instance.Localize(_container.m_name);
			while (true)
			{
				yield return (object)new WaitForSeconds(RefuelerUpdateInterval.Value);
				if (!piece.m_nview.IsOwner())
				{
					continue;
				}
				List<Player> playersInRange = new List<Player>();
				Player.GetPlayersInRange(((Component)this).transform.position, 150f, playersInRange);
				if (playersInRange.Count >= 1)
				{
					yield return (object)new WaitWhile((Func<bool>)(() => playersInRange[0].IsSleeping()));
					Tuple<List<Smelter>, List<Fireplace>, List<CookingStation>> nearbySmeltersAndFireplaces = GetNearbySmeltersAndFireplaces();
					nearbySmeltersAndFireplaces.Item1?.ForEach(ManageSmelter);
					nearbySmeltersAndFireplaces.Item2?.ForEach(ManageFireplace);
					nearbySmeltersAndFireplaces.Item3?.ForEach(ManageCookingStation);
				}
			}
		}

		private Tuple<List<Smelter>, List<Fireplace>, List<CookingStation>> GetNearbySmeltersAndFireplaces()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position + Vector3.up, SightRadius.Value, pieceMask);
			if (array.Length < 1)
			{
				return null;
			}
			List<Smelter> list = new List<Smelter>();
			List<Fireplace> list2 = new List<Fireplace>();
			List<CookingStation> list3 = new List<CookingStation>();
			Collider[] array2 = array;
			foreach (Collider val in array2)
			{
				if (ManageSmelters.Value)
				{
					Smelter componentInParent = ((Component)val).GetComponentInParent<Smelter>();
					if ((Object)(object)componentInParent != (Object)null)
					{
						list.Add(componentInParent);
					}
				}
				if (ManageFireplaces.Value)
				{
					Fireplace componentInParent2 = ((Component)val).GetComponentInParent<Fireplace>();
					if ((Object)(object)componentInParent2 != (Object)null)
					{
						list2.Add(componentInParent2);
					}
				}
			}
			if (ManageCookingStations.Value)
			{
				array2 = Physics.OverlapSphere(((Component)this).transform.position + Vector3.up, SightRadius.Value, pieceMaskNonSolid);
				for (int i = 0; i < array2.Length; i++)
				{
					CookingStation componentInParent3 = ((Component)array2[i]).GetComponentInParent<CookingStation>();
					if ((Object)(object)componentInParent3 != (Object)null)
					{
						list3.Add(componentInParent3);
					}
				}
			}
			return new Tuple<List<Smelter>, List<Fireplace>, List<CookingStation>>(list, list2, list3);
		}

		private void ManageSmelter(Smelter smelter)
		{
			if ((Object)(object)smelter == (Object)null)
			{
				return;
			}
			if ((Object)(object)smelter.m_fuelItem != (Object)null)
			{
				LoadSmelterWithFuel(smelter.m_fuelItem.m_itemData.m_shared.m_name);
			}
			ItemData val = smelter.FindCookableItem(_inventory);
			if (val != null && smelter.IsItemAllowed(((Object)val.m_dropPrefab).name) && smelter.GetQueueSize() < smelter.m_maxOre)
			{
				_inventory.RemoveItem(val, 1);
				smelter.m_nview.InvokeRPC("RPC_AddOre", new object[1] { ((Object)val.m_dropPrefab).name });
				smelter.m_addedOreTime = Time.time;
				if (smelter.m_addOreAnimationDuration > 0f)
				{
					smelter.SetAnimation(true);
				}
			}
			void LoadSmelterWithFuel(string fuel)
			{
				while (_inventory.CountItems(fuel, -1, true) > 0)
				{
					float fuel2 = smelter.GetFuel();
					if (!(fuel2 < (float)smelter.m_maxFuel))
					{
						break;
					}
					smelter.SetFuel(fuel2 + 1f);
					_inventory.RemoveItem(fuel, 1, -1, true);
				}
			}
		}

		private void ManageFireplace(Fireplace fireplace)
		{
			if (!(fireplace.m_nview.GetZDO().GetFloat("fuel", 0f) >= fireplace.m_maxFuel - 1f) && _inventory.HaveItem(fireplace.m_fuelItem.m_itemData.m_shared.m_name, true))
			{
				fireplace.m_nview.InvokeRPC("RPC_AddFuel", Array.Empty<object>());
				_inventory.RemoveItem(fireplace.m_fuelItem.m_itemData.m_shared.m_name, 1, -1, true);
			}
		}

		private void ManageCookingStation(CookingStation cookingStation)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (cookingStation.HaveDoneItem())
			{
				cookingStation.m_nview.InvokeRPC("RPC_RemoveDoneItem", new object[1] { ((Component)this).transform.position });
			}
			if (cookingStation.GetFreeSlot() != -1)
			{
				ItemData val = cookingStation.FindCookableItem(_inventory);
				if (val != null)
				{
					string name = ((Object)val.m_dropPrefab).name;
					cookingStation.m_nview.InvokeRPC("RPC_AddItem", new object[1] { name });
					_inventory.RemoveOneItem(val);
				}
			}
		}
	}
	internal class RepairPylon : Structure
	{
		public static ConfigEntry<float> SightRadius;

		public static ConfigEntry<float> RepairUpdateInterval;

		public static ConfigEntry<float> FuelConsumedPerPointOfDamage;

		public static ConfigEntry<float> RepairWoodWhen;

		public static ConfigEntry<float> RepairOtherWhen;

		public static MemoryConfigEntry<string, List<string>> Fuels;

		public static MemoryConfigEntry<string, List<string>> AlwaysRepair;

		private readonly int pieceMask = LayerMask.GetMask(new string[1] { "piece" });

		private Container _container;

		private Inventory _inventory;

		private float _fuelAccumulator;

		public static ChebsRecipe ChebsRecipeConfig = new ChebsRecipe
		{
			DefaultRecipe = "Stone:15,GreydwarfEye:50,SurtlingCore:1",
			IconName = "chebgonaz_repairpylon_icon.png",
			PieceTable = "_HammerPieceTable",
			PieceCategory = "Misc",
			PieceName = "$chebgonaz_repairpylon_name",
			PieceDescription = "$chebgonaz_repairpylon_desc",
			PrefabName = "ChebGonaz_RepairPylon.prefab",
			ObjectName = MethodBase.GetCurrentMethod().DeclaringType.Name
		};

		private int FuelInInventory
		{
			get
			{
				int num = 0;
				foreach (string item in Fuels.Value)
				{
					GameObject prefab = ZNetScene.instance.GetPrefab(item);
					if (!((Object)(object)prefab == (Object)null))
					{
						num += _inventory.CountItems(prefab.GetComponent<ItemDrop>()?.m_itemData.m_shared.m_name, -1, true);
					}
				}
				return num;
			}
		}

		public static void UpdateRecipe()
		{
			ChebsRecipeConfig.UpdateRecipe(ChebsRecipeConfig.CraftingCost);
		}

		public static void CreateConfigs(BasePlugin plugin)
		{
			ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RepairPylonAllowed", true, "Whether making a Repair Pylon is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RepairPylonBuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build a Repair Pylon. None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true);
			SightRadius = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RepairPylonSightRadius", 30f, "How far a Repair Pylon can reach containers.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			RepairUpdateInterval = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RepairPylonUpdateInterval", 5f, "How long a Repair Pylon waits between checking containers (lower values may negatively impact performance).", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			FuelConsumedPerPointOfDamage = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "FuelConsumedPerPointOfDamage", 0.01f, "How much fuel is consumed per point of damage. For example at 0.01 it will cost 1 fuel per 100 points of damage healed.", null, true);
			RepairWoodWhen = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RepairWoodWhen", 0.25f, "How low a wooden structure's health must drop in order for it to be repaired. Set to 0 to repair regardless of damage.", null, true);
			RepairOtherWhen = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "RepairOtherWhen", 0f, "How low a non-wood structure's health must drop in order for it to be repaired. Set to 0 to repair regardless of damage.", null, true);
			AlwaysRepair = new MemoryConfigEntry<string, List<string>>(plugin.ModConfig(ChebsRecipeConfig.ObjectName, "AlwaysRepair", "piece_sharpstakes,piece_dvergr_sharpstakes", "These prefabs are always repaired no matter their damage and ignore the RepairWoodWhen/RepairOtherWhen thresholds. This is good for defensive things like stakes which should always be kept at maximum health. Please use a comma-delimited list of prefab names.", null, true), (Func<string, List<string>>)((string s) => (from str in s?.Split(new char[1] { ',' })
				select str.Trim()).ToList()));
			Fuels = new MemoryConfigEntry<string, List<string>>(plugin.ModConfig(ChebsRecipeConfig.ObjectName, "Fuels", "Resin,GreydwarfEye,Pukeberries", "The items that are consumed as fuel when repairing. Please use a comma-delimited list of prefab names.", null, true), (Func<string, List<string>>)((string s) => (from str in s?.Split(new char[1] { ',' })
				select str.Trim()).ToList()));
		}

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(LookForPieces());
		}

		private IEnumerator LookForPieces()
		{
			Piece piece = ((Component)this).GetComponent<Piece>();
			yield return (object)new WaitWhile((Func<bool>)(() => !piece.IsPlacedByPlayer()));
			_container = ((Component)this).gameObject.AddComponent<Container>();
			_container.m_name = "$chebgonaz_repairpylon_name";
			_inventory = _container.GetInventory();
			_inventory.m_name = Localization.instance.Localize(_container.m_name);
			while (true)
			{
				yield return (object)new WaitForSeconds(RepairUpdateInterval.Value);
				if (!piece.m_nview.IsOwner())
				{
					continue;
				}
				List<Player> playersInRange = new List<Player>();
				Player.GetPlayersInRange(((Component)this).transform.position, 150f, playersInRange);
				if (playersInRange.Count < 1)
				{
					continue;
				}
				yield return (object)new WaitWhile((Func<bool>)(() => playersInRange[0].IsSleeping()));
				List<WearNTear> list = PiecesInRange();
				foreach (WearNTear item in list)
				{
					float healthPercentage = item.GetHealthPercentage();
					if (!RepairDamage(item))
					{
						continue;
					}
					if (playersInRange.Any((Player player) => Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position) < 5f))
					{
						Chat.instance.SetNpcText(((Component)this).gameObject, Vector3.up, 5f, 2f, "", "Repairing " + ((Object)((Component)item).gameObject).name + " (" + (healthPercentage * 100f).ToString("0.##") + "%)...", false);
					}
					List<Player> list2 = new List<Player>();
					Player.GetPlayersInRange(((Component)item).transform.position, 20f, list2);
					if (list2.Count > 0)
					{
						Piece piece2 = item.m_piece;
						if (piece2 != null)
						{
							Transform transform = ((Component)piece2).transform;
							piece2.m_placeEffect.Create(transform.position, transform.rotation, (Transform)null, 1f, -1);
						}
					}
					yield return (object)new WaitForSeconds(1f);
				}
			}
		}

		private bool RepairDamage(WearNTear wearNTear)
		{
			//IL_0044: 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_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_004f: Invalid comparison between Unknown and I4
			if (wearNTear.GetHealthPercentage() >= 1f)
			{
				return false;
			}
			if (!AlwaysRepair.Value.Any((string alwaysRepairName) => ((Object)wearNTear).name.Contains(alwaysRepairName)))
			{
				MaterialType materialType = wearNTear.m_materialType;
				if (((int)materialType == 0 || (int)materialType == 3) ? true : false)
				{
					if (RepairWoodWhen.Value != 0f && wearNTear.GetHealthPercentage() >= RepairWoodWhen.Value)
					{
						return false;
					}
				}
				else if (RepairOtherWhen.Value != 0f && wearNTear.GetHealthPercentage() >= RepairOtherWhen.Value)
				{
					return false;
				}
			}
			bool num = ConsumeFuel(wearNTear);
			if (num)
			{
				wearNTear.Repair();
			}
			return num;
		}

		private bool ConsumeFuel(int fuelToConsume)
		{
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			int num = 0;
			foreach (string item in Fuels.Value)
			{
				GameObject prefab = ZNetScene.instance.GetPrefab(item);
				if (!((Object)(object)prefab == (Object)null))
				{
					string name = prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_name;
					int num3 = (dictionary[name] = _inventory.CountItems(name, -1, true));
					num += num3;
					if (num >= fuelToConsume)
					{
						break;
					}
				}
			}
			if (num < fuelToConsume)
			{
				return false;
			}
			foreach (string key in dictionary.Keys)
			{
				int num4 = dictionary[key];
				if (fuelToConsume <= num4)
				{
					_inventory.RemoveItem(key, fuelToConsume, -1, true);
					return true;
				}
				fuelToConsume -= num4;
				_inventory.RemoveItem(key, num4, -1, true);
			}
			return true;
		}

		private bool ConsumeFuel(WearNTear wearNTear)
		{
			if (_fuelAccumulator >= 1f && (float)FuelInInventory >= _fuelAccumulator)
			{
				ConsumeFuel((int)_fuelAccumulator);
				_fuelAccumulator -= (int)_fuelAccumulator;
			}
			float healthPercentage = wearNTear.GetHealthPercentage();
			if (healthPercentage <= 0f)
			{
				return false;
			}
			float num = (100f - healthPercentage * 100f) * FuelConsumedPerPointOfDamage.Value;
			if (num < 1f)
			{
				_fuelAccumulator += num;
			}
			if (num > (float)FuelInInventory)
			{
				return false;
			}
			ConsumeFuel((int)num);
			return true;
		}

		private List<WearNTear> PiecesInRange()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(((Component)this).transform.position + Vector3.up, SightRadius.Value, pieceMask);
			if (array.Length < 1)
			{
				return null;
			}
			List<WearNTear> list = new List<WearNTear>();
			Collider[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				WearNTear componentInParent = ((Component)array2[i]).GetComponentInParent<WearNTear>();
				if (!((Object)(object)componentInParent == (Object)null) && componentInParent.m_nview.IsValid())
				{
					list.Add(componentInParent);
				}
			}
			return list;
		}
	}
	internal class SpiritPylon : Structure
	{
		public static ConfigEntry<float> SightRadius;

		public static ConfigEntry<float> GhostDuration;

		public static ConfigEntry<float> DelayBetweenGhosts;

		public static ConfigEntry<int> MaxGhosts;

		protected List<GameObject> SpawnedGhosts = new List<GameObject>();

		private float ghostLastSpawnedAt;

		public static ChebsRecipe ChebsRecipeConfig = new ChebsRecipe
		{
			DefaultRecipe = "Stone:15,Wood:15,BoneFragments:15,SurtlingCore:1",
			IconName = "chebgonaz_spiritpylon_icon.png",
			PieceTable = "_HammerPieceTable",
			PieceCategory = "Misc",
			PieceName = "$chebgonaz_spiritpylon_name",
			PieceDescription = "$chebgonaz_spiritpylon_desc",
			PrefabName = "ChebGonaz_SpiritPylon.prefab",
			ObjectName = MethodBase.GetCurrentMethod().DeclaringType.Name
		};

		public static void UpdateRecipe()
		{
			ChebsRecipeConfig.UpdateRecipe(ChebsRecipeConfig.CraftingCost);
		}

		public static void CreateConfigs(BasePlugin plugin)
		{
			ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "SpiritPylonAllowed", true, "Whether making a Spirit Pylon is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "SpiritPylonBuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build Spirit Pylon. None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true);
			SightRadius = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "SpiritPylonSightRadius", 30f, "How far a Spirit Pylon can see enemies.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			GhostDuration = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "SpiritPylonGhostDuration", 30f, "How long a Spirit Pylon's ghost persists.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			DelayBetweenGhosts = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "SpiritPylonDelayBetweenGhosts", 5f, "How long a Spirit Pylon must wait before being able to spawn another ghost.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			MaxGhosts = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "SpiritPylonMaxGhosts", 3, "The maximum number of ghosts that a Spirit Pylon can spawn.", (AcceptableValueBase)(object)plugin.IntQuantityValue, true);
		}

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(LookForEnemies());
		}

		private IEnumerator LookForEnemies()
		{
			Piece piece = ((Component)this).GetComponent<Piece>();
			yield return (object)new WaitWhile((Func<bool>)(() => !piece.IsPlacedByPlayer()));
			Character target = default(Character);
			while (true)
			{
				yield return (object)new WaitForSeconds(2f);
				if (!piece.m_nview.IsOwner())
				{
					continue;
				}
				for (int num = SpawnedGhosts.Count - 1; num >= 0; num--)
				{
					if ((Object)(object)SpawnedGhosts[num] == (Object)null)
					{
						SpawnedGhosts.RemoveAt(num);
					}
				}
				if (((Structure)this).EnemiesNearby(ref target, SightRadius.Value) && SpawnedGhosts.Count < MaxGhosts.Value && Time.time > ghostLastSpawnedAt + DelayBetweenGhosts.Value)
				{
					ghostLastSpawnedAt = Time.time;
					GameObject val = SpawnFriendlyGhost();
					if ((Object)(object)val != (Object)null)
					{
						val.GetComponent<MonsterAI>().SetTarget(target);
						SpawnedGhosts.Add(val);
					}
				}
			}
		}

		protected GameObject SpawnFriendlyGhost()
		{
			//IL_002d: 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_0042: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			int level = 1;
			GameObject prefab = ZNetScene.instance.GetPrefab("ChebGonaz_SpiritPylonGhost");
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				Logger.LogError((object)"SpawnFriendlyGhost: spawning ChebGonaz_SpiritPylonGhost failed!");
				return null;
			}
			GameObject obj = Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position + ((Component)this).transform.forward * 2f + Vector3.up, Quaternion.identity);
			obj.GetComponent<Character>().SetLevel(level);
			return obj;
		}
	}
	internal class TreasurePylonEffect : MonoBehaviour
	{
		private IEnumerator Start()
		{
			yield return (object)new WaitForSeconds(5f);
			ZNetScene.instance.Destroy(((Component)this).gameObject);
		}
	}
	internal class TreasurePylon : Structure
	{
		public const string EffectName = "ChebGonaz_TreasurePylonEffect";

		public static ConfigEntry<float> SightRadius;

		public static ConfigEntry<float> UpdateInterval;

		public static MemoryConfigEntry<string, List<string>> ContainerWhitelist;

		private readonly int pieceMask = LayerMask.GetMask(new string[1] { "piece" });

		public static ChebsRecipe ChebsRecipeConfig = new ChebsRecipe
		{
			DefaultRecipe = "Coins:200,Ruby:2",
			IconName = "chebgonaz_treasurepylon_icon.png",
			PieceTable = "_HammerPieceTable",
			PieceCategory = "Misc",
			PieceName = "$chebgonaz_treasurepylon_name",
			PieceDescription = "$chebgonaz_treasurepylon_desc",
			PrefabName = "ChebGonaz_TreasurePylon.prefab",
			ObjectName = MethodBase.GetCurrentMethod().DeclaringType.Name
		};

		public static void UpdateRecipe()
		{
			ChebsRecipeConfig.UpdateRecipe(ChebsRecipeConfig.CraftingCost);
		}

		public static void CreateConfigs(BasePlugin plugin)
		{
			ChebsRecipeConfig.Allowed = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "Allowed", true, "Whether making a Treasure Pylon is allowed or not.", (AcceptableValueBase)(object)plugin.BoolValue, true);
			ChebsRecipeConfig.CraftingCost = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "BuildCosts", ChebsRecipeConfig.DefaultRecipe, "Materials needed to build a Treasure Pylon. None or Blank will use Default settings. Format: " + ChebsRecipeConfig.RecipeValue, null, true);
			SightRadius = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "SightRadius", 20f, "How far a Treasure Pylon can reach containers.", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			UpdateInterval = plugin.ModConfig(ChebsRecipeConfig.ObjectName, "UpdateInterval", 30f, "How long a Treasure Pylon waits between checking containers (lower values may negatively impact performance).", (AcceptableValueBase)(object)plugin.FloatQuantityValue, true);
			ContainerWhitelist = new MemoryConfigEntry<string, List<string>>(plugin.ModConfig(ChebsRecipeConfig.ObjectName, "ContainerWhitelist", "piece_chest_wood", "The containers that are sorted. Please use a comma-delimited list of prefab names.", null, true), (Func<string, List<string>>)((string s) => (from str in s?.Split(new char[1] { ',' })
				select str.Trim()).ToList()));
		}

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(LookForPieces());
		}

		private IEnumerator LookForPieces()
		{
			Piece piece = ((