Decompiled source of TotemsOfUndying v2.3.2

TotemsOfUndying.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using JFUtils;
using JFUtils.Valheim.WithPatch;
using JFUtils.WithPatch;
using JFUtils.zdos;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using Steamworks;
using TMPro;
using TotemsOfUndying.ItemManager;
using TotemsOfUndying.LocalizationManager;
using TotemsOfUndying.PieceManager;
using TotemsOfUndying.StatusEffectManager;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Callbacks;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: Guid("46BDCABE-BEB1-491F-8631-310F5186A3DB")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyProduct("TotemsOfUndying")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("TotemsOfUndying")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("JustAFrogger")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: <0c4373b5-6544-47e8-833e-581126bb9f2a>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<8cf12e90-8186-4da3-8882-a0e3c8b06ba5>Embedded]
	internal sealed class <8cf12e90-8186-4da3-8882-a0e3c8b06ba5>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[<8cf12e90-8186-4da3-8882-a0e3c8b06ba5>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <cb9d0274-549a-4593-bd8d-d0619a9c0bd8>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <cb9d0274-549a-4593-bd8d-d0619a9c0bd8>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <cb9d0274-549a-4593-bd8d-d0619a9c0bd8>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<8cf12e90-8186-4da3-8882-a0e3c8b06ba5>Embedded]
	[CompilerGenerated]
	internal sealed class <6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[<8cf12e90-8186-4da3-8882-a0e3c8b06ba5>Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class <0c4373b5-6544-47e8-833e-581126bb9f2a>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <0c4373b5-6544-47e8-833e-581126bb9f2a>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal sealed class ConfigurationManagerAttributes
{
	public bool? Browsable;

	public string Category;

	public Action<ConfigEntryBase> CustomDrawer;

	public object DefaultValue;

	public string Description;

	public string DispName;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public int? Order;

	public bool? ReadOnly;

	public bool? ShowRangeAsPercent;

	public Func<string, object> StrToObj;
}
namespace TotemsOfUndying
{
	[BepInPlugin("com.Frogger.TotemsOfUndying", "TotemsOfUndying", "2.3.2")]
	internal class Plugin : BaseUnityPlugin
	{
		private const string ModName = "TotemsOfUndying";

		private const string ModAuthor = "Frogger";

		private const string ModVersion = "2.3.2";

		private const string ModGUID = "com.Frogger.TotemsOfUndying";

		private static Totem EikthyrTotem;

		private static Totem TheElderTotem;

		private static Totem BonemassTotem;

		private static Totem ModerTotem;

		private static Totem YagluthTotem;

		private void Awake()
		{
			//IL_11c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_11db: Unknown result type (might be due to invalid IL or missing references)
			//IL_11e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_11eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_11f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_11fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1202: Unknown result type (might be due to invalid IL or missing references)
			//IL_120d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1216: Unknown result type (might be due to invalid IL or missing references)
			//IL_121e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1223: Unknown result type (might be due to invalid IL or missing references)
			//IL_122e: Unknown result type (might be due to invalid IL or missing references)
			//IL_123b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1243: Unknown result type (might be due to invalid IL or missing references)
			//IL_1248: Unknown result type (might be due to invalid IL or missing references)
			//IL_1253: Unknown result type (might be due to invalid IL or missing references)
			//IL_125c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1264: Unknown result type (might be due to invalid IL or missing references)
			//IL_1269: Unknown result type (might be due to invalid IL or missing references)
			//IL_1274: Unknown result type (might be due to invalid IL or missing references)
			//IL_1281: Unknown result type (might be due to invalid IL or missing references)
			//IL_1289: Unknown result type (might be due to invalid IL or missing references)
			//IL_128e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1299: Unknown result type (might be due to invalid IL or missing references)
			//IL_12a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_12b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_132e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1338: Unknown result type (might be due to invalid IL or missing references)
			//IL_1340: Unknown result type (might be due to invalid IL or missing references)
			//IL_1345: Unknown result type (might be due to invalid IL or missing references)
			//IL_13c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_13c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_13d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_13d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1451: Unknown result type (might be due to invalid IL or missing references)
			//IL_145e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1466: Unknown result type (might be due to invalid IL or missing references)
			//IL_146b: Unknown result type (might be due to invalid IL or missing references)
			//IL_14df: Unknown result type (might be due to invalid IL or missing references)
			//IL_14ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_14f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_14ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_1504: Unknown result type (might be due to invalid IL or missing references)
			//IL_150f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1518: Unknown result type (might be due to invalid IL or missing references)
			//IL_1520: Unknown result type (might be due to invalid IL or missing references)
			//IL_1525: Unknown result type (might be due to invalid IL or missing references)
			ModBase.CreateMod((BaseUnityPlugin)(object)this, "TotemsOfUndying", "Frogger", "2.3.2", "com.Frogger.TotemsOfUndying");
			ModBase.OnConfigurationChanged = (Action)Delegate.Combine(ModBase.OnConfigurationChanged, new Action(UpdateConfiguration));
			ModBase.bundle = PrefabManager.RegisterAssetBundle("totems");
			Item item = new Item(ModBase.bundle, "TotemOfEikthyr");
			item.Name.English("Totem Of Eikthyr").Swedish("Totem av Eikthyr").French("Totem d'Eikthyr")
				.Italian("Totem di Eikthyr")
				.German("Totem von Eikthyr")
				.Spanish("Tótem de Eikthyr")
				.Russian("Тотем Эйктюра")
				.Romanian("Totemul lui Eikthyr")
				.Bulgarian("Тотемът на Ейктир")
				.Macedonian("Тотем на Ејтир")
				.Finnish("Eikthyrin toteemi")
				.Danish("Totem af Eikthyr")
				.Norwegian("Totem av Eikthyr")
				.Icelandic("Tótem frá Eikthyr")
				.Turkish("Eikthyr Totemi")
				.Lithuanian("Eikthyro totemas")
				.Czech("Totem Eikthyr")
				.Hungarian("Eikthyr Totem")
				.Slovak("Totem Eikthyr")
				.Polish("Totem Eikthyru")
				.Dutch("Totem van Eikthyr")
				.Chinese("艾克瑟尔图腾")
				.Japanese("エイクシルのトーテム")
				.Korean("에이크티르의 토템")
				.Hindi("इकथ\u093fर क\u093e क\u0941लद\u0947वत\u093e")
				.Thai("Totem ของ Eikthyr")
				.Croatian("Totem Eikthyra")
				.Georgian("ეიქტირის ტოტემი")
				.Greek("Τοτέμ του Eikthyr")
				.Serbian("Тотем Еиктира")
				.Ukrainian("Тотем Ейктір");
			item.Description.English("In case of your death, Eikthyr will save you and give you a part of his powers").Swedish("I händelse av din död kommer Eikthyr att rädda dig och ge dig en del av sina krafter").French("En cas de votre mort, Eikthyr vous sauvera et vous donnera une partie de ses pouvoirs")
				.Italian("In caso di tua morte, Eikthyr ti salverà e ti darà una parte dei suoi poteri")
				.German("Im Falle deines Todes wird Eikthyr dich retten und dir einen Teil seiner Kräfte geben")
				.Spanish("En caso de tu muerte, Eikthyr te salvará y te dará una parte de sus poderes.")
				.Russian("В случае вашей смерти Эйктир спасет вас и передаст вам часть своих сил.")
				.Romanian("În cazul morții tale, Eikthyr te va salva și îți va oferi o parte din puterile lui")
				.Bulgarian("В случай на вашата смърт, Eikthyr ще ви спаси и ще ви даде част от силите си")
				.Macedonian("Во случај на твоја смрт, Еиктир ќе те спаси и ќе ти даде дел од неговите моќи")
				.Finnish("Jos kuolet, Eikthyr pelastaa sinut ja antaa sinulle osan voimistaan")
				.Danish("I tilfælde af din død, vil Eikthyr redde dig og give dig en del af sine kræfter")
				.Norwegian("I tilfelle du dør, vil Eikthyr redde deg og gi deg en del av kreftene sine")
				.Icelandic("Ef þú deyrð mun Eikthyr bjarga þér og gefa þér hluta af krafti sínum")
				.Turkish("Ölümün durumunda Eikthyr seni kurtaracak ve güçlerinin bir kısmını sana verecek")
				.Lithuanian("Jūsų mirties atveju Eikthyr jus išgelbės ir suteiks jums dalį savo galių")
				.Czech("V případě tvé smrti tě Eikthyr zachrání a dá ti část svých sil")
				.Hungarian("Halálod esetén Eikthyr megment, és hatalmának egy részét átadja neked")
				.Slovak("V prípade vašej smrti vás Eikthyr zachráni a dá vám časť svojich schopností")
				.Polish("W przypadku twojej śmierci Eikthyr cię uratuje i odda część swoich mocy")
				.Dutch("In het geval van je dood zal Eikthyr je redden en je een deel van zijn krachten geven")
				.Chinese("如果你死了,艾克瑟尔会拯救你并给予你他的一部分力量")
				.Japanese("あなたが死んだ場合、エイクシルはあなたを救い、彼の力の一部をあなたに与えます")
				.Korean("당신이 죽을 경우, Eikthyr는 당신을 구하고 그의 힘의 일부를 당신에게 줄 것입니다")
				.Hindi("आपक\u0940 म\u0943त\u094dय\u0941 क\u0947 म\u093eमल\u0947 म\u0947\u0902, इकथ\u093fर आपक\u094b बच\u093eएग\u093e और आपक\u094b अपन\u0940 शक\u094dत\u093fय\u094b\u0902 क\u093e एक ह\u093fस\u094dस\u093e द\u0947ग\u093e")
				.Thai("ในกรณ\u0e35ท\u0e35\u0e48ค\u0e38ณเส\u0e35ยช\u0e35ว\u0e34ต Eikthyr จะช\u0e48วยค\u0e38ณและมอบพล\u0e31งส\u0e48วนหน\u0e36\u0e48งให\u0e49ก\u0e31บค\u0e38ณ")
				.Croatian("U slučaju vaše smrti, Eikthyr će vas spasiti i dati vam dio svojih moći")
				.Georgian("თქვენი სიკვდილის შემთხვევაში, ეიკთირი გადაგარჩენს და მოგცემთ თავისი ძალების ნაწილს")
				.Greek("Σε περίπτωση θανάτου σας, ο Eikthyr θα σας σώσει και θα σας δώσει ένα μέρος των δυνάμεών του")
				.Serbian("У случају ваше смрти, Еиктхир ће вас спасити и дати вам део својих моћи")
				.Ukrainian("У разі вашої смерті Ейктір врятує вас і віддасть вам частину своїх сил");
			item.Crafting.Add("Altar", 1);
			item.RequiredItems.Add("GreydwarfEye", 10);
			item.RequiredItems.Add("SurtlingCore", 7);
			item.RequiredItems.Add("TrophyEikthyr", 1);
			item.CraftAmount = 1;
			Item item2 = new Item(ModBase.bundle, "TotemOfTheElder");
			item2.Name.English("Totem Of TheElder").Swedish("Totem Of TheElder").French("Totem de l'Ancien")
				.Italian("Totem dell'Anziano")
				.German("Totem des Ältesten")
				.Spanish("Tótem del anciano")
				.Russian("Тотем Древнего")
				.Romanian("Totemul Bătrânului")
				.Bulgarian("Тотемът на Стария")
				.Macedonian("Тотем на постариот")
				.Finnish("Totem Of The Elder")
				.Danish("Totem Of TheElder")
				.Norwegian("Totem Of TheElder")
				.Icelandic("Totem Of TheElder")
				.Turkish("Yaşlıların Totemi")
				.Lithuanian("Vyresniojo totemas")
				.Czech("Totem The Elder")
				.Hungarian("Totem Of The Elder")
				.Slovak("Totem The Elder")
				.Polish("Totem Starszego")
				.Dutch("Totem van de Oudere")
				.Chinese("长者图腾")
				.Japanese("エルダーのトーテム")
				.Korean("장로의 토템")
				.Hindi("बड\u093c\u094b\u0902 क\u093e क\u0941लद\u0947वत\u093e")
				.Thai("Totem ของผ\u0e39\u0e49เฒ\u0e48า")
				.Croatian("Totem Starijeg")
				.Georgian("უფროსის ტოტემი")
				.Greek("Totem Of The Elder")
				.Serbian("Тотем оф Тхе Елдер")
				.Ukrainian("Тотем Старшого");
			item2.Description.English("In case of your death, TheElder will save you and give you a part of his powers").Swedish("Om du dör, kommer TheElder att rädda dig och ge dig en del av sina krafter").French("En cas de décès, TheElder vous sauvera et vous donnera une partie de ses pouvoirs")
				.Italian("In caso di tua morte, TheElder ti salverà e ti darà una parte dei suoi poteri")
				.German("Im Falle Ihres Todes wird The Elder Sie retten und Ihnen einen Teil seiner Kräfte geben")
				.Spanish("En caso de tu muerte, TheElder te salvará y te dará una parte de sus poderes.")
				.Russian("В случае вашей смерти TheElder спасет вас и передаст вам часть своих сил.")
				.Romanian("În cazul morții tale, The Elder te va salva și îți va oferi o parte din puterile sale")
				.Bulgarian("В случай на твоята смърт TheElder ще те спаси и ще ти даде част от силите си")
				.Macedonian("Во случај на твоја смрт, Старецот ќе те спаси и ќе ти даде дел од неговите моќи")
				.Finnish("Jos kuolet, Elder pelastaa sinut ja antaa sinulle osan voimistaan")
				.Danish("I tilfælde af din død, vil TheElder redde dig og give dig en del af hans kræfter")
				.Norwegian("I tilfelle du dør, vil TheElder redde deg og gi deg en del av kreftene hans")
				.Icelandic("Ef þú deyrð mun TheElder bjarga þér og gefa þér hluta af krafti hans")
				.Turkish("Ölümünüz durumunda The Elder sizi kurtaracak ve güçlerinin bir kısmını size verecek")
				.Lithuanian("Jūsų mirties atveju Vyresnysis jus išgelbės ir suteiks jums dalį savo galių")
				.Czech("V případě vaší smrti vás TheElder zachrání a dá vám část svých schopností")
				.Hungarian("Halálod esetén TheElder megment, és hatalmának egy részét átadja neked")
				.Slovak("V prípade vašej smrti vás TheElder zachráni a dá vám časť svojich schopností")
				.Polish("W przypadku twojej śmierci TheElder cię uratuje i przekaże część swoich mocy")
				.Dutch("In het geval van je dood zal TheElder je redden en je een deel van zijn krachten geven")
				.Chinese("如果你死了,长老会救你并给你他的一部分力量")
				.Japanese("あなたが死んだ場合、TheElder はあなたを救い、彼の力の一部をあなたに与えます")
				.Korean("당신이 죽을 경우, TheElder는 당신을 구하고 그의 능력의 일부를 당신에게 줄 것입니다")
				.Hindi("आपक\u0940 म\u0943त\u094dय\u0941 क\u0947 म\u093eमल\u0947 म\u0947\u0902, द एल\u094dडर आपक\u094b बच\u093eएग\u093e और आपक\u094b अपन\u0940 शक\u094dत\u093fय\u094b\u0902 क\u093e एक ह\u093fस\u094dस\u093e द\u0947ग\u093e")
				.Thai("ในกรณ\u0e35ท\u0e35\u0e48ค\u0e38ณเส\u0e35ยช\u0e35ว\u0e34ต TheElder จะช\u0e48วยค\u0e38ณและมอบพล\u0e31งส\u0e48วนหน\u0e36\u0e48งให\u0e49ก\u0e31บค\u0e38ณ")
				.Croatian("U slučaju vaše smrti, TheElder će vas spasiti i dati vam dio svojih moći")
				.Georgian("თქვენი სიკვდილის შემთხვევაში, უხუცესი გადაგარჩენთ და მოგცემთ მისი ძალაუფლების ნაწილს")
				.Greek("Σε περίπτωση θανάτου σας, ο TheElder θα σας σώσει και θα σας δώσει ένα μέρος των δυνάμεών του")
				.Serbian("У случају ваше смрти, Старешина ће вас спасити и дати вам део својих моћи")
				.Ukrainian("У разі вашої смерті Старійшина врятує вас і віддасть вам частину своїх сил");
			item2.Crafting.Add("Altar", 1);
			item2.RequiredItems.Add("GreydwarfEye", 10);
			item2.RequiredItems.Add("SurtlingCore", 7);
			item2.RequiredItems.Add("TrophyTheElder", 1);
			item2.CraftAmount = 1;
			Item item3 = new Item(ModBase.bundle, "TotemOfBonemass");
			item3.Name.English("Totem Of Bonemass").Swedish("Totem Av Benmassa").French("Totem de masse osseuse")
				.Italian("Totem di massa ossea")
				.German("Totem der Knochenmasse")
				.Spanish("Tótem de masa ósea")
				.Russian("Тотем Костяной Массы")
				.Romanian("Totem al Masei Osoase")
				.Bulgarian("Тотем на костната маса")
				.Macedonian("Тотем на коскената маса")
				.Finnish("Totem Of Bonemass")
				.Danish("Totem af knoglemasse")
				.Norwegian("Totem av benmasse")
				.Icelandic("Totem Of Bonemass")
				.Turkish("Kemik Kütlesi Totemi")
				.Lithuanian("Kaulų masės totemas")
				.Czech("Totem Bonemass")
				.Hungarian("Bonemass Totem")
				.Slovak("Totem Bonemass")
				.Polish("Totem Masy Kości")
				.Dutch("Totem van beenmassa")
				.Chinese("骨量图腾")
				.Japanese("骨塊のトーテム")
				.Korean("뼈 덩어리의 토템")
				.Hindi("ब\u094bनम\u093eस क\u093e ट\u094bट\u0947म")
				.Thai("โทเท\u0e47มแห\u0e48งกระด\u0e39ก")
				.Croatian("Totem koštane mase")
				.Georgian("Bonemass-ის ტოტემი")
				.Greek("Totem Of Bonemass")
				.Serbian("Тотем оф Бонемасс")
				.Ukrainian("Тотем кісткової маси");
			item3.Description.English("In case of your death, Bonemass will save you and give you a part of his powers").Swedish("I händelse av din död kommer Bonemass att rädda dig och ge dig en del av sina krafter").French("En cas de décès, Bonemass vous sauvera et vous donnera une partie de ses pouvoirs")
				.Italian("In caso di tua morte, Bonemass ti salverà e ti darà una parte dei suoi poteri")
				.German("Im Falle deines Todes wird Bonemass dich retten und dir einen Teil seiner Kräfte geben")
				.Spanish("En caso de tu muerte, Bonemass te salvará y te dará una parte de sus poderes.")
				.Russian("В случае вашей смерти, Костяная Масса спасет вас и передаст вам часть своих сил.")
				.Romanian("În cazul morții tale, Bonemass te va salva și îți va oferi o parte din puterile lui")
				.Bulgarian("В случай на вашата смърт Bonemass ще ви спаси и ще ви даде част от силите си")
				.Macedonian("Во случај на твоја смрт, Бонемас ќе те спаси и ќе ти даде дел од неговите моќи")
				.Finnish("Jos kuolet, Bonemass pelastaa sinut ja antaa sinulle osan voimistaan")
				.Danish("I tilfælde af din død vil Bonemass redde dig og give dig en del af hans kræfter")
				.Norwegian("I tilfelle du dør, vil Bonemass redde deg og gi deg en del av kreftene hans")
				.Icelandic("Ef þú deyrð, mun Bonemass bjarga þér og gefa þér hluta af krafti hans")
				.Turkish("Ölümünüz durumunda Bonemass sizi kurtaracak ve güçlerinin bir kısmını size verecek")
				.Lithuanian("Jūsų mirties atveju Bonemass jus išgelbės ir suteiks jums dalį savo galių")
				.Czech("V případě vaší smrti vás Bonemass zachrání a dá vám část svých schopností")
				.Hungarian("Halálod esetén Bonemass megment téged, és átadja erejének egy részét")
				.Slovak("V prípade vašej smrti vás Bonemass zachráni a dá vám časť svojich schopností")
				.Polish("W przypadku twojej śmierci Bonemass cię uratuje i przekaże część swoich mocy")
				.Dutch("In het geval van je dood zal Bonemass je redden en je een deel van zijn krachten geven")
				.Chinese("如果你死了,博内玛斯会救你并给你他的一部分力量")
				.Japanese("あなたが死んだ場合、ボーンマスはあなたを救い、彼の力の一部をあなたに与えます")
				.Korean("당신이 죽을 경우, Bonemass는 당신을 구하고 그의 힘의 일부를 줄 것입니다")
				.Hindi("आपक\u0940 म\u0943त\u094dय\u0941 क\u0947 म\u093eमल\u0947 म\u0947\u0902, ब\u094bनम\u093eस आपक\u094b बच\u093eएग\u093e और आपक\u094b अपन\u0940 शक\u094dत\u093fय\u094b\u0902 क\u093e एक ह\u093fस\u094dस\u093e द\u0947ग\u093e")
				.Thai("ในกรณ\u0e35ท\u0e35\u0e48ค\u0e38ณเส\u0e35ยช\u0e35ว\u0e34ต Bonemass จะช\u0e48วยค\u0e38ณและมอบพล\u0e31งส\u0e48วนหน\u0e36\u0e48งให\u0e49ก\u0e31บค\u0e38ณ")
				.Croatian("U slučaju vaše smrti, Bonemass će vas spasiti i dati vam dio svojih moći")
				.Georgian("თქვენი სიკვდილის შემთხვევაში ბონემასი გადაგარჩენთ და მოგცემთ თავისი ძალების ნაწილს")
				.Greek("Σε περίπτωση θανάτου σας, ο Bonemass θα σας σώσει και θα σας δώσει ένα μέρος των δυνάμεών του")
				.Serbian("У случају ваше смрти, Бонемасс ће вас спасити и дати вам део својих моћи")
				.Ukrainian("У разі вашої смерті Бонемас врятує вас і віддасть вам частину своїх сил");
			item3.Crafting.Add("Altar", 1);
			item3.RequiredItems.Add("GreydwarfEye", 10);
			item3.RequiredItems.Add("SurtlingCore", 7);
			item3.RequiredItems.Add("TrophyBonemass", 1);
			item3.CraftAmount = 1;
			Item item4 = new Item(ModBase.bundle, "TotemOfModer");
			item4.Name.English("Totem Of Moder").Swedish("Totem av Moder").French("Totem de Moder")
				.Italian("Totem di moderno")
				.German("Totem von Moder")
				.Spanish("Tótem de Moder")
				.Russian("Тотем Модера")
				.Romanian("Totem al Moderului")
				.Bulgarian("Тотем на Модер")
				.Macedonian("Тотем на Модер")
				.Finnish("Totem Of Moder")
				.Danish("Totem af Moder")
				.Norwegian("Totem Of Moder")
				.Icelandic("Totem Of Moder")
				.Turkish("Moderin Totemi")
				.Lithuanian("Modernaus totemas")
				.Czech("Totem Moder")
				.Hungarian("Moder Totem")
				.Slovak("Totem Modera")
				.Polish("Totem Moderatora")
				.Dutch("Totem van Moder")
				.Chinese("现代图腾")
				.Japanese("モダーのトーテム")
				.Korean("모더의 토템")
				.Hindi("म\u0949डर क\u093e क\u0941लद\u0947वत\u093e")
				.Thai("Totem ของโมเดอร\u0e4c")
				.Croatian("Totem Modera")
				.Georgian("მოდერის ტოტემი")
				.Greek("Totem Of Moder")
				.Serbian("Тотем оф Модер")
				.Ukrainian("Тотем Модера");
			item4.Description.English("In case of your death, Moder will save you and give you a part of his powers").Swedish("Om du dör kommer Moder att rädda dig och ge dig en del av sina krafter").French("En cas de mort, Moder vous sauvera et vous donnera une partie de ses pouvoirs")
				.Italian("In caso di tua morte, Moder ti salverà e ti darà una parte dei suoi poteri")
				.German("Im Falle Ihres Todes wird Moder Sie retten und Ihnen einen Teil seiner Kräfte geben")
				.Spanish("En caso de tu muerte, Moder te salvará y te dará una parte de sus poderes.")
				.Russian("В случае вашей смерти Модер спасет вас и передаст вам часть своих сил.")
				.Romanian("În cazul morții tale, Moder te va salva și îți va oferi o parte din puterile sale")
				.Bulgarian("В случай на вашата смърт, Модер ще ви спаси и ще ви даде част от силите си")
				.Macedonian("Во случај на ваша смрт, Модер ќе ве спаси и ќе ви даде дел од неговите моќи")
				.Finnish("Jos kuolet, Moder pelastaa sinut ja antaa sinulle osan voimistaan")
				.Danish("I tilfælde af din død vil Moder redde dig og give dig en del af sine kræfter")
				.Norwegian("I tilfelle du dør, vil Moder redde deg og gi deg en del av kreftene sine")
				.Icelandic("Ef þú deyrð mun Moder bjarga þér og gefa þér hluta af krafti hans")
				.Turkish("Ölümün durumunda Moder seni kurtaracak ve güçlerinin bir kısmını sana verecek")
				.Lithuanian("Jūsų mirties atveju Moderis jus išgelbės ir suteiks jums dalį savo galių")
				.Czech("V případě vaší smrti vás Moder zachrání a dá vám část svých schopností")
				.Hungarian("Halálod esetén Moder megment téged, és átadja erejének egy részét")
				.Slovak("V prípade vašej smrti vás Moder zachráni a dá vám časť svojich právomocí")
				.Polish("W przypadku Twojej śmierci Moder Cię uratuje i odda Ci część swoich mocy")
				.Dutch("In het geval van je dood zal Moder je redden en je een deel van zijn krachten geven")
				.Chinese("如果你死了,莫德会救你并给你他的一部分力量")
				.Japanese("あなたが死んだ場合、モダーはあなたを救い、彼の力の一部をあなたに与えます")
				.Korean("당신이 죽을 경우, 모더는 당신을 구하고 그의 능력의 일부를 줄 것입니다")
				.Hindi("आपक\u0940 म\u0943त\u094dय\u0941 क\u0947 म\u093eमल\u0947 म\u0947\u0902, म\u0949डर आपक\u094b बच\u093eएग\u093e और आपक\u094b अपन\u0940 शक\u094dत\u093fय\u094b\u0902 क\u093e एक ह\u093fस\u094dस\u093e द\u0947ग\u093e")
				.Thai("ในกรณ\u0e35ท\u0e35\u0e48ค\u0e38ณเส\u0e35ยช\u0e35ว\u0e34ต Moder จะช\u0e48วยค\u0e38ณและมอบพล\u0e31งส\u0e48วนหน\u0e36\u0e48งให\u0e49ก\u0e31บค\u0e38ณ")
				.Croatian("U slučaju vaše smrti, Moder će vas spasiti i dati vam dio svojih moći")
				.Georgian("შენი სიკვდილის შემთხვევაში მოდერი გიშველის და მოგცემს თავისი ძალების ნაწილს")
				.Greek("Σε περίπτωση θανάτου σας, ο Moder θα σας σώσει και θα σας δώσει ένα μέρος των δυνάμεών του")
				.Serbian("У случају ваше смрти, Модер ће вас спасити и дати вам део својих моћи")
				.Ukrainian("У разі вашої смерті Модер врятує вас і віддасть вам частину своїх сил");
			item4.Crafting.Add("Altar", 1);
			item4.RequiredItems.Add("GreydwarfEye", 10);
			item4.RequiredItems.Add("SurtlingCore", 7);
			item4.RequiredItems.Add("TrophyDragonQueen", 1);
			item4.CraftAmount = 1;
			Item item5 = new Item(ModBase.bundle, "TotemOfYagluth");
			item5.Name.English("Totem Of Yagluth").Swedish("Totem av Yagluth").French("Totem de Yagluth")
				.Italian("Totem di Yagluth")
				.German("Totem von Yagluth")
				.Spanish("Tótem de Yagluth")
				.Russian("Тотем Яглута")
				.Romanian("Totem al lui Yagluth")
				.Bulgarian("Тотемът на Яглут")
				.Macedonian("Тотем на Јаглут")
				.Finnish("Yagluthin toteemi")
				.Danish("Totem af Yagluth")
				.Norwegian("Totem av Yagluth")
				.Icelandic("Tótem frá Yagluth")
				.Turkish("Yagluth'un Totemi")
				.Lithuanian("Jagluto totemas")
				.Czech("Totem Yagluth")
				.Hungarian("Yagluth Totem")
				.Slovak("Totem Yagluth")
				.Polish("Totem Yagluth")
				.Dutch("Totem van Yagluth")
				.Chinese("亚格鲁斯图腾")
				.Japanese("ヤグルスのトーテム")
				.Korean("야글루스의 토템")
				.Hindi("यग\u094dल\u0941थ क\u093e क\u0941लद\u0947वत\u093e")
				.Thai("โทเท\u0e47มแห\u0e48งยากล\u0e31ท")
				.Croatian("Totem Yaglutha")
				.Georgian("იაგლუთის ტოტემი")
				.Greek("Τοτέμ Γιαγλούθ")
				.Serbian("Тотем Јаглута")
				.Ukrainian("Тотем Яглута");
			item5.Description.English("In case of your death, Yagluth will save you and give you a part of his powers").Swedish("I fall av din död kommer Yagluth att rädda dig och ge dig en del av sina krafter").French("En cas de mort, Yagluth vous sauvera et vous donnera une partie de ses pouvoirs")
				.Italian("In caso di tua morte, Yagluth ti salverà e ti donerà parte dei suoi poteri")
				.German("Im Falle deines Todes wird Yagluth dich retten und dir einen Teil seiner Kräfte geben")
				.Spanish("En caso de tu muerte, Yagluth te salvará y te dará una parte de sus poderes.")
				.Russian("В случае вашей смерти Яглут спасет вас и передаст вам часть своих сил.")
				.Romanian("În cazul morții tale, Yagluth te va salva și îți va da o parte din puterile lui")
				.Bulgarian("В случай на твоята смърт Yagluth ще те спаси и ще ти даде част от силите си")
				.Macedonian("Во случај на твоја смрт, Јаглут ќе те спаси и ќе ти даде дел од неговите моќи")
				.Finnish("Jos kuolet, Yagluth pelastaa sinut ja antaa sinulle osan voimistaan")
				.Danish("I tilfælde af din død, vil Yagluth redde dig og give dig en del af sine kræfter")
				.Norwegian("I tilfelle du dør, vil Yagluth redde deg og gi deg en del av kreftene hans")
				.Icelandic("Ef þú deyrð, mun Yagluth bjarga þér og gefa þér hluta af krafti hans")
				.Turkish("Ölümün durumunda Yagluth seni kurtaracak ve güçlerinin bir kısmını sana verecek")
				.Lithuanian("Jūsų mirties atveju Yagluth jus išgelbės ir suteiks jums dalį savo galių")
				.Czech("V případě tvé smrti tě Yagluth zachrání a dá ti část svých sil")
				.Hungarian("Halálod esetén Yagluth megment, és hatalmának egy részét átadja neked")
				.Slovak("V prípade vašej smrti vás Yagluth zachráni a dá vám časť svojich schopností")
				.Polish("W przypadku twojej śmierci Yagluth cię uratuje i przekaże część swoich mocy")
				.Dutch("In het geval van je dood zal Yagluth je redden en je een deel van zijn krachten geven")
				.Chinese("如果你死了,亚格鲁斯会救你并给你他的一部分力量")
				.Japanese("あなたが死んだ場合、ヤグルスはあなたを救い、彼の力の一部をあなたに与えます")
				.Korean("당신이 죽을 경우 Yagluth는 당신을 구하고 그의 힘의 일부를 줄 것입니다")
				.Hindi("आपक\u0940 म\u0943त\u094dय\u0941 क\u0947 म\u093eमल\u0947 म\u0947\u0902, य\u093eग\u094dल\u0941थ आपक\u094b बच\u093eएग\u093e और आपक\u094b अपन\u0940 शक\u094dत\u093fय\u094b\u0902 क\u093e एक ह\u093fस\u094dस\u093e द\u0947ग\u093e")
				.Thai("ในกรณ\u0e35ท\u0e35\u0e48ค\u0e38ณเส\u0e35ยช\u0e35ว\u0e34ต Yagluth จะช\u0e48วยค\u0e38ณและมอบพล\u0e31งส\u0e48วนหน\u0e36\u0e48งให\u0e49ก\u0e31บค\u0e38ณ")
				.Croatian("U slučaju vaše smrti, Yagluth će vas spasiti i dati vam dio svojih moći")
				.Georgian("შენი სიკვდილის შემთხვევაში იაგლუტი გადაგარჩენს და მოგცემს თავისი ძალების ნაწილს")
				.Greek("Σε περίπτωση θανάτου σου, ο Yagluth θα σε σώσει και θα σου δώσει ένα μέρος των δυνάμεών του")
				.Serbian("У случају ваше смрти, Иаглутх ће вас спасити и дати вам део својих моћи")
				.Ukrainian("У разі вашої смерті Яглут врятує вас і віддасть вам частину своїх сил");
			item5.Crafting.Add("Altar", 1);
			item5.RequiredItems.Add("GreydwarfEye", 10);
			item5.RequiredItems.Add("SurtlingCore", 7);
			item5.RequiredItems.Add("TrophyGoblinKing", 1);
			item5.CraftAmount = 1;
			BuildPiece buildPiece = new BuildPiece(ModBase.bundle, "Altar");
			buildPiece.Name.English("Altar").Swedish("Altare").French("Autel")
				.Italian("Altare")
				.German("Altar")
				.Spanish("Altar")
				.Russian("Алтарь")
				.Romanian("Altar")
				.Bulgarian("Олтар")
				.Macedonian("Олтар")
				.Finnish("Alttari")
				.Danish("Alter")
				.Norwegian("Alter")
				.Icelandic("Altari")
				.Turkish("Altar")
				.Lithuanian("Altorius")
				.Czech("Oltář")
				.Hungarian("Oltár")
				.Slovak("Oltár")
				.Polish("Ołtarz")
				.Dutch("Altaar")
				.Chinese("坛")
				.Japanese("祭壇")
				.Korean("제단")
				.Hindi("व\u0947द\u0940")
				.Thai("แท\u0e48นบ\u0e39ชา")
				.Croatian("Oltar")
				.Georgian("საკურთხეველი")
				.Greek("Αγια ΤΡΑΠΕΖΑ")
				.Serbian("Олтар")
				.Ukrainian("Вівтар");
			buildPiece.Description.English("Call on the help of defeated bosses by sacrificing their head.").Swedish("Ring på hjälp av besegrade chefer genom att offra deras huvud.").French("Faites appel à l'aide des boss vaincus en sacrifiant leur tête.")
				.Italian("Invoca l'aiuto dei boss sconfitti sacrificando la loro testa.")
				.German("Rufen Sie besiegte Bosse um Hilfe, indem Sie ihren Kopf opfern.")
				.Spanish("Pide la ayuda de los jefes derrotados sacrificando sus cabezas.")
				.Russian("Взови к помощи поверженных боссов, принеся их голову в жертву.")
				.Romanian("Apelați la ajutorul șefilor învinși sacrificându-și capul.")
				.Bulgarian("Потърсете помощта на победените босове, като пожертвате главата им.")
				.Macedonian("Повикајте им помош на поразените газди со жртвување на нивната глава.")
				.Finnish("Pyydä päihitettyjen pomojen apua uhraamalla heidän päänsä.")
				.Danish("Kald på hjælp fra besejrede chefer ved at ofre deres hoved.")
				.Norwegian("Be om hjelp fra beseirede sjefer ved å ofre hodet.")
				.Icelandic("Kallaðu á hjálp ósigraðra yfirmanna með því að fórna höfði þeirra.")
				.Turkish("Başlarını feda ederek mağlup patronların yardımını çağırın.")
				.Lithuanian("Pasikvieskite nugalėtų viršininkų pagalbą, paaukodami jų galvą.")
				.Czech("Přivolejte si na pomoc poražené bossy obětováním jejich hlavy.")
				.Hungarian("Hívd segítségül a legyőzött főnököket a fejük feláldozásával.")
				.Slovak("Privolajte si na pomoc porazených bossov obetovaním ich hlavy.")
				.Polish("Wezwij pomoc pokonanych bossów, poświęcając ich głowę.")
				.Dutch("Roep de hulp in van verslagen bazen door hun hoofd op te offeren.")
				.Chinese("通过牺牲被击败的首领的头颅来寻求帮助。")
				.Japanese("倒したボスの頭を犠牲にして助けを求めます。")
				.Korean("패배한 보스의 머리를 희생하여 도움을 요청하세요.")
				.Hindi("अपन\u0947 स\u093fर क\u093e बल\u093fद\u093eन द\u0947कर पर\u093eज\u093fत म\u093eल\u093fक\u094b\u0902 क\u0940 मदद क\u093e आह\u094dव\u093eन कर\u0947\u0902।")
				.Thai("ขอความช\u0e48วยเหล\u0e37อจากบอสท\u0e35\u0e48พ\u0e48ายแพ\u0e49ด\u0e49วยการเส\u0e35ยสละห\u0e31วของพวกเขา")
				.Croatian("Pozovite u pomoć poražene šefove tako što ćete žrtvovati njihovu glavu.")
				.Georgian("დახმარებისთვის მიმართეთ დამარცხებულ უფროსებს მათი თავის გაწირვით.")
				.Greek("Ζητήστε τη βοήθεια των ηττημένων αφεντικών θυσιάζοντας το κεφάλι τους.")
				.Serbian("Позовите у помоћ поражене шефове жртвујући њихову главу.")
				.Ukrainian("Взивай до допомоги повалених босів, принісши їхню голову в жертву.");
			buildPiece.RequiredItems.Add("Stone", 20, recover: true);
			buildPiece.RequiredItems.Add("SurtlingCore", 10, recover: true);
			buildPiece.Category.Set(BuildPieceCategory.Crafting);
			LoadTotems();
			CustomSE customSE = new CustomSE("totemsofundying_efects", "SE_Yagluth");
			StatusEffect effect = customSE.Effect;
			SE_Stats val = (SE_Stats)(object)((effect is SE_Stats) ? effect : null);
			((StatusEffect)val).m_icon = YagluthTotem.config.itemDrop.m_itemData.GetIcon();
			val.m_mods = new List<DamageModPair>
			{
				new DamageModPair
				{
					m_type = (DamageType)31,
					m_modifier = (DamageModifier)1
				},
				new DamageModPair
				{
					m_type = (DamageType)16,
					m_modifier = (DamageModifier)1
				},
				new DamageModPair
				{
					m_type = (DamageType)4,
					m_modifier = (DamageModifier)1
				},
				new DamageModPair
				{
					m_type = (DamageType)256,
					m_modifier = (DamageModifier)1
				},
				new DamageModPair
				{
					m_type = (DamageType)2,
					m_modifier = (DamageModifier)1
				},
				new DamageModPair
				{
					m_type = (DamageType)512,
					m_modifier = (DamageModifier)1
				},
				new DamageModPair
				{
					m_type = (DamageType)224,
					m_modifier = (DamageModifier)1
				}
			};
			CustomSE customSE2 = new CustomSE("totemsofundying_efects", "SE_Moder");
			customSE2.IconSprite = ModerTotem.config.itemDrop.m_itemData.GetIcon();
			StatusEffect effect2 = customSE2.Effect;
			SE_Stats val2 = (SE_Stats)(object)((effect2 is SE_Stats) ? effect2 : null);
			((StatusEffect)val2).m_icon = ModerTotem.config.itemDrop.m_itemData.GetIcon();
			val2.m_mods = new List<DamageModPair>
			{
				new DamageModPair
				{
					m_type = (DamageType)32,
					m_modifier = (DamageModifier)2
				}
			};
			CustomSE customSE3 = new CustomSE("totemsofundying_efects", "SE_Bonemass");
			customSE3.IconSprite = BonemassTotem.config.itemDrop.m_itemData.GetIcon();
			StatusEffect effect3 = customSE3.Effect;
			SE_Stats val3 = (SE_Stats)(object)((effect3 is SE_Stats) ? effect3 : null);
			((StatusEffect)val3).m_icon = BonemassTotem.config.itemDrop.m_itemData.GetIcon();
			val3.m_mods = new List<DamageModPair>
			{
				new DamageModPair
				{
					m_type = (DamageType)1,
					m_modifier = (DamageModifier)5
				}
			};
			CustomSE customSE4 = new CustomSE("totemsofundying_efects", "SE_Eikthyr");
			customSE4.IconSprite = EikthyrTotem.config.itemDrop.m_itemData.GetIcon();
			StatusEffect effect4 = customSE4.Effect;
			SE_Stats val4 = (SE_Stats)(object)((effect4 is SE_Stats) ? effect4 : null);
			((StatusEffect)val4).m_icon = EikthyrTotem.config.itemDrop.m_itemData.GetIcon();
			val4.m_mods = new List<DamageModPair>
			{
				new DamageModPair
				{
					m_type = (DamageType)128,
					m_modifier = (DamageModifier)5
				}
			};
			CustomSE customSE5 = new CustomSE("totemsofundying_efects", "SE_TheElder");
			customSE5.IconSprite = TheElderTotem.config.itemDrop.m_itemData.GetIcon();
			StatusEffect effect5 = customSE5.Effect;
			SE_Stats val5 = (SE_Stats)(object)((effect5 is SE_Stats) ? effect5 : null);
			((StatusEffect)val5).m_icon = TheElderTotem.config.itemDrop.m_itemData.GetIcon();
			val5.m_modifyAttackSkill = (SkillType)7;
			val5.m_mods = new List<DamageModPair>
			{
				new DamageModPair
				{
					m_type = (DamageType)8,
					m_modifier = (DamageModifier)2
				},
				new DamageModPair
				{
					m_type = (DamageType)4,
					m_modifier = (DamageModifier)1
				}
			};
			Localizer.Load();
		}

		private void LoadTotems()
		{
			//IL_00b6: 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_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: 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)
			EikthyrTotem = Totem.CreateInstance("TotemOfEikthyr");
			EikthyrTotem.config.allBiomes = true;
			EikthyrTotem.config.healthRightBiome = 10;
			EikthyrTotem.config.healthWrongBiome = 10;
			EikthyrTotem.config.staminaRightBiome = 25;
			EikthyrTotem.config.staminaWrongBiome = 25;
			EikthyrTotem.config.speedModifier = 0.1f;
			EikthyrTotem.config.damageModifier = 0f;
			EikthyrTotem.config.Bind();
			TheElderTotem = Totem.CreateInstance("TotemOfTheElder");
			TheElderTotem.config.bestBiome = (Biome)8;
			TheElderTotem.config.badBiome = (Biome)32;
			TheElderTotem.config.aditionalBiomes.Add((Biome)512);
			TheElderTotem.config.healthRightBiome = 50;
			TheElderTotem.config.healthWrongBiome = 20;
			TheElderTotem.config.staminaRightBiome = 45;
			TheElderTotem.config.staminaWrongBiome = 20;
			TheElderTotem.config.speedModifier = 0.1f;
			TheElderTotem.config.damageModifier = 0.13f;
			TheElderTotem.config.Bind();
			BonemassTotem = Totem.CreateInstance("TotemOfBonemass");
			BonemassTotem.config.bestBiome = (Biome)2;
			BonemassTotem.config.badBiome = (Biome)32;
			BonemassTotem.config.healthRightBiome = 40;
			BonemassTotem.config.healthWrongBiome = 50;
			BonemassTotem.config.staminaRightBiome = 130;
			BonemassTotem.config.staminaWrongBiome = 45;
			BonemassTotem.config.speedModifier = 0.2f;
			BonemassTotem.config.buffs.Add("Potion_poisonresist");
			BonemassTotem.config.Bind();
			ModerTotem = Totem.CreateInstance("TotemOfModer");
			ModerTotem.config.bestBiome = (Biome)4;
			ModerTotem.config.aditionalBiomes.Add((Biome)64);
			ModerTotem.config.healthRightBiome = 101;
			ModerTotem.config.healthWrongBiome = 30;
			ModerTotem.config.staminaRightBiome = 60;
			ModerTotem.config.staminaWrongBiome = 50;
			ModerTotem.config.speedModifier = 0.11f;
			ModerTotem.config.fallDamageModifier = -5f;
			ModerTotem.config.buffs.Add("Potion_frostresist");
			ModerTotem.config.Bind();
			YagluthTotem = Totem.CreateInstance("TotemOfYagluth");
			YagluthTotem.config.bestBiome = (Biome)16;
			YagluthTotem.config.badBiome = (Biome)256;
			YagluthTotem.config.aditionalBiomes.Add((Biome)2);
			YagluthTotem.config.aditionalBiomes.Add((Biome)512);
			YagluthTotem.config.aditionalBiomes.Add((Biome)32);
			YagluthTotem.config.healthRightBiome = 150;
			YagluthTotem.config.healthWrongBiome = 80;
			YagluthTotem.config.staminaRightBiome = 60;
			YagluthTotem.config.staminaWrongBiome = 50;
			YagluthTotem.config.speedModifier = 0.5f;
			YagluthTotem.config.damageModifier = 0.5f;
			YagluthTotem.config.buffs.Add("Potion_health_major");
			YagluthTotem.config.buffs.Add("Potion_barleywine");
			YagluthTotem.config.Bind();
			ModBase.Debug("All Totems Loaded");
		}

		public void UseTotem(ItemData itemData, string totemName)
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			Biome currentBiome = Player.m_localPlayer.GetCurrentBiome();
			GetTotem(totemName)?.Use(itemData, currentBiome);
		}

		public static Totem GetTotem(string totemName)
		{
			if (1 == 0)
			{
			}
			Totem result = totemName switch
			{
				"$item_TotemOfEikthyr" => EikthyrTotem, 
				"$item_TotemOfTheElder" => TheElderTotem, 
				"$item_TotemOfBonemass" => BonemassTotem, 
				"$item_TotemOfModer" => ModerTotem, 
				"$item_TotemOfYagluth" => YagluthTotem, 
				_ => null, 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		internal void UpdateConfiguration()
		{
			EikthyrTotem?.config?.UpdateValues();
			TheElderTotem?.config?.UpdateValues();
			BonemassTotem?.config?.UpdateValues();
			ModerTotem?.config?.UpdateValues();
			YagluthTotem?.config?.UpdateValues();
			ModBase.Debug("Configuration Received");
		}
	}
	public class Totem
	{
		internal TotemConfig config { get; }

		public string bossBuff => "SE_" + config.name.Replace("TotemOf", string.Empty);

		public Totem(string name)
		{
			config = new TotemConfig(this, name);
		}

		public static Totem CreateInstance(string name)
		{
			return new Totem(name);
		}

		public void Use(ItemData itemData, Biome biome)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: 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_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
			MessageHud.instance.ShowMessage((MessageType)2, config.name, 0, (Sprite)null);
			if (biome == config.bestBiome || config.allBiomes)
			{
				((Character)Player.m_localPlayer).SetHealth((float)config.healthRightBiome);
				((Character)Player.m_localPlayer).AddStamina((float)config.staminaRightBiome);
				config.buffs.ForEach(delegate(string x)
				{
					((Character)Player.m_localPlayer).m_seman.AddStatusEffect(StringExtensionMethods.GetStableHashCode(x), true, 0, 0f);
				});
				((Character)Player.m_localPlayer).m_seman.AddStatusEffect(StringExtensionMethods.GetStableHashCode(bossBuff), true, 0, 0f);
			}
			else if (config.aditionalBiomes.Contains(biome))
			{
				((Character)Player.m_localPlayer).SetHealth((float)config.healthRightBiome * config.additionalBiomeStatsModifier);
				((Character)Player.m_localPlayer).AddStamina((float)config.staminaRightBiome * config.additionalBiomeStatsModifier);
				if (Random.value <= (float)(config.chanceToActivateBufInAdditionalBiome / 100) && config.buffs.Count > 0)
				{
					config.buffs.ForEach(delegate(string x)
					{
						((Character)Player.m_localPlayer).m_seman.AddStatusEffect(StringExtensionMethods.GetStableHashCode(x), true, 0, 0f);
					});
				}
			}
			else if (biome != config.badBiome)
			{
				((Character)Player.m_localPlayer).SetHealth((float)config.healthWrongBiome);
				((Character)Player.m_localPlayer).AddStamina((float)config.staminaWrongBiome);
			}
			Object.Instantiate<GameObject>(config.fx, new Vector3(((Component)Player.m_localPlayer).transform.position.x, ((Component)Player.m_localPlayer).transform.position.y + 1.4f, ((Component)Player.m_localPlayer).transform.position.z), Quaternion.identity);
			inventory.RemoveItem(itemData, 1);
		}

		public SE_Stats GetSE()
		{
			StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(bossBuff));
			return (SE_Stats)(object)((statusEffect is SE_Stats) ? statusEffect : null);
		}
	}
	[Serializable]
	public class TotemConfig
	{
		public static readonly string[] AllBiomesStrings;

		public float fallDamageModifier;

		public float damageModifier;

		public float speedModifier;

		public int bossBuffTtl = 15;

		public int healthRightBiome = 1;

		public int healthWrongBiome = 1;

		public int staminaRightBiome = 1;

		public int staminaWrongBiome = 1;

		public Biome bestBiome;

		public Biome badBiome;

		public List<Biome> aditionalBiomes = new List<Biome>();

		public bool allBiomes;

		public bool teleportable = true;

		public int maxCountInInventory = 5;

		public List<string> buffs = new List<string>();

		public int chanceToActivateBufInAdditionalBiome = 45;

		public float additionalBiomeStatsModifier = 0.6f;

		public GameObject gameObject;

		public ItemDrop itemDrop;

		public GameObject fx;

		internal ConfigEntry<string> additionalBiomesConfig;

		internal ConfigEntry<float> additionalBiomeStatsModifierConfig;

		internal ConfigEntry<bool> allBiomesConfig;

		internal ConfigEntry<string> badBiomeConfig;

		internal ConfigEntry<int> bossBuffTtlConfig;

		internal ConfigEntry<string> buffsConfig;

		internal ConfigEntry<int> chanceToActivateBuffInAdditionalBiomeConfig;

		internal ConfigEntry<float> damageModifierConfig;

		internal ConfigEntry<float> fallDamageModifierConfig;

		internal ConfigEntry<int> healthRightBiomeConfig;

		internal ConfigEntry<int> healthWrongBiomeConfig;

		internal ConfigEntry<string> mainBiomeConfig;

		internal ConfigEntry<int> maxCountInInventoryConfig;

		internal ConfigEntry<float> speedModifierConfig;

		internal ConfigEntry<int> staminaRightBiomeConfig;

		internal ConfigEntry<int> staminaWrongBiomeConfig;

		internal ConfigEntry<bool> teleportableConfig;

		public string name { get; private set; }

		public Totem totem { get; private set; }

		public TotemConfig(Totem totem, string name)
		{
			this.name = name;
			this.totem = totem;
			gameObject = ModBase.bundle.LoadAsset<GameObject>(name);
			itemDrop = gameObject.GetComponent<ItemDrop>();
			fx = ModBase.bundle.LoadAsset<GameObject>("fx_" + name.Replace("TotemOf", string.Empty));
		}

		public void UpdateValues()
		{
			fallDamageModifier = fallDamageModifierConfig.Value;
			damageModifier = damageModifierConfig.Value;
			speedModifier = speedModifierConfig.Value;
			bossBuffTtl = bossBuffTtlConfig.Value;
			healthRightBiome = healthRightBiomeConfig.Value;
			healthWrongBiome = healthWrongBiomeConfig.Value;
			staminaRightBiome = staminaRightBiomeConfig.Value;
			staminaWrongBiome = staminaWrongBiomeConfig.Value;
			maxCountInInventory = maxCountInInventoryConfig.Value;
			allBiomes = allBiomesConfig.Value;
			teleportable = teleportableConfig.Value;
			chanceToActivateBufInAdditionalBiome = chanceToActivateBuffInAdditionalBiomeConfig.Value;
			additionalBiomeStatsModifier = additionalBiomeStatsModifierConfig.Value;
			if (!Enum.TryParse<Biome>(badBiomeConfig.Value, out badBiome))
			{
				ModBase.DebugError(badBiomeConfig.Value + " is not a valid biome");
			}
			if (!Enum.TryParse<Biome>(mainBiomeConfig.Value, out bestBiome))
			{
				ModBase.DebugError(mainBiomeConfig.Value + " is not a valid biome");
			}
			aditionalBiomes = ((IEnumerable<string>)additionalBiomesConfig.Value.Split(new string[1] { ", " }, StringSplitOptions.RemoveEmptyEntries)).Select((Func<string, Biome>)delegate(string x)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				if (Enum.TryParse<Biome>(x, out Biome result))
				{
					return result;
				}
				ModBase.DebugError(x + " is not a biome.");
				return (Biome)0;
			}).ToList();
			buffs = buffsConfig.Value.Split(new string[1] { ", " }, StringSplitOptions.RemoveEmptyEntries).ToList();
			if (Object.op_Implicit((Object)(object)ObjectDB.instance))
			{
				StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(totem.bossBuff));
				SE_Stats val = (SE_Stats)(object)((statusEffect is SE_Stats) ? statusEffect : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					((StatusEffect)val).m_ttl = bossBuffTtl;
					val.m_speedModifier = speedModifier;
					val.m_damageModifier = damageModifier;
					val.m_fallDamageModifier = fallDamageModifier;
				}
			}
			itemDrop.m_itemData.m_shared.m_teleportable = teleportable;
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				return;
			}
			Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
			if (inventory == null)
			{
				return;
			}
			foreach (ItemData item in from x in inventory.GetAllItems()
				where x.m_shared.m_name == itemDrop.m_itemData.m_shared.m_name
				select x)
			{
				item.m_shared.m_teleportable = teleportable;
			}
			inventory.UpdateTotalWeight();
			InventoryGui.instance.UpdateInventory(Player.m_localPlayer);
		}

		public void Bind()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Expected O, but got Unknown
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Expected O, but got Unknown
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Expected O, but got Unknown
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Expected O, but got Unknown
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Expected O, but got Unknown
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Expected O, but got Unknown
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Expected O, but got Unknown
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Expected O, but got Unknown
			maxCountInInventoryConfig = ModBase.config(name, "Max count in inventory", maxCountInInventory, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 25), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			fallDamageModifierConfig = ModBase.config(name, "Fall damage modifier applied by boss buff", fallDamageModifier, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 5f), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			damageModifierConfig = ModBase.config(name, "Damage modifier applied by boss buff", damageModifier, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 5f), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			speedModifierConfig = ModBase.config(name, "Speed modifier applied by boss buff", speedModifier, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			healthRightBiomeConfig = ModBase.config(name, "Health after dying in best biome", healthRightBiome, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			bossBuffTtlConfig = ModBase.config(name, "Boss buff time", bossBuffTtl, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			healthWrongBiomeConfig = ModBase.config(name, "Health after dying in other biome", healthWrongBiome, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			staminaRightBiomeConfig = ModBase.config(name, "Stamina after dying in best biome", staminaRightBiome, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			staminaWrongBiomeConfig = ModBase.config(name, "Stamina after dying in other biome", staminaWrongBiome, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			mainBiomeConfig = ModBase.config(name, "Best biome", ((object)(Biome)(ref bestBiome)).ToString(), new ConfigDescription("Related to healthBestBiome, healthWrongBiome, staminaBestBiome etc.", (AcceptableValueBase)(object)new AcceptableValueList<string>(AllBiomesStrings), Array.Empty<object>()));
			badBiomeConfig = ModBase.config(name, "Bad biome", ((object)(Biome)(ref badBiome)).ToString(), new ConfigDescription("Totem wouldn't work in this biome", (AcceptableValueBase)(object)new AcceptableValueList<string>(AllBiomesStrings), Array.Empty<object>()));
			additionalBiomesConfig = ModBase.config(name, "Additional biomes", "", new ConfigDescription("The player will receive the same stats as when activated in the best biome multiplied by additionalBiomeStatsModifier", (AcceptableValueBase)null, Array.Empty<object>()));
			allBiomesConfig = ModBase.config(name, "Work in all biomes", allBiomes, new ConfigDescription("", (AcceptableValueBase)null, Array.Empty<object>()));
			teleportableConfig = ModBase.config(name, "Teleportable", teleportable, new ConfigDescription("Is it possible to transfer an item through the portal", (AcceptableValueBase)null, Array.Empty<object>()));
			buffsConfig = ModBase.config(name, "Buffs", "", new ConfigDescription("The effects that the player will receive when activating the totem of the best biome.", (AcceptableValueBase)null, Array.Empty<object>()));
			chanceToActivateBuffInAdditionalBiomeConfig = ModBase.config(name, "Chance to activate buf in additional biome", chanceToActivateBufInAdditionalBiome, new ConfigDescription("The chance that the player will receive buffs when activated in an additional biome.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
			additionalBiomeStatsModifierConfig = ModBase.config(name, "Additional biome stats modifier", additionalBiomeStatsModifier, new ConfigDescription("When activating a totem in an additional biome, the player will receive the same characteristics as when activated in the best biome, but multiplied by this value.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 5f), new object[1]
			{
				new ConfigurationManagerAttributes()
			}));
		}

		static TotemConfig()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[10];
			Biome val = (Biome)0;
			array[0] = ((object)(Biome)(ref val)).ToString();
			val = (Biome)1;
			array[1] = ((object)(Biome)(ref val)).ToString();
			val = (Biome)2;
			array[2] = ((object)(Biome)(ref val)).ToString();
			val = (Biome)4;
			array[3] = ((object)(Biome)(ref val)).ToString();
			val = (Biome)8;
			array[4] = ((object)(Biome)(ref val)).ToString();
			val = (Biome)16;
			array[5] = ((object)(Biome)(ref val)).ToString();
			val = (Biome)32;
			array[6] = ((object)(Biome)(ref val)).ToString();
			val = (Biome)64;
			array[7] = ((object)(Biome)(ref val)).ToString();
			val = (Biome)256;
			array[8] = ((object)(Biome)(ref val)).ToString();
			val = (Biome)512;
			array[9] = ((object)(Biome)(ref val)).ToString();
			AllBiomesStrings = array;
		}
	}
}
namespace TotemsOfUndying.Patch
{
	[HarmonyPatch]
	public class CraftItemDescriptionSize
	{
		private static bool firstCall = true;

		private static float vanilaMinSize;

		[HarmonyWrapSafe]
		[HarmonyPostfix]
		[HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")]
		private static void Patch(InventoryGui __instance)
		{
			if (firstCall)
			{
				vanilaMinSize = __instance.m_recipeDecription.fontSizeMin;
				firstCall = false;
			}
			Recipe key = __instance.m_selectedRecipe.Key;
			if (!((Object)(object)key == (Object)null))
			{
				ItemData itemData = key.m_item.m_itemData;
				if (itemData != null)
				{
					Totem totem = Plugin.GetTotem(itemData.m_shared.m_name);
					__instance.m_recipeDecription.fontSizeMin = ((totem == null) ? vanilaMinSize : 1f);
				}
			}
		}
	}
	[HarmonyPatch]
	public class MaxCountInInventory
	{
		private static bool CheckForTotemsCore(Inventory __instance, ItemData item)
		{
			if (item == null)
			{
				return true;
			}
			Totem totem = Plugin.GetTotem(item.m_shared.m_name);
			if (totem == null)
			{
				return true;
			}
			if (__instance.CountItems(item.m_shared.m_name, -1, true) >= totem.config.maxCountInInventory)
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool CheckForTotems(Inventory __instance, ItemData item)
		{
			return CheckForTotemsCore(__instance, item);
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
		{
			typeof(string),
			typeof(int),
			typeof(int),
			typeof(int),
			typeof(long),
			typeof(string),
			typeof(bool)
		})]
		[HarmonyWrapSafe]
		private static bool CheckForTotems(Inventory __instance, string name)
		{
			ItemData item = ObjectDB.instance.GetItem(name)?.m_itemData;
			return CheckForTotemsCore(__instance, item);
		}
	}
	[HarmonyPatch]
	public class TotemTooltip
	{
		[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
		{
			typeof(ItemData),
			typeof(int),
			typeof(bool),
			typeof(float)
		})]
		[HarmonyPostfix]
		private static void ItemDropItemDataGetTooltip(ItemData item, int qualityLevel, bool crafting, float worldLevel, ref string __result)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			Totem totem = Plugin.GetTotem(item.m_shared.m_name);
			if (totem == null)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			if (!Input.GetKey((KeyCode)304))
			{
				__result += "\n$holdShift".Localize();
				return;
			}
			string text = "<color=orange>" + (totem.config.allBiomes ? "$allBiomes".Localize() : totem.config.bestBiome.GetLocalizationKey().Localize()) + "</color>";
			string text2 = totem.config.badBiome.GetLocalizationKey().Localize();
			stringBuilder.AppendLine();
			stringBuilder.AppendLine(string.Format("<color=#ff8080ff>{0}</color> {1} {2}", totem.config.healthRightBiome, "$healthAfterBiome".Localize(), text));
			stringBuilder.AppendLine(string.Format("<color=yellow>{0}</color> {1} {2}", totem.config.staminaRightBiome, "$staminaAfterBiome".Localize(), text));
			if (!totem.config.allBiomes)
			{
				double num = Math.Round(1f / totem.config.additionalBiomeStatsModifier, 2);
				if (Math.Abs(num - 1.0) > 0.20000000298023224)
				{
					string value = "$lessEffectInBiomes".Localize() + " " + string.Format("<color=yellow>{0}</color> {1} ", num, "$timesInBiomes".Localize()) + "<color=orange>" + (from x in totem.config.aditionalBiomes
						where x.GetLocalizationKey() != "$biome_none"
						select x.GetLocalizationKey().Localize()).GetString("</color>, <color=orange>") + "</color>";
					stringBuilder.AppendLine(value);
				}
				List<string> list = (from x in TotemConfig.AllBiomesStrings
					where x != "None" && x != ((object)(Biome)(ref totem.config.bestBiome)).ToString() && !totem.config.aditionalBiomes.Select((Biome x) => ((object)(Biome)(ref x)).ToString()).Contains<string>(x)
					select BiomeExtension.GetLocalizationKey((Biome)Enum.Parse(typeof(Biome), x)).Localize()).ToList();
				if (list.Count > 0)
				{
					string @string = list.GetString("</color>, <color=orange>");
					stringBuilder.AppendLine(string.Format("<color=#ff8080ff>{0}</color> {1} ", totem.config.healthWrongBiome, "$healthAfterBiome".Localize()) + "<color=orange>" + @string + "</color>");
					stringBuilder.AppendLine(string.Format("<color=yellow>{0}</color> {1} ", totem.config.staminaWrongBiome, "$staminaAfterBiome".Localize()) + "<color=orange>" + @string + "</color>");
				}
				if (text2 != "[biome_none]")
				{
					stringBuilder.AppendLine("$dontWorkInBiome".Localize() + " <color=orange>" + text2 + "</color> ");
				}
				stringBuilder.AppendLine("$chanceToActivateBuffInAdditionalBiome".Localize() + " " + text + " " + $"<color=yellow>{totem.config.chanceToActivateBufInAdditionalBiome}%</color>");
			}
			if (totem.config.buffs.Count > 0)
			{
				stringBuilder.AppendLine("$buffs".Localize() ?? "");
				stringBuilder.AppendLine("<color=orange>" + totem.config.buffs.Select((string x) => ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(x)).m_name.Localize()).GetString("</color>, <color=orange>") + "</color> ");
			}
			stringBuilder.AppendLine("$bossSE_effects".Localize() + " " + text);
			__result += stringBuilder.ToString();
		}
	}
	[HarmonyPatch]
	public class UseTotem
	{
		[HarmonyPatch(typeof(Character), "CheckDeath")]
		[HarmonyPrefix]
		private static void CharacterDeathPatch(Character __instance)
		{
			if (!Application.isFocused || !__instance.IsPlayer() || __instance.IsDead() || !((Object)(object)__instance == (Object)(object)Player.m_localPlayer))
			{
				return;
			}
			Inventory inventory = ((Humanoid)Player.m_localPlayer).GetInventory();
			if (!(Mathf.Floor(__instance.GetHealth()) <= 0f))
			{
				return;
			}
			foreach (ItemData allItem in inventory.GetAllItems())
			{
				if (allItem.m_shared.m_name.StartsWith("$item_TotemOf"))
				{
					ModBase.Debug("Try to use " + allItem.LocalizeName());
					ModBase.GetPlugin<Plugin>().UseTotem(allItem, allItem.m_shared.m_name);
					break;
				}
			}
		}
	}
}
namespace TotemsOfUndying.StatusEffectManager
{
	[PublicAPI]
	[Description("The ItemDrop effect to apply the status effect")]
	public enum EffectType
	{
		Equip,
		Attack,
		Consume,
		Set
	}
	public struct SE_Item
	{
		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(1)]
		public StatusEffect Effect;

		public EffectType Type;
	}
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	[PublicAPI]
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	public class CustomSE
	{
		private static readonly List<CustomSE> RegisteredEffects = new List<CustomSE>();

		private static readonly Dictionary<StatusEffect, CustomSE> CustomEffectMap = new Dictionary<StatusEffect, CustomSE>();

		internal static readonly List<StatusEffect> CustomSEs = new List<StatusEffect>();

		internal static readonly Dictionary<SE_Item, string> AddToPrefabs = new Dictionary<SE_Item, string>();

		[Description("Instance of the StatusEffect.")]
		public readonly StatusEffect Effect;

		[Description("Set the type of effect you are adding. If the item can attack, consume, or be equipped, change this to correspond.")]
		public EffectType Type;

		private string _folderName = "icons";

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		private AssetBundle _assetBundle;

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		[Description("Sets the icon for the StatusEffect. Must be 64x64")]
		public Sprite IconSprite;

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		private string IconName;

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		private LocalizeKey _name;

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		private static Localization _english;

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync = true;

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		private static object _configSync;

		[Description("Sets the icon for the StatusEffect. Must be 64x64")]
		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		public string Icon
		{
			[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(2)]
			get
			{
				return IconName;
			}
			[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(2)]
			set
			{
				IconName = value;
				IconSprite = ((IconName == null) ? null : loadSprite(IconName));
				Effect.m_icon = IconSprite;
			}
		}

		[Description("Sets the in-game name for the StatusEffect")]
		public LocalizeKey Name
		{
			get
			{
				LocalizeKey name = _name;
				if (name != null)
				{
					return name;
				}
				StatusEffect effect = Effect;
				if (effect.m_name.StartsWith("$"))
				{
					_name = new LocalizeKey(effect.m_name);
				}
				else
				{
					string text = "$statuseffect_" + ((Object)Effect).name.Replace(" ", "_");
					_name = new LocalizeKey(text).English(effect.m_name);
					effect.m_name = text;
				}
				return _name;
			}
		}

		private static Localization english
		{
			get
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Expected O, but got Unknown
				if (_english == null)
				{
					_english = new Localization();
					_english.SetupLanguage("English");
				}
				return _english;
			}
		}

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		private static object configSync
		{
			[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(2)]
			get
			{
				if (_configSync == null && hasConfigSync)
				{
					Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync");
					if ((object)type != null)
					{
						_configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " ItemManager");
						type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
						type.GetProperty("IsLocked").SetValue(_configSync, true);
					}
					else
					{
						hasConfigSync = false;
					}
				}
				return _configSync;
			}
		}

		public CustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets")
			: this(EffectManager.RegisterAssetBundle(assetBundleFileName, folderName), customEffectName)
		{
		}

		public CustomSE(AssetBundle bundle, string customEffectName)
		{
			Effect = EffectManager.RegisterCustomSE(bundle, customEffectName);
			RegisteredEffects.Add(this);
			CustomEffectMap[Effect] = this;
		}

		public CustomSE(string customEffectName)
		{
			Effect = ScriptableObject.CreateInstance<StatusEffect>();
			EffectManager.RegisterCustomSE(Effect, customEffectName);
			RegisteredEffects.Add(this);
			CustomEffectMap[Effect] = this;
		}

		[return: <cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		private byte[] ReadEmbeddedFileBytes(string name)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ((_folderName == "") ? "" : ".") + _folderName + "." + name);
			if (manifestResourceStream == null)
			{
				return null;
			}
			manifestResourceStream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		[return: <cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		private Texture2D loadTexture(string name)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			byte[] array = ReadEmbeddedFileBytes(name);
			if (array != null)
			{
				Texture2D val = new Texture2D(0, 0);
				ImageConversion.LoadImage(val, array);
				return val;
			}
			return null;
		}

		private Sprite loadSprite(string name)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = loadTexture(name);
			if (val != null)
			{
				return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), Vector2.zero);
			}
			AssetBundle assetBundle = _assetBundle;
			Sprite val2 = ((assetBundle != null) ? assetBundle.LoadAsset<Sprite>(name) : null);
			if (val2 != null)
			{
				return val2;
			}
			throw new FileNotFoundException("Could not find a file named " + name + " for the effect icon");
		}

		[Description("Adds the CustomSE to a prefab by adding it on ZNetScene awake. The effect type will be used to determine when the effect applies.")]
		public void AddSEToPrefab(CustomSE customSE, string prefabName)
		{
			SE_Item sE_Item = default(SE_Item);
			sE_Item.Effect = customSE.Effect;
			sE_Item.Type = customSE.Type;
			SE_Item key = sE_Item;
			AddToPrefabs.Add(key, prefabName);
		}

		private static ConfigEntry<T> config<[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)] T>(string group, string name, T value, ConfigDescription description)
		{
			ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description);
			configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T))
				.Invoke(configSync, new object[1] { val });
			return val;
		}

		private static ConfigEntry<T> config<[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)] T>(string group, string name, T value, string description)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	[PublicAPI]
	public class LocalizeKey
	{
		public readonly string Key = key.Replace("$", "");

		public LocalizeKey(string key)
		{
		}

		public LocalizeKey English(string key)
		{
			return addForLang("English", key);
		}

		public LocalizeKey Swedish(string key)
		{
			return addForLang("Swedish", key);
		}

		public LocalizeKey French(string key)
		{
			return addForLang("French", key);
		}

		public LocalizeKey Italian(string key)
		{
			return addForLang("Italian", key);
		}

		public LocalizeKey German(string key)
		{
			return addForLang("German", key);
		}

		public LocalizeKey Spanish(string key)
		{
			return addForLang("Spanish", key);
		}

		public LocalizeKey Russian(string key)
		{
			return addForLang("Russian", key);
		}

		public LocalizeKey Romanian(string key)
		{
			return addForLang("Romanian", key);
		}

		public LocalizeKey Bulgarian(string key)
		{
			return addForLang("Bulgarian", key);
		}

		public LocalizeKey Macedonian(string key)
		{
			return addForLang("Macedonian", key);
		}

		public LocalizeKey Finnish(string key)
		{
			return addForLang("Finnish", key);
		}

		public LocalizeKey Danish(string key)
		{
			return addForLang("Danish", key);
		}

		public LocalizeKey Norwegian(string key)
		{
			return addForLang("Norwegian", key);
		}

		public LocalizeKey Icelandic(string key)
		{
			return addForLang("Icelandic", key);
		}

		public LocalizeKey Turkish(string key)
		{
			return addForLang("Turkish", key);
		}

		public LocalizeKey Lithuanian(string key)
		{
			return addForLang("Lithuanian", key);
		}

		public LocalizeKey Czech(string key)
		{
			return addForLang("Czech", key);
		}

		public LocalizeKey Hungarian(string key)
		{
			return addForLang("Hungarian", key);
		}

		public LocalizeKey Slovak(string key)
		{
			return addForLang("Slovak", key);
		}

		public LocalizeKey Polish(string key)
		{
			return addForLang("Polish", key);
		}

		public LocalizeKey Dutch(string key)
		{
			return addForLang("Dutch", key);
		}

		public LocalizeKey Portuguese_European(string key)
		{
			return addForLang("Portuguese_European", key);
		}

		public LocalizeKey Portuguese_Brazilian(string key)
		{
			return addForLang("Portuguese_Brazilian", key);
		}

		public LocalizeKey Chinese(string key)
		{
			return addForLang("Chinese", key);
		}

		public LocalizeKey Japanese(string key)
		{
			return addForLang("Japanese", key);
		}

		public LocalizeKey Korean(string key)
		{
			return addForLang("Korean", key);
		}

		public LocalizeKey Hindi(string key)
		{
			return addForLang("Hindi", key);
		}

		public LocalizeKey Thai(string key)
		{
			return addForLang("Thai", key);
		}

		public LocalizeKey Abenaki(string key)
		{
			return addForLang("Abenaki", key);
		}

		public LocalizeKey Croatian(string key)
		{
			return addForLang("Croatian", key);
		}

		public LocalizeKey Georgian(string key)
		{
			return addForLang("Georgian", key);
		}

		public LocalizeKey Greek(string key)
		{
			return addForLang("Greek", key);
		}

		public LocalizeKey Serbian(string key)
		{
			return addForLang("Serbian", key);
		}

		public LocalizeKey Ukrainian(string key)
		{
			return addForLang("Ukrainian", key);
		}

		private LocalizeKey addForLang(string lang, string value)
		{
			if (Localization.instance.GetSelectedLanguage() == lang)
			{
				Localization.instance.AddWord(Key, value);
			}
			else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key))
			{
				Localization.instance.AddWord(Key, value);
			}
			return this;
		}
	}
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	public static class EffectManager
	{
		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
		private struct BundleId
		{
			[UsedImplicitly]
			public string assetBundleFileName;

			[UsedImplicitly]
			public string folderName;
		}

		private static readonly Dictionary<BundleId, AssetBundle> bundleCache;

		static EffectManager()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			bundleCache = new Dictionary<BundleId, AssetBundle>();
			Harmony val = new Harmony("org.bepinex.helpers.StatusEffectManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static AssetBundle RegisterAssetBundle(string assetBundleFileName, string folderName = "assets")
		{
			BundleId bundleId = default(BundleId);
			bundleId.assetBundleFileName = assetBundleFileName;
			bundleId.folderName = folderName;
			BundleId key = bundleId;
			if (!bundleCache.TryGetValue(key, out var value))
			{
				Dictionary<BundleId, AssetBundle> dictionary = bundleCache;
				AssetBundle? obj = ((IEnumerable<AssetBundle>)Resources.FindObjectsOfTypeAll<AssetBundle>()).FirstOrDefault((Func<AssetBundle, bool>)([<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(0)] (AssetBundle a) => ((Object)a).name == assetBundleFileName)) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ((folderName == "") ? "" : ".") + folderName + "." + assetBundleFileName));
				AssetBundle result = obj;
				dictionary[key] = obj;
				return result;
			}
			return value;
		}

		public static StatusEffect RegisterCustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets")
		{
			return RegisterCustomSE(RegisterAssetBundle(assetBundleFileName, folderName), customEffectName);
		}

		public static StatusEffect RegisterCustomSE(AssetBundle assets, string customEffectName)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			StatusEffect val = (StatusEffect)assets.LoadAsset<ScriptableObject>(customEffectName);
			CustomSE.CustomSEs.Add(val);
			return val;
		}

		public static StatusEffect RegisterCustomSE(StatusEffect customSE, string customEffectName)
		{
			((Object)customSE).name = customEffectName;
			CustomSE.CustomSEs.Add(customSE);
			return customSE;
		}

		[HarmonyPriority(700)]
		private static void Patch_ObjectDBInit(ObjectDB __instance)
		{
			foreach (StatusEffect customSE in CustomSE.CustomSEs)
			{
				if (!__instance.m_StatusEffects.Contains(customSE))
				{
					__instance.m_StatusEffects.Add(customSE);
				}
			}
			__instance.UpdateItemHashes();
		}

		[HarmonyPriority(700)]
		private static void Patch_ZNetSceneAwake(ZNetScene __instance)
		{
			foreach (KeyValuePair<SE_Item, string> addToPrefab in CustomSE.AddToPrefabs)
			{
				try
				{
					GameObject prefab = __instance.GetPrefab(addToPrefab.Value);
					ItemDrop val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<ItemDrop>() : prefab.GetComponentInChildren<ItemDrop>());
					Aoe val2 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Aoe>() : prefab.GetComponentInChildren<Aoe>());
					EffectArea val3 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<EffectArea>() : prefab.GetComponentInChildren<EffectArea>());
					if (Object.op_Implicit((Object)(object)val))
					{
						switch (addToPrefab.Key.Type)
						{
						case EffectType.Equip:
							val.m_itemData.m_shared.m_equipStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Attack:
							val.m_itemData.m_shared.m_attackStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Consume:
							val.m_itemData.m_shared.m_consumeStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Set:
							val.m_itemData.m_shared.m_setSize = 1;
							val.m_itemData.m_shared.m_setName = ((Object)addToPrefab.Key.Effect).name;
							val.m_itemData.m_shared.m_setStatusEffect = addToPrefab.Key.Effect;
							break;
						default:
							throw new ArgumentOutOfRangeException();
						}
					}
					else if (Object.op_Implicit((Object)(object)val2))
					{
						val2.m_statusEffect = ((Object)addToPrefab.Key.Effect).name;
					}
					else if (Object.op_Implicit((Object)(object)val3))
					{
						val3.m_statusEffect = ((Object)addToPrefab.Key.Effect).name;
					}
					else
					{
						ModBase.DebugWarning("The prefab '" + ((Object)prefab).name + "' does not have an ItemDrop, AOE, or EffectArea component. Cannot add the StatusEffect to the prefab.");
					}
				}
				catch (Exception)
				{
					ModBase.DebugWarning("BROKE");
				}
			}
		}
	}
}
namespace TotemsOfUndying.PieceManager
{
	[PublicAPI]
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	public static class MaterialReplacer
	{
		[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(0)]
		public enum ShaderType
		{
			PieceShader,
			VegetationShader,
			RockShader,
			RugShader,
			GrassShader,
			CustomCreature,
			UseUnityShader
		}

		private static readonly Dictionary<GameObject, bool> ObjectToSwap;

		private static readonly Dictionary<string, Material> OriginalMaterials;

		private static readonly Dictionary<GameObject, ShaderType> ObjectsForShaderReplace;

		private static readonly HashSet<Shader> CachedShaders;

		private static bool hasRun;

		static MaterialReplacer()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			CachedShaders = new HashSet<Shader>();
			OriginalMaterials = new Dictionary<string, Material>();
			ObjectToSwap = new Dictionary<GameObject, bool>();
			ObjectsForShaderReplace = new Dictionary<GameObject, ShaderType>();
			Harmony val = new Harmony("org.bepinex.helpers.PieceManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZoneSystem), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MaterialReplacer), "ReplaceAllMaterialsWithOriginal", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static void RegisterGameObjectForShaderSwap(GameObject go, ShaderType type)
		{
			if (!ObjectsForShaderReplace.ContainsKey(go))
			{
				ObjectsForShaderReplace.Add(go, type);
			}
		}

		public static void RegisterGameObjectForMatSwap(GameObject go, bool isJotunnMock = false)
		{
			if (!ObjectToSwap.ContainsKey(go))
			{
				ObjectToSwap.Add(go, isJotunnMock);
			}
		}

		private static void GetAllMaterials()
		{
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			foreach (Material val in array)
			{
				OriginalMaterials[((Object)val).name] = val;
			}
		}

		[HarmonyPriority(700)]
		private static void ReplaceAllMaterialsWithOriginal()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)SystemInfo.graphicsDeviceType == 4 || hasRun)
			{
				return;
			}
			if (OriginalMaterials.Count == 0)
			{
				GetAllMaterials();
			}
			foreach (KeyValuePair<GameObject, bool> item in ObjectToSwap)
			{
				GameObject key = item.Key;
				bool value = item.Value;
				ProcessGameObjectMaterials(key, value);
			}
			AssetBundle[] array = Resources.FindObjectsOfTypeAll<AssetBundle>();
			AssetBundle[] array2 = array;
			foreach (AssetBundle val in array2)
			{
				IEnumerable<Shader> enumerable3;
				try
				{
					IEnumerable<Shader> enumerable2;
					if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val))
					{
						IEnumerable<Shader> enumerable = val.LoadAllAssets<Shader>();
						enumerable2 = enumerable;
					}
					else
					{
						enumerable2 = from shader in ((IEnumerable<string>)val.GetAllAssetNames()).Select((Func<string, Shader>)val.LoadAsset<Shader>)
							where (Object)(object)shader != (Object)null
							select shader;
					}
					enumerable3 = enumerable2;
				}
				catch (Exception)
				{
					continue;
				}
				if (enumerable3 == null)
				{
					continue;
				}
				foreach (Shader item2 in enumerable3)
				{
					CachedShaders.Add(item2);
				}
			}
			foreach (KeyValuePair<GameObject, ShaderType> item3 in ObjectsForShaderReplace)
			{
				GameObject key2 = item3.Key;
				ShaderType value2 = item3.Value;
				ProcessGameObjectShaders(key2, value2);
			}
			hasRun = true;
		}

		private static void ProcessGameObjectMaterials(GameObject go, bool isJotunnMock)
		{
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material[] sharedMaterials = val.sharedMaterials.Select([<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(0)] (Material material) => ReplaceMaterial(material, isJotunnMock)).ToArray();
				val.sharedMaterials = sharedMaterials;
			}
		}

		private static Material ReplaceMaterial(Material originalMaterial, bool isJotunnMock)
		{
			string text = (isJotunnMock ? "JVLmock_" : "_REPLACE_");
			if (!((Object)originalMaterial).name.StartsWith(text, StringComparison.Ordinal))
			{
				return originalMaterial;
			}
			string text2 = ((Object)originalMaterial).name.Replace(" (Instance)", "").Replace(text, "");
			if (OriginalMaterials.TryGetValue(text2, out var value))
			{
				return value;
			}
			ModBase.DebugWarning("No suitable material found to replace: " + text2);
			return originalMaterial;
		}

		private static void ProcessGameObjectShaders(GameObject go, ShaderType shaderType)
		{
			Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				foreach (Material val2 in sharedMaterials)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						val2.shader = GetShaderForType(val2.shader, shaderType, ((Object)val2.shader).name);
					}
				}
			}
		}

		private static Shader GetShaderForType(Shader orig, ShaderType shaderType, string originalShaderName)
		{
			return (Shader)(shaderType switch
			{
				ShaderType.PieceShader => FindShaderWithName(orig, "Custom/Piece"), 
				ShaderType.VegetationShader => FindShaderWithName(orig, "Custom/Vegetation"), 
				ShaderType.RockShader => FindShaderWithName(orig, "Custom/StaticRock"), 
				ShaderType.RugShader => FindShaderWithName(orig, "Custom/Rug"), 
				ShaderType.GrassShader => FindShaderWithName(orig, "Custom/Grass"), 
				ShaderType.CustomCreature => FindShaderWithName(orig, "Custom/Creature"), 
				ShaderType.UseUnityShader => FindShaderWithName(orig, ((Object)(object)FindShaderWithName(orig, originalShaderName) != (Object)null) ? originalShaderName : "ToonDeferredShading2017"), 
				_ => FindShaderWithName(orig, "Standard"), 
			});
		}

		public static Shader FindShaderWithName(Shader origShader, string name)
		{
			foreach (Shader cachedShader in CachedShaders)
			{
				if (((Object)cachedShader).name == name)
				{
					return cachedShader;
				}
			}
			return origShader;
		}
	}
	[PublicAPI]
	public enum CraftingTable
	{
		None,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[InternalName("blackforge")]
		BlackForge,
		Custom
	}
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	public class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	public class ExtensionList
	{
		public readonly List<ExtensionConfig> ExtensionStations = new List<ExtensionConfig>();

		public void Set(CraftingTable table, int maxStationDistance = 5)
		{
			ExtensionStations.Add(new ExtensionConfig
			{
				Table = table,
				maxStationDistance = maxStationDistance
			});
		}

		public void Set(string customTable, int maxStationDistance = 5)
		{
			ExtensionStations.Add(new ExtensionConfig
			{
				Table = CraftingTable.Custom,
				custom = customTable,
				maxStationDistance = maxStationDistance
			});
		}
	}
	public struct ExtensionConfig
	{
		public CraftingTable Table;

		public float maxStationDistance;

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		public string custom;
	}
	[PublicAPI]
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	public class CraftingStationList
	{
		public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>();

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

		public void Set(string customTable)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = CraftingTable.Custom,
				custom = customTable
			});
		}
	}
	public struct CraftingStationConfig
	{
		public CraftingTable Table;

		public int level;

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
		public string custom;
	}
	[PublicAPI]
	public enum BuildPieceCategory
	{
		Misc = 0,
		Crafting = 1,
		Building = 2,
		Furniture = 3,
		All = 100,
		Custom = 99
	}
	[PublicAPI]
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	public class RequiredResourcesList
	{
		public readonly List<Requirement> Requirements = new List<Requirement>();

		public void Add(string item, int amount, bool recover)
		{
			Requirements.Add(new Requirement
			{
				itemName = item,
				amount = amount,
				recover = recover
			});
		}
	}
	public struct Requirement
	{
		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(1)]
		public string itemName;

		public int amount;

		public bool recover;
	}
	public struct SpecialProperties
	{
		[Description("Admins should be the only ones that can build this piece.")]
		public bool AdminOnly;

		[Description("Turns off generating a config for this build piece.")]
		public bool NoConfig;
	}
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	[PublicAPI]
	public class BuildingPieceCategory
	{
		public BuildPieceCategory Category;

		public string custom = "";

		public void Set(BuildPieceCategory category)
		{
			Category = category;
		}

		public void Set(string customCategory)
		{
			Category = BuildPieceCategory.Custom;
			custom = customCategory;
		}
	}
	[PublicAPI]
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	public class PieceTool
	{
		public readonly HashSet<string> Tools = new HashSet<string>();

		public void Add(string tool)
		{
			Tools.Add(tool);
		}
	}
	[PublicAPI]
	[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
	[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(1)]
	public class BuildPiece
	{
		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
		internal class PieceConfig
		{
			public ConfigEntry<string> craft = null;

			public ConfigEntry<BuildPieceCategory> category = null;

			public ConfigEntry<string> customCategory = null;

			public ConfigEntry<string> tools = null;

			public ConfigEntry<CraftingTable> extensionTable = null;

			public ConfigEntry<string> customExtentionTable = null;

			public ConfigEntry<float> maxStationDistance = null;

			public ConfigEntry<CraftingTable> table = null;

			public ConfigEntry<string> customTable = null;
		}

		[<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order;

			[UsedImplicitly]
			public bool? Browsable;

			[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(2)]
			[UsedImplicitly]
			public string Category;

			[UsedImplicitly]
			[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer;
		}

		[<cb9d0274-549a-4593-bd8d-d0619a9c0bd8>Nullable(0)]
		private class SerializedRequirements
		{
			public readonly List<Requirement> Reqs;

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

			public SerializedRequirements(string reqs)
			{
				Reqs = reqs.Split(new char[1] { ',' }).Select([<6438ce56-b3a0-489a-a74b-277ccd7278b8>NullableCont