Decompiled source of BlightedWorldHeart v1.0.5

BlightedWorldHeart/plugins/BlightedHeart.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: AssemblyCompany("BlightedHeart")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A Valheim mod that adds the Blighted World Heart boss.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BlightedHeart")]
[assembly: AssemblyTitle("BlightedHeart")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class TestCompile
{
	public void Test(ZNetView nview)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		ZDOID none = ZDOID.None;
		nview.GetZDO().Set("subboss", none);
		nview.GetZDO().GetZDOID("subboss");
	}
}
namespace BlightedHeart
{
	[HarmonyPatch(typeof(Character), "OnDeath")]
	public static class BlightedHeartLoot
	{
		public static void Prefix(Character __instance)
		{
			//IL_0023: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			BlightedWorldHeartAI component = ((Component)__instance).GetComponent<BlightedWorldHeartAI>();
			if ((Object)(object)component != (Object)null && __instance.IsOwner())
			{
				Logger.LogInfo((object)"Blighted World Heart defeated! Dropping loot...");
				DropLoot(component.CurrentBiome, ((Component)__instance).transform.position + Vector3.up * 2f);
			}
		}

		private static void DropLoot(Biome biome, Vector3 dropPosition)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			if (!BlightedConfigManager.BiomeConfigs.TryGetValue(biome, out var value))
			{
				return;
			}
			float value2 = value.LootScaleFactor.Value;
			List<string> list = new List<string>();
			if (BlightedItemsManager.BiomeWeaponDrops.TryGetValue(biome, out var value3))
			{
				list.AddRange(value3);
			}
			if (BlightedItemsManager.BiomeArmorDrops.TryGetValue(biome, out var value4))
			{
				list.AddRange(value4);
			}
			if (list.Count == 0)
			{
				return;
			}
			int num = Mathf.CeilToInt(2f * value2);
			for (int i = 0; i < num; i++)
			{
				string text = list[Random.Range(0, list.Count)];
				GameObject prefab = PrefabManager.Instance.GetPrefab(text);
				if ((Object)(object)prefab != (Object)null)
				{
					Vector3 val = dropPosition + Random.insideUnitSphere * 2f;
					Object.Instantiate<GameObject>(prefab, val, Quaternion.identity);
				}
			}
		}
	}
	[HarmonyPatch(typeof(OfferingBowl))]
	public static class BlightedHeartSpawning
	{
		[HarmonyPatch("Interact")]
		[HarmonyPrefix]
		public static bool InteractPrefix(OfferingBowl __instance, Humanoid user, bool hold, bool alt)
		{
			if (hold)
			{
				return true;
			}
			_ = (Object)(object)__instance.m_bossPrefab == (Object)null;
			return true;
		}

		[HarmonyPatch("UseItem")]
		[HarmonyPrefix]
		public static bool UseItemPrefix(OfferingBowl __instance, Humanoid user, ItemData item, ref bool __result)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.m_bossPrefab == (Object)null)
			{
				return true;
			}
			Biome key = Heightmap.FindBiome(((Component)__instance).transform.position);
			if (!BlightedConfigManager.BiomeConfigs.TryGetValue(key, out var value))
			{
				return true;
			}
			string value2 = value.AltarSummonItem.Value;
			int value3 = value.AltarSummonAmount.Value;
			if (((Object)item.m_dropPrefab).name == value2)
			{
				if (item.m_stack < value3)
				{
					((Character)user).Message((MessageType)2, $"Need {value3} {item.m_shared.m_name}", 0, (Sprite)null);
					__result = true;
					return false;
				}
				user.GetInventory().RemoveItem(item, value3);
				((Character)user).Message((MessageType)2, "The Blighted World Heart awakens!", 0, (Sprite)null);
				SpawnBlightedHeart(__instance, user);
				__result = true;
				return false;
			}
			return true;
		}

		private static void SpawnBlightedHeart(OfferingBowl bowl, Humanoid user)
		{
			((MonoBehaviour)bowl).StartCoroutine(SpawnBlightedHeartCoroutine(bowl, user));
		}

		private static IEnumerator SpawnBlightedHeartCoroutine(OfferingBowl bowl, Humanoid user)
		{
			GameObject heartPrefab = PrefabManager.Instance.GetPrefab("BlightedWorldHeart");
			if ((Object)(object)heartPrefab == (Object)null)
			{
				Logger.LogError((object)"Failed to get BlightedWorldHeart prefab for spawning.");
				yield break;
			}
			Vector3 spawnPos = ((Component)bowl).transform.position + Vector3.up * 1f;
			if ((int)Heightmap.FindBiome(spawnPos) == 2 && (Object)(object)user != (Object)null)
			{
				Vector3 val = ((Component)user).transform.position - ((Component)bowl).transform.position;
				val.y = 0f;
				spawnPos += ((Vector3)(ref val)).normalized * 12f;
			}
			float y = default(float);
			if (ZoneSystem.instance.GetSolidHeight(spawnPos, ref y, 1000))
			{
				spawnPos.y = y;
			}
			if (bowl.m_spawnBossStartEffects != null)
			{
				bowl.m_spawnBossStartEffects.Create(spawnPos, Quaternion.identity, (Transform)null, 1f, -1);
			}
			yield return (object)new WaitForSeconds((bowl.m_spawnBossDelay > 0f) ? bowl.m_spawnBossDelay : 8f);
			GameObject obj = Object.Instantiate<GameObject>(heartPrefab, spawnPos, Quaternion.identity);
			Biome biome = Heightmap.FindBiome(spawnPos);
			BlightedWorldHeartAI component = obj.GetComponent<BlightedWorldHeartAI>();
			if ((Object)(object)component != (Object)null)
			{
				component.Initialize(biome);
			}
		}
	}
	public static class BlightedItemsManager
	{
		public static Dictionary<Biome, List<string>> BiomeWeaponDrops = new Dictionary<Biome, List<string>>();

		public static Dictionary<Biome, List<string>> BiomeArmorDrops = new Dictionary<Biome, List<string>>();

		private static Dictionary<string, string> _deferredRecipeLookups = new Dictionary<string, string>();

		private static bool _recipesResolved = false;

		public static void Setup()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Setup;
			Logger.LogInfo((object)"Setting up Blighted custom items...");
			CreateBiomeItems((Biome)1, new string[3] { "Club", "SpearFlint", "Bow" }, new string[5] { "ArmorLeatherChest", "ArmorLeatherLegs", "HelmetLeather", "CapeDeerHide", "ShieldWood" });
			CreateBiomeItems((Biome)8, new string[3] { "SwordBronze", "MaceBronze", "AxeBronze" }, new string[5] { "ArmorBronzeChest", "ArmorBronzeLegs", "HelmetBronze", "CapeTrollHide", "ShieldBronzeBuckler" });
			CreateBiomeItems((Biome)2, new string[3] { "SwordIron", "MaceIron", "Battleaxe" }, new string[4] { "ArmorIronChest", "ArmorIronLegs", "HelmetIron", "ShieldBanded" });
			CreateBiomeItems((Biome)4, new string[2] { "SwordSilver", "BowDraugrFang" }, new string[5] { "ArmorWolfChest", "ArmorWolfLegs", "HelmetDrake", "CapeWolf", "ShieldSilver" });
			CreateBiomeItems((Biome)16, new string[3] { "SwordBlackmetal", "MaceNeedle", "AtgeirBlackmetal" }, new string[5] { "ArmorPaddedCuirass", "ArmorPaddedGreaves", "HelmetPadded", "CapeLox", "ShieldBlackmetal" });
			CreateBiomeItems((Biome)512, new string[2] { "SwordMistwalker", "BowSpineSnap" }, new string[5] { "ArmorCarapaceChest", "ArmorCarapaceLegs", "HelmetCarapace", "CapeFeather", "ShieldCarapace" });
			CreateBiomeItems((Biome)32, new string[2] { "SwordFlametal", "MaceFlametal" }, new string[5] { "ArmorFlametalChest", "ArmorFlametalLegs", "HelmetFlametal", "CapeAsh", "ShieldFlametal" });
			CreateBiomeItems((Biome)64, new string[2] { "SwordSilver", "BowDraugrFang" }, new string[5] { "ArmorWolfChest", "ArmorWolfLegs", "HelmetDrake", "CapeWolf", "ShieldSilver" });
			Logger.LogInfo((object)"Blighted custom items created.");
		}

		private static void CreateBiomeItems(Biome biome, string[] weapons, string[] armors)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			float scale = 1f;
			if (BlightedConfigManager.BiomeConfigs.TryGetValue(biome, out var value))
			{
				scale = value.LootScaleFactor.Value;
			}
			BiomeWeaponDrops[biome] = new List<string>();
			BiomeArmorDrops[biome] = new List<string>();
			string[] array = weapons;
			foreach (string basePrefab in array)
			{
				string text = CreateWeaponVariant(biome, basePrefab, "Serpent", "of the Serpent", "Attacks deal additional poison damage.", scale, delegate(SharedData shared)
				{
					shared.m_damages.m_poison += 10f * scale;
				});
				if (text != null)
				{
					BiomeWeaponDrops[biome].Add(text);
				}
				string text2 = CreateWeaponVariant(biome, basePrefab, "Wraith", "of the Wraith", "Attacks deal additional spirit damage.", scale, delegate(SharedData shared)
				{
					shared.m_damages.m_spirit += 10f * scale;
				});
				if (text2 != null)
				{
					BiomeWeaponDrops[biome].Add(text2);
				}
				string text3 = CreateWeaponVariant(biome, basePrefab, "Blight", "of the Blight", "Attacks deal increased physical, poison, and spirit damage.", scale, delegate(SharedData shared)
				{
					shared.m_damages.m_poison += 5f * scale;
					shared.m_damages.m_spirit += 5f * scale;
					shared.m_damages.m_slash *= 1f + 0.05f * scale;
					shared.m_damages.m_blunt *= 1f + 0.05f * scale;
					shared.m_damages.m_pierce *= 1f + 0.05f * scale;
				});
				if (text3 != null)
				{
					BiomeWeaponDrops[biome].Add(text3);
				}
			}
			array = armors;
			foreach (string basePrefab2 in array)
			{
				string text4 = CreateArmorVariant(biome, basePrefab2, "Bastion", "of the Bastion", "Increased armor rating and durability.", scale, delegate(SharedData shared)
				{
					shared.m_armor *= 1f + 0.1f * scale;
					shared.m_maxDurability *= 1.5f;
				});
				if (text4 != null)
				{
					BiomeArmorDrops[biome].Add(text4);
				}
				string text5 = CreateArmorVariant(biome, basePrefab2, "Serpent", "of the Serpent", "Grants resistance to Poison.", scale, delegate(SharedData shared)
				{
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_0035: Unknown result type (might be due to invalid IL or missing references)
					if (shared.m_damageModifiers == null)
					{
						shared.m_damageModifiers = new List<DamageModPair>();
					}
					shared.m_damageModifiers.Add(new DamageModPair
					{
						m_type = (DamageType)256,
						m_modifier = (DamageModifier)1
					});
				});
				if (text5 != null)
				{
					BiomeArmorDrops[biome].Add(text5);
				}
				string text6 = CreateArmorVariant(biome, basePrefab2, "Wraith", "of the Wraith", "Grants resistance to Spirit damage.", scale, delegate(SharedData shared)
				{
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_0035: Unknown result type (might be due to invalid IL or missing references)
					if (shared.m_damageModifiers == null)
					{
						shared.m_damageModifiers = new List<DamageModPair>();
					}
					shared.m_damageModifiers.Add(new DamageModPair
					{
						m_type = (DamageType)512,
						m_modifier = (DamageModifier)1
					});
				});
				if (text6 != null)
				{
					BiomeArmorDrops[biome].Add(text6);
				}
				string text7 = CreateArmorVariant(biome, basePrefab2, "Blight", "of the Blight", "Increased armor and resistance to Poison and Spirit.", scale, delegate(SharedData shared)
				{
					//IL_003a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_004f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0054: Unknown result type (might be due to invalid IL or missing references)
					//IL_0062: Unknown result type (might be due to invalid IL or missing references)
					//IL_006f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0077: Unknown result type (might be due to invalid IL or missing references)
					//IL_007c: Unknown result type (might be due to invalid IL or missing references)
					shared.m_armor *= 1f + 0.05f * scale;
					if (shared.m_damageModifiers == null)
					{
						shared.m_damageModifiers = new List<DamageModPair>();
					}
					shared.m_damageModifiers.Add(new DamageModPair
					{
						m_type = (DamageType)256,
						m_modifier = (DamageModifier)1
					});
					shared.m_damageModifiers.Add(new DamageModPair
					{
						m_type = (DamageType)512,
						m_modifier = (DamageModifier)1
					});
				});
				if (text7 != null)
				{
					BiomeArmorDrops[biome].Add(text7);
				}
			}
		}

		private static string GetStationName(string basePrefab)
		{
			if (basePrefab.Contains("Carapace") || basePrefab.Contains("Flametal") || basePrefab.Contains("Mistwalker") || basePrefab.Contains("SpineSnap") || basePrefab.Contains("Ash") || basePrefab.Contains("Feather"))
			{
				return "blackforge";
			}
			if (basePrefab.Contains("Bronze") || basePrefab.Contains("Iron") || basePrefab.Contains("Silver") || basePrefab.Contains("Blackmetal") || basePrefab.Contains("Banded") || basePrefab.Contains("Padded") || basePrefab.Contains("Needle") || basePrefab.Contains("DraugrFang") || basePrefab.Contains("Battleaxe") || basePrefab.Contains("Drake"))
			{
				return "forge";
			}
			return "piece_workbench";
		}

		private static string[] GetBiomeTrophies(Biome biome)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected I4, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			if ((int)biome <= 16)
			{
				switch (biome - 1)
				{
				default:
					if ((int)biome != 8)
					{
						if ((int)biome != 16)
						{
							break;
						}
						return new string[2] { "TrophyGoblin", "TrophyDeathsquito" };
					}
					return new string[2] { "TrophyGreydwarfBrute", "TrophyGreydwarfShaman" };
				case 0:
					return new string[2] { "TrophyBoar", "TrophyNeck" };
				case 1:
					return new string[2] { "TrophyDraugr", "TrophyLeech" };
				case 3:
					return new string[2] { "TrophyWolf", "TrophyHatchling" };
				case 2:
					break;
				}
			}
			else
			{
				if ((int)biome == 32)
				{
					return new string[2] { "TrophyCharredMelee", "TrophyCharredArcher" };
				}
				if ((int)biome == 64)
				{
					return new string[2] { "TrophyWolf", "TrophyHatchling" };
				}
				if ((int)biome == 512)
				{
					return new string[2] { "TrophySeeker", "TrophyTick" };
				}
			}
			return new string[2] { "TrophyBoar", "TrophyNeck" };
		}

		public static void ResolveVanillaRecipeMaterials()
		{
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			if (_recipesResolved)
			{
				return;
			}
			_recipesResolved = true;
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				Logger.LogWarning((object)"ResolveVanillaRecipeMaterials called but ObjectDB.instance is null!");
				return;
			}
			int num = 0;
			int num2 = 0;
			foreach (KeyValuePair<string, string> deferredRecipeLookup in _deferredRecipeLookups)
			{
				string blightedName = deferredRecipeLookup.Key;
				string basePrefab = deferredRecipeLookup.Value;
				Recipe val = ((IEnumerable<Recipe>)ObjectDB.instance.m_recipes).FirstOrDefault((Func<Recipe, bool>)((Recipe r) => (Object)(object)r != (Object)null && (Object)(object)r.m_item != (Object)null && ((Object)((Component)r.m_item).gameObject).name == blightedName));
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Recipe val2 = ((IEnumerable<Recipe>)ObjectDB.instance.m_recipes).FirstOrDefault((Func<Recipe, bool>)((Recipe r) => (Object)(object)r != (Object)null && (Object)(object)r.m_item != (Object)null && ((Object)((Component)r.m_item).gameObject).name == basePrefab));
				if ((Object)(object)val2 == (Object)null || val2.m_resources == null)
				{
					Logger.LogWarning((object)("Could not find vanilla recipe for '" + basePrefab + "', upgrade for '" + blightedName + "' will only require trophies."));
					num2++;
					continue;
				}
				List<Requirement> list = ((val.m_resources != null) ? new List<Requirement>(val.m_resources) : new List<Requirement>());
				Requirement[] resources = val2.m_resources;
				foreach (Requirement val3 in resources)
				{
					if (!((Object)(object)val3.m_resItem == (Object)null))
					{
						int amountPerLevel = ((val3.m_amountPerLevel > 0) ? val3.m_amountPerLevel : Mathf.Max(1, val3.m_amount / 2));
						list.Add(new Requirement
						{
							m_resItem = val3.m_resItem,
							m_amount = 0,
							m_amountPerLevel = amountPerLevel,
							m_recover = true
						});
					}
				}
				val.m_resources = list.ToArray();
				num++;
			}
			Logger.LogInfo((object)$"Resolved vanilla recipe materials for {num} blighted items ({num2} could not be resolved).");
		}

		private static string CreateWeaponVariant(Biome biome, string basePrefab, string suffixId, string suffixName, string effectDescription, float scale, Action<SharedData> modify)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			string text = $"Blighted{biome}_{basePrefab}_{suffixId}";
			if ((Object)(object)PrefabManager.Instance.GetPrefab(basePrefab) == (Object)null)
			{
				return null;
			}
			CustomItem val = new CustomItem(text, basePrefab);
			SharedData shared = val.ItemDrop.m_itemData.m_shared;
			shared.m_name = "Blighted " + shared.m_name + " " + suffixName;
			shared.m_description = "<color=yellow>" + effectDescription + "</color>\n" + shared.m_description;
			shared.m_damages.m_blunt *= 1f + 0.05f * scale;
			shared.m_damages.m_slash *= 1f + 0.05f * scale;
			shared.m_damages.m_pierce *= 1f + 0.05f * scale;
			modify?.Invoke(shared);
			TintItemPrefab(val);
			ItemManager.Instance.AddItem(val);
			string[] biomeTrophies = GetBiomeTrophies(biome);
			List<RequirementConfig> list = new List<RequirementConfig>();
			_deferredRecipeLookups[text] = basePrefab;
			string[] array = biomeTrophies;
			foreach (string item in array)
			{
				list.Add(new RequirementConfig
				{
					Item = item,
					Amount = 0,
					AmountPerLevel = 2
				});
			}
			CustomRecipe val2 = new CustomRecipe(new RecipeConfig
			{
				Item = text,
				Amount = 1,
				CraftingStation = GetStationName(basePrefab),
				Enabled = true,
				Requirements = list.ToArray()
			});
			ItemManager.Instance.AddRecipe(val2);
			return text;
		}

		private static string CreateArmorVariant(Biome biome, string basePrefab, string suffixId, string suffixName, string effectDescription, float scale, Action<SharedData> modify)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_00b3: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			string text = $"Blighted{biome}_{basePrefab}_{suffixId}";
			if ((Object)(object)PrefabManager.Instance.GetPrefab(basePrefab) == (Object)null)
			{
				return null;
			}
			CustomItem val = new CustomItem(text, basePrefab);
			SharedData shared = val.ItemDrop.m_itemData.m_shared;
			shared.m_name = "Blighted " + shared.m_name + " " + suffixName;
			shared.m_description = "<color=yellow>" + effectDescription + "</color>\n" + shared.m_description;
			shared.m_armor *= 1f + 0.05f * scale;
			modify?.Invoke(shared);
			TintItemPrefab(val);
			ItemManager.Instance.AddItem(val);
			string[] biomeTrophies = GetBiomeTrophies(biome);
			List<RequirementConfig> list = new List<RequirementConfig>();
			_deferredRecipeLookups[text] = basePrefab;
			string[] array = biomeTrophies;
			foreach (string item in array)
			{
				list.Add(new RequirementConfig
				{
					Item = item,
					Amount = 0,
					AmountPerLevel = 2
				});
			}
			CustomRecipe val2 = new CustomRecipe(new RecipeConfig
			{
				Item = text,
				Amount = 1,
				CraftingStation = GetStationName(basePrefab),
				Enabled = true,
				Requirements = list.ToArray()
			});
			ItemManager.Instance.AddRecipe(val2);
			return text;
		}

		private static void TintItemPrefab(CustomItem customItem)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Color blightedTint = default(Color);
			((Color)(ref blightedTint))..ctor(0.1f, 0.4f, 0.1f, 1f);
			Renderer[] componentsInChildren = customItem.ItemPrefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Material[] materials = componentsInChildren[i].materials;
				for (int j = 0; j < materials.Length; j++)
				{
					TintMaterial(materials[j], blightedTint);
				}
			}
			SharedData shared = customItem.ItemDrop.m_itemData.m_shared;
			if (shared != null && (Object)(object)shared.m_armorMaterial != (Object)null)
			{
				shared.m_armorMaterial = new Material(shared.m_armorMaterial);
				TintMaterial(shared.m_armorMaterial, blightedTint);
			}
		}

		private static void TintMaterial(Material mat, Color blightedTint)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mat == (Object)null))
			{
				if (mat.HasProperty("_Color"))
				{
					mat.color = Color.Lerp(mat.color, blightedTint, 0.8f);
				}
				if (mat.HasProperty("_EmissionColor") && mat.IsKeywordEnabled("_EMISSION"))
				{
					mat.SetColor("_EmissionColor", mat.GetColor("_EmissionColor") * blightedTint);
				}
			}
		}
	}
	[HarmonyPatch]
	public static class BlightedMechanicsPatches
	{
		[HarmonyPatch(typeof(Player), "OnSpawned")]
		[HarmonyPostfix]
		public static void PlayerOnSpawnedPostfix()
		{
			BlightedItemsManager.ResolveVanillaRecipeMaterials();
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		[HarmonyPrefix]
		public static bool DamagePrefix(Character __instance, HitData hit)
		{
			if ((Object)(object)((Component)__instance).GetComponent<BlightedWorldHeartAI>() != (Object)null && hit != null && ((Object)(object)hit.GetAttacker() == (Object)null || !hit.GetAttacker().IsPlayer()))
			{
				return false;
			}
			if (hit != null && !((Object)(object)hit.GetAttacker() == (Object)null))
			{
				hit.GetAttacker().IsPlayer();
			}
			return true;
		}

		[HarmonyPatch(typeof(InventoryGui), "UpdateRecipeList")]
		[HarmonyPrefix]
		public static void HideBlightedCrafting(List<Recipe> recipes)
		{
			if (recipes != null && (Object)(object)InventoryGui.instance != (Object)null && InventoryGui.instance.InCraftTab())
			{
				recipes.RemoveAll((Recipe r) => (Object)(object)r != (Object)null && (Object)(object)r.m_item != (Object)null && ((Object)((Component)r.m_item).gameObject).name.StartsWith("Blighted"));
			}
		}

		[HarmonyPatch(typeof(Player), "AddKnownItem", new Type[] { typeof(ItemData) })]
		[HarmonyPrefix]
		public static void AddKnownItemPrefix(Player __instance, ItemData item)
		{
			if (item == null || (Object)(object)item.m_dropPrefab == (Object)null || !((Object)item.m_dropPrefab).name.StartsWith("Blighted"))
			{
				return;
			}
			string prefabName = ((Object)item.m_dropPrefab).name;
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				return;
			}
			Recipe val = ((IEnumerable<Recipe>)ObjectDB.instance.m_recipes).FirstOrDefault((Func<Recipe, bool>)((Recipe r) => (Object)(object)r != (Object)null && (Object)(object)r.m_item != (Object)null && ((Object)((Component)r.m_item).gameObject).name == prefabName));
			if ((Object)(object)val == (Object)null || val.m_resources == null)
			{
				return;
			}
			Requirement[] resources = val.m_resources;
			foreach (Requirement val2 in resources)
			{
				if ((Object)(object)val2.m_resItem != (Object)null)
				{
					__instance.m_knownMaterial.Add(((Object)((Component)val2.m_resItem).gameObject).name);
				}
			}
		}
	}
	public class BlightedUIManager : MonoBehaviour
	{
		private static BlightedUIManager _instance;

		private GameObject _uiRoot;

		private BlightedWorldHeartAI _activeHeart;

		private Character _trackedSubBoss1;

		private Character _trackedSubBoss2;

		private Vector3 _heartPosition;

		private RectTransform _mainBossBar;

		private Image _mainBossFill;

		private Text _mainBossName;

		private RectTransform _subBoss1Bar;

		private Image _subBoss1Fill;

		private Text _subBoss1Name;

		private RectTransform _subBoss2Bar;

		private Image _subBoss2Fill;

		private Text _subBoss2Name;

		private Font _valheimFont;

		public static BlightedUIManager Instance => _instance;

		public void Awake()
		{
			_instance = this;
		}

		public void RegisterHeart(BlightedWorldHeartAI heart)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			_activeHeart = heart;
			if ((Object)(object)_activeHeart != (Object)null)
			{
				_heartPosition = ((Component)_activeHeart).transform.position;
			}
			if ((Object)(object)_uiRoot == (Object)null && (Object)(object)Hud.instance != (Object)null)
			{
				CreateUI();
			}
		}

		public void UnregisterHeart(BlightedWorldHeartAI heart)
		{
			if ((Object)(object)_activeHeart == (Object)(object)heart)
			{
				_activeHeart = null;
			}
		}

		private void CreateUI()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_008c: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Hud.instance == (Object)null) && !((Object)(object)Hud.instance.m_rootObject == (Object)null))
			{
				Text componentInChildren = Hud.instance.m_rootObject.GetComponentInChildren<Text>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					_valheimFont = componentInChildren.font;
				}
				_uiRoot = new GameObject("BlightedCustomBossUI");
				_uiRoot.transform.SetParent(Hud.instance.m_rootObject.transform, false);
				RectTransform obj = _uiRoot.AddComponent<RectTransform>();
				obj.anchorMin = new Vector2(0.5f, 1f);
				obj.anchorMax = new Vector2(0.5f, 1f);
				obj.pivot = new Vector2(0.5f, 1f);
				obj.anchoredPosition = new Vector2(0f, -50f);
				CreateHealthBar("MainBossBar", _uiRoot.transform, new Vector2(0f, 0f), new Vector2(600f, 30f), out _mainBossBar, out _mainBossFill, out _mainBossName);
				CreateHealthBar("SubBoss1Bar", _uiRoot.transform, new Vector2(-200f, -50f), new Vector2(250f, 20f), out _subBoss1Bar, out _subBoss1Fill, out _subBoss1Name);
				CreateHealthBar("SubBoss2Bar", _uiRoot.transform, new Vector2(200f, -50f), new Vector2(250f, 20f), out _subBoss2Bar, out _subBoss2Fill, out _subBoss2Name);
				_uiRoot.SetActive(false);
			}
		}

		private void CreateHealthBar(string name, Transform parent, Vector2 anchoredPos, Vector2 size, out RectTransform rootRt, out Image fill, out Text nameText)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			rootRt = val.AddComponent<RectTransform>();
			rootRt.anchorMin = new Vector2(0.5f, 1f);
			rootRt.anchorMax = new Vector2(0.5f, 1f);
			rootRt.pivot = new Vector2(0.5f, 1f);
			rootRt.anchoredPosition = anchoredPos;
			rootRt.sizeDelta = size;
			GameObject val2 = new GameObject("Trim");
			val2.transform.SetParent(val.transform, false);
			RectTransform obj = val2.AddComponent<RectTransform>();
			obj.anchorMin = Vector2.zero;
			obj.anchorMax = Vector2.one;
			obj.offsetMin = new Vector2(-2f, -2f);
			obj.offsetMax = new Vector2(2f, 2f);
			((Graphic)val2.AddComponent<Image>()).color = new Color(1f, 0.84f, 0f, 1f);
			GameObject val3 = new GameObject("Bkg");
			val3.transform.SetParent(val.transform, false);
			RectTransform obj2 = val3.AddComponent<RectTransform>();
			obj2.anchorMin = Vector2.zero;
			obj2.anchorMax = Vector2.one;
			obj2.sizeDelta = Vector2.zero;
			((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.9f);
			GameObject val4 = new GameObject("Fill");
			val4.transform.SetParent(val.transform, false);
			RectTransform obj3 = val4.AddComponent<RectTransform>();
			obj3.anchorMin = new Vector2(0f, 0f);
			obj3.anchorMax = new Vector2(1f, 1f);
			obj3.sizeDelta = Vector2.zero;
			obj3.pivot = new Vector2(0f, 0.5f);
			fill = val4.AddComponent<Image>();
			((Graphic)fill).color = Color.magenta;
			GameObject val5 = new GameObject("NameText");
			val5.transform.SetParent(val.transform, false);
			RectTransform obj4 = val5.AddComponent<RectTransform>();
			obj4.anchorMin = new Vector2(0.5f, 0.5f);
			obj4.anchorMax = new Vector2(0.5f, 0.5f);
			obj4.pivot = new Vector2(0.5f, 0.5f);
			obj4.anchoredPosition = new Vector2(0f, 0f);
			obj4.sizeDelta = new Vector2(500f, 30f);
			nameText = val5.AddComponent<Text>();
			nameText.alignment = (TextAnchor)4;
			((Graphic)nameText).color = Color.white;
			nameText.fontSize = 20;
			if ((Object)(object)_valheimFont != (Object)null)
			{
				nameText.font = _valheimFont;
			}
			else
			{
				nameText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			}
			Shadow obj5 = val5.AddComponent<Shadow>();
			obj5.effectColor = Color.black;
			obj5.effectDistance = new Vector2(1f, -1f);
		}

		public void LateUpdate()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Hud.instance == (Object)null)
			{
				return;
			}
			if ((Object)(object)_activeHeart != (Object)null && _activeHeart.m_health > 0f)
			{
				_heartPosition = ((Component)_activeHeart).transform.position;
				if ((Object)(object)_activeHeart.m_subBoss1 != (Object)null)
				{
					_trackedSubBoss1 = _activeHeart.m_subBoss1;
				}
				if ((Object)(object)_activeHeart.m_subBoss2 != (Object)null)
				{
					_trackedSubBoss2 = _activeHeart.m_subBoss2;
				}
			}
			bool flag = (Object)(object)_activeHeart != (Object)null && _activeHeart.m_health > 0f;
			bool flag2 = (Object)(object)_trackedSubBoss1 != (Object)null && !_trackedSubBoss1.IsDead();
			bool flag3 = (Object)(object)_trackedSubBoss2 != (Object)null && !_trackedSubBoss2.IsDead();
			if (!flag && !flag2 && !flag3)
			{
				if ((Object)(object)_uiRoot != (Object)null && _uiRoot.activeSelf)
				{
					_uiRoot.SetActive(false);
				}
				return;
			}
			if ((Object)(object)Player.m_localPlayer != (Object)null && Vector3.Distance(((Component)Player.m_localPlayer).transform.position, _heartPosition) > 100f)
			{
				if ((Object)(object)_uiRoot != (Object)null && _uiRoot.activeSelf)
				{
					_uiRoot.SetActive(false);
				}
				return;
			}
			if ((Object)(object)_uiRoot == (Object)null)
			{
				CreateUI();
			}
			if (!((Object)(object)_uiRoot == (Object)null))
			{
				if (!_uiRoot.activeSelf)
				{
					_uiRoot.SetActive(true);
				}
				UpdateBars(flag, flag2, flag3);
			}
		}

		private void UpdateBars(bool heartAlive, bool sb1Alive, bool sb2Alive)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: 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_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			if (heartAlive)
			{
				((Component)_mainBossBar).gameObject.SetActive(true);
				float health = _activeHeart.m_health;
				float maxHealth = _activeHeart.m_maxHealth;
				((Graphic)_mainBossFill).color = GetBiomeColor(_activeHeart.CurrentBiome);
				_mainBossName.text = "Blighted World Heart";
				UpdateFill(_mainBossFill, health, maxHealth);
			}
			else
			{
				((Component)_mainBossBar).gameObject.SetActive(false);
			}
			float num = (heartAlive ? (-50f) : 0f);
			if (sb1Alive)
			{
				((Component)_subBoss1Bar).gameObject.SetActive(true);
				_subBoss1Name.text = GetLocalizedBlightedName(_trackedSubBoss1.m_name);
				((Graphic)_subBoss1Fill).color = new Color(0.2f, 0.6f, 1f, 1f);
				UpdateFill(_subBoss1Fill, _trackedSubBoss1.GetHealth(), _trackedSubBoss1.GetMaxHealth());
			}
			else
			{
				((Component)_subBoss1Bar).gameObject.SetActive(false);
			}
			if (sb2Alive)
			{
				((Component)_subBoss2Bar).gameObject.SetActive(true);
				_subBoss2Name.text = GetLocalizedBlightedName(_trackedSubBoss2.m_name);
				((Graphic)_subBoss2Fill).color = new Color(0.2f, 0.6f, 1f, 1f);
				UpdateFill(_subBoss2Fill, _trackedSubBoss2.GetHealth(), _trackedSubBoss2.GetMaxHealth());
			}
			else
			{
				((Component)_subBoss2Bar).gameObject.SetActive(false);
			}
			if (sb1Alive && sb2Alive)
			{
				_subBoss1Bar.sizeDelta = new Vector2(250f, 20f);
				_subBoss1Bar.anchoredPosition = new Vector2(-200f, num);
				_subBoss1Name.fontSize = 20;
				_subBoss2Bar.sizeDelta = new Vector2(250f, 20f);
				_subBoss2Bar.anchoredPosition = new Vector2(200f, num);
				_subBoss2Name.fontSize = 20;
			}
			else if (sb1Alive && !sb2Alive && !heartAlive)
			{
				_subBoss1Bar.sizeDelta = new Vector2(600f, 30f);
				_subBoss1Bar.anchoredPosition = new Vector2(0f, 0f);
				_subBoss1Name.fontSize = 24;
			}
			else if (!sb1Alive && sb2Alive && !heartAlive)
			{
				_subBoss2Bar.sizeDelta = new Vector2(600f, 30f);
				_subBoss2Bar.anchoredPosition = new Vector2(0f, 0f);
				_subBoss2Name.fontSize = 24;
			}
			else if (sb1Alive && !sb2Alive && heartAlive)
			{
				_subBoss1Bar.sizeDelta = new Vector2(250f, 20f);
				_subBoss1Bar.anchoredPosition = new Vector2(0f, num);
				_subBoss1Name.fontSize = 20;
			}
			else if (!sb1Alive && sb2Alive && heartAlive)
			{
				_subBoss2Bar.sizeDelta = new Vector2(250f, 20f);
				_subBoss2Bar.anchoredPosition = new Vector2(0f, num);
				_subBoss2Name.fontSize = 20;
			}
		}

		private void UpdateFill(Image fill, float current, float max)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp01((max > 0f) ? (current / max) : 0f);
			((Component)fill).transform.localScale = new Vector3(num, 1f, 1f);
		}

		private string GetLocalizedBlightedName(string rawName)
		{
			if (string.IsNullOrEmpty(rawName))
			{
				return "Blighted Unknown";
			}
			if (rawName.StartsWith("Blighted"))
			{
				return rawName;
			}
			string text = Localization.instance.Localize(rawName);
			return "Blighted " + text;
		}

		private Color GetBiomeColor(Biome biome)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected I4, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			if ((int)biome <= 16)
			{
				switch (biome - 1)
				{
				default:
					if ((int)biome != 8)
					{
						if ((int)biome != 16)
						{
							break;
						}
						return new Color(0.9f, 0.7f, 0.2f);
					}
					return new Color(0.5f, 0.1f, 0.8f);
				case 0:
					return new Color(0.2f, 0.8f, 0.2f);
				case 1:
					return new Color(0.4f, 0.3f, 0.1f);
				case 3:
					return new Color(0.8f, 0.9f, 1f);
				case 2:
					break;
				}
			}
			else
			{
				if ((int)biome == 32)
				{
					return new Color(1f, 0.2f, 0f);
				}
				if ((int)biome == 64)
				{
					return new Color(0.9f, 0.9f, 1f);
				}
				if ((int)biome == 512)
				{
					return new Color(0.3f, 0.1f, 0.5f);
				}
			}
			return Color.white;
		}
	}
	public class BlightedWorldHeartAI : MonoBehaviour, IDestructible
	{
		private static readonly int RPC_BlightedDamage = StringExtensionMethods.GetStableHashCode("RPC_BlightedHeartDamage");

		public float m_health;

		public float m_maxHealth = 2000f;

		private bool m_isDead;

		public Biome CurrentBiome;

		private float _lastWaveTime;

		private float _waveInterval = 30f;

		private bool _subBoss1Spawned;

		private bool _subBoss2Spawned;

		public Character m_subBoss1;

		public Character m_subBoss2;

		public ZNetView m_nview;

		private float _lastLogTime;

		private static readonly int ZDO_Health = StringExtensionMethods.GetStableHashCode("blighted_health");

		private static readonly int ZDO_MaxHealth = StringExtensionMethods.GetStableHashCode("blighted_max_health");

		private static readonly string ZDO_SubBoss1 = "blighted_subboss1";

		private static readonly string ZDO_SubBoss2 = "blighted_subboss2";

		private List<GameObject> m_spawnedEnemies = new List<GameObject>();

		public void Awake()
		{
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			m_nview = ((Component)this).GetComponent<ZNetView>();
			CharacterAnimEvent[] componentsInChildren = ((Component)this).GetComponentsInChildren<CharacterAnimEvent>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			CharacterDrop[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<CharacterDrop>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			BaseAI[] componentsInChildren3 = ((Component)this).GetComponentsInChildren<BaseAI>(true);
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
			}
			FootStep[] componentsInChildren4 = ((Component)this).GetComponentsInChildren<FootStep>(true);
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren4[i]);
			}
			VisEquipment[] componentsInChildren5 = ((Component)this).GetComponentsInChildren<VisEquipment>(true);
			for (int i = 0; i < componentsInChildren5.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren5[i]);
			}
			Character[] componentsInChildren6 = ((Component)this).GetComponentsInChildren<Character>(true);
			foreach (Character val in componentsInChildren6)
			{
				Logger.LogInfo((object)("[BlightedHeart] Stripping Character: " + ((Object)((Component)val).gameObject).name));
				Object.DestroyImmediate((Object)(object)val);
			}
			ZSyncAnimation[] componentsInChildren7 = ((Component)this).GetComponentsInChildren<ZSyncAnimation>(true);
			for (int i = 0; i < componentsInChildren7.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren7[i]);
			}
			Animator[] componentsInChildren8 = ((Component)this).GetComponentsInChildren<Animator>(true);
			for (int i = 0; i < componentsInChildren8.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren8[i]);
			}
			Rigidbody[] componentsInChildren9 = ((Component)this).GetComponentsInChildren<Rigidbody>(true);
			for (int i = 0; i < componentsInChildren9.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren9[i]);
			}
			Aoe[] componentsInChildren10 = ((Component)this).GetComponentsInChildren<Aoe>(true);
			foreach (Aoe val2 in componentsInChildren10)
			{
				Logger.LogInfo((object)("[BlightedHeart] Stripping Aoe: " + ((Object)((Component)val2).gameObject).name));
				Object.DestroyImmediate((Object)(object)val2);
			}
			MineRock5[] componentsInChildren11 = ((Component)this).GetComponentsInChildren<MineRock5>(true);
			for (int i = 0; i < componentsInChildren11.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren11[i]);
			}
			HitArea[] componentsInChildren12 = ((Component)this).GetComponentsInChildren<HitArea>(true);
			for (int i = 0; i < componentsInChildren12.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren12[i]);
			}
			Destructible[] componentsInChildren13 = ((Component)this).GetComponentsInChildren<Destructible>(true);
			for (int i = 0; i < componentsInChildren13.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren13[i]);
			}
			Collider[] componentsInChildren14 = ((Component)this).GetComponentsInChildren<Collider>(true);
			foreach (Collider val3 in componentsInChildren14)
			{
				if ((Object)(object)val3 != (Object)null && val3.isTrigger)
				{
					Object.DestroyImmediate((Object)(object)val3);
				}
			}
			MonoBehaviour[] componentsInChildren15 = ((Component)this).GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val4 in componentsInChildren15)
			{
				if (!((Object)(object)val4 == (Object)null) && !(val4 is ZNetView) && !(val4 is BlightedWorldHeartAI) && !(val4 is BlightedDamageForwarder))
				{
					Object.DestroyImmediate((Object)(object)val4);
				}
			}
			if ((Object)(object)m_nview != (Object)null)
			{
				m_nview.Register<HitData>("RPC_BlightedHeartDamage", (Action<long, HitData>)RPC_HandleDamage);
			}
			m_health = m_maxHealth;
			if ((Object)(object)m_nview != (Object)null && m_nview.GetZDO() != null)
			{
				float num = m_nview.GetZDO().GetFloat(ZDO_Health, 0f);
				if (num > 0f)
				{
					m_health = num;
				}
				float num2 = m_nview.GetZDO().GetFloat(ZDO_MaxHealth, 0f);
				if (num2 > 0f)
				{
					m_maxHealth = num2;
				}
			}
			componentsInChildren14 = ((Component)this).GetComponentsInChildren<Collider>(true);
			foreach (Collider val5 in componentsInChildren14)
			{
				if ((Object)(object)val5 != (Object)null && (Object)(object)((Component)val5).gameObject != (Object)(object)((Component)this).gameObject)
				{
					BlightedDamageForwarder blightedDamageForwarder = ((Component)val5).gameObject.GetComponent<BlightedDamageForwarder>();
					if ((Object)(object)blightedDamageForwarder == (Object)null)
					{
						blightedDamageForwarder = ((Component)val5).gameObject.AddComponent<BlightedDamageForwarder>();
					}
					blightedDamageForwarder.m_heart = this;
				}
			}
			if ((Object)(object)((Component)this).gameObject.GetComponent<Collider>() == (Object)null)
			{
				BoxCollider obj = ((Component)this).gameObject.AddComponent<BoxCollider>();
				obj.size = new Vector3(10f, 10f, 10f);
				obj.center = Vector3.zero;
			}
			if ((Object)(object)BlightedUIManager.Instance != (Object)null)
			{
				BlightedUIManager.Instance.RegisterHeart(this);
			}
			Logger.LogInfo((object)"[BlightedHeart] Runtime cleanup complete. Custom IDestructible active.");
		}

		public DestructibleType GetDestructibleType()
		{
			return (DestructibleType)1;
		}

		public void Damage(HitData hit)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (m_isDead || (Object)(object)m_nview == (Object)null || !m_nview.IsValid())
			{
				return;
			}
			if (hit != null)
			{
				Character attacker = hit.GetAttacker();
				if ((Object)(object)attacker == (Object)null || (!attacker.IsPlayer() && !attacker.IsTamed()))
				{
					return;
				}
			}
			if (!m_nview.IsOwner())
			{
				m_nview.InvokeRPC("RPC_BlightedHeartDamage", new object[1] { hit });
				return;
			}
			float totalDamage = hit.GetTotalDamage();
			if (!(totalDamage <= 0f))
			{
				m_health -= totalDamage;
				m_nview.GetZDO().Set(ZDO_Health, m_health);
				if ((Object)(object)DamageText.instance != (Object)null)
				{
					DamageText.instance.ShowText((TextType)0, hit.m_point, totalDamage, false);
				}
				if (BlightedConfigManager.DebugMode != null && BlightedConfigManager.DebugMode.Value)
				{
					Logger.LogInfo((object)$"[BlightedHeart] Took {totalDamage:F1} damage. Health: {m_health:F0}/{m_maxHealth:F0}");
				}
				if (m_health <= 0f)
				{
					m_health = 0f;
					m_isDead = true;
					OnDeath();
				}
			}
		}

		private void RPC_HandleDamage(long sender, HitData hit)
		{
			Damage(hit);
		}

		private void OnDeath()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Logger.LogInfo((object)"[BlightedHeart] The Blighted World Heart has been destroyed!");
			DropLoot();
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				Player.MessageAllInRange(((Component)this).transform.position, 200f, (MessageType)2, "The Blighted World Heart has been purified!", (Sprite)null);
			}
			if ((Object)(object)m_nview != (Object)null && m_nview.IsOwner())
			{
				m_nview.Destroy();
			}
		}

		private void DropLoot()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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)
			if (!BlightedConfigManager.BiomeConfigs.TryGetValue(CurrentBiome, out var _))
			{
				return;
			}
			int num = 1;
			List<Player> list = new List<Player>();
			Player.GetPlayersInRange(((Component)this).transform.position, 100f, list);
			if (list.Count > 0)
			{
				num = list.Count;
			}
			int num2 = 3 + (num - 1);
			if (num2 < 3)
			{
				num2 = 3;
			}
			List<string> value2;
			bool flag = BlightedItemsManager.BiomeWeaponDrops.TryGetValue(CurrentBiome, out value2) && value2.Count > 0;
			List<string> value3;
			bool flag2 = BlightedItemsManager.BiomeArmorDrops.TryGetValue(CurrentBiome, out value3) && value3.Count > 0;
			if (!flag && !flag2)
			{
				return;
			}
			for (int i = 0; i < num2; i++)
			{
				if ((Random.value > 0.5f && flag) || !flag2)
				{
					string prefabName = value2[Random.Range(0, value2.Count)];
					SpawnDrop(prefabName);
				}
				else if (flag2)
				{
					string prefabName2 = value3[Random.Range(0, value3.Count)];
					SpawnDrop(prefabName2);
				}
			}
		}

		private void SpawnDrop(string prefabName)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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)
			ZNetScene instance = ZNetScene.instance;
			GameObject val = ((instance != null) ? instance.GetPrefab(prefabName) : null);
			if ((Object)(object)val != (Object)null)
			{
				Vector3 val2 = ((Component)this).transform.position + Vector3.up * 1f + Random.insideUnitSphere * 0.5f;
				Object.Instantiate<GameObject>(val, val2, Quaternion.identity);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)BlightedUIManager.Instance != (Object)null)
			{
				BlightedUIManager.Instance.UnregisterHeart(this);
			}
		}

		public void Initialize(Biome biome)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			CurrentBiome = biome;
			if (BlightedConfigManager.BiomeConfigs.TryGetValue(biome, out var value))
			{
				float num = ((value.WaveTimerSeconds != null) ? value.WaveTimerSeconds.Value : _waveInterval);
				_lastWaveTime = Time.time - num + 1f;
			}
			else
			{
				_lastWaveTime = Time.time - _waveInterval + 1f;
			}
			if (BlightedConfigManager.BiomeConfigs.TryGetValue(biome, out var value2))
			{
				m_maxHealth = value2.BossHP.Value;
				m_health = m_maxHealth;
				if ((Object)(object)m_nview != (Object)null && m_nview.GetZDO() != null)
				{
					m_nview.GetZDO().Set(ZDO_Health, m_health);
					m_nview.GetZDO().Set(ZDO_MaxHealth, m_maxHealth);
				}
			}
			ApplyBiomeVisuals(biome);
		}

		private void ApplyBiomeVisuals(Biome biome)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>();
			Color biomeColor = GetBiomeColor(biome);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				if ((Object)(object)val.material != (Object)null)
				{
					val.material.SetColor("_Color", biomeColor);
					if (val.material.HasProperty("_EmissionColor"))
					{
						val.material.SetColor("_EmissionColor", biomeColor * 2f);
						val.material.EnableKeyword("_EMISSION");
					}
				}
			}
		}

		private Color GetBiomeColor(Biome biome)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected I4, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			if ((int)biome <= 16)
			{
				switch (biome - 1)
				{
				default:
					if ((int)biome != 8)
					{
						if ((int)biome != 16)
						{
							break;
						}
						return new Color(0.9f, 0.7f, 0.2f);
					}
					return new Color(0.5f, 0.1f, 0.8f);
				case 0:
					return new Color(0.2f, 0.8f, 0.2f);
				case 1:
					return new Color(0.4f, 0.3f, 0.1f);
				case 3:
					return new Color(0.8f, 0.9f, 1f);
				case 2:
					break;
				}
			}
			else
			{
				if ((int)biome == 32)
				{
					return new Color(1f, 0.2f, 0f);
				}
				if ((int)biome == 64)
				{
					return new Color(0.9f, 0.9f, 1f);
				}
				if ((int)biome == 512)
				{
					return new Color(0.3f, 0.1f, 0.5f);
				}
			}
			return Color.white;
		}

		private void Update()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_nview == (Object)null || m_isDead)
			{
				return;
			}
			if (!m_nview.IsOwner())
			{
				if (m_nview.GetZDO() == null)
				{
					return;
				}
				m_health = m_nview.GetZDO().GetFloat(ZDO_Health, m_health);
				m_maxHealth = m_nview.GetZDO().GetFloat(ZDO_MaxHealth, m_maxHealth);
				if ((Object)(object)m_subBoss1 == (Object)null)
				{
					ZDOID zDOID = m_nview.GetZDO().GetZDOID(ZDO_SubBoss1);
					if (zDOID != ZDOID.None)
					{
						GameObject val = ZNetScene.instance.FindInstance(zDOID);
						if (Object.op_Implicit((Object)(object)val))
						{
							m_subBoss1 = val.GetComponent<Character>();
						}
					}
				}
				if (!((Object)(object)m_subBoss2 == (Object)null))
				{
					return;
				}
				ZDOID zDOID2 = m_nview.GetZDO().GetZDOID(ZDO_SubBoss2);
				if (zDOID2 != ZDOID.None)
				{
					GameObject val2 = ZNetScene.instance.FindInstance(zDOID2);
					if (Object.op_Implicit((Object)(object)val2))
					{
						m_subBoss2 = val2.GetComponent<Character>();
					}
				}
			}
			else
			{
				CheckSubBossThresholds();
				HandleWaveSpawning();
			}
		}

		private void HandleWaveSpawning()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (BlightedConfigManager.BiomeConfigs.TryGetValue(CurrentBiome, out var value))
			{
				float num = ((value.WaveTimerSeconds != null) ? value.WaveTimerSeconds.Value : _waveInterval);
				if (Time.time - _lastWaveTime > num)
				{
					_lastWaveTime = Time.time;
					SpawnWave();
				}
			}
		}

		private void SpawnWave()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			if (!BlightedConfigManager.BiomeConfigs.TryGetValue(CurrentBiome, out var value))
			{
				return;
			}
			int value2 = value.MaxEnemiesPerWave.Value;
			m_spawnedEnemies.RemoveAll((GameObject e) => (Object)(object)e == (Object)null || (Object)(object)e.GetComponent<Character>() == (Object)null || e.GetComponent<Character>().IsDead());
			int num = value2 - m_spawnedEnemies.Count;
			if (num <= 0)
			{
				return;
			}
			string[] waveEnemiesForBiome = GetWaveEnemiesForBiome(CurrentBiome);
			if (waveEnemiesForBiome.Length == 0)
			{
				return;
			}
			if (BlightedConfigManager.DebugMode.Value)
			{
				Logger.LogInfo((object)string.Format("Attempting to spawn {0} wave enemies (Current: {1}/{2}) of type {3} in {4}.", num, m_spawnedEnemies.Count, value2, string.Join(",", waveEnemiesForBiome), CurrentBiome));
			}
			int num2 = 0;
			float y = default(float);
			for (int num3 = 0; num3 < num; num3++)
			{
				string text = waveEnemiesForBiome[Random.Range(0, waveEnemiesForBiome.Length)];
				GameObject prefab = ZNetScene.instance.GetPrefab(text);
				if ((Object)(object)prefab != (Object)null)
				{
					Vector3 val = ((Component)this).transform.position + Random.insideUnitSphere * 10f;
					if (ZoneSystem.instance.GetSolidHeight(val, ref y, 1000))
					{
						val.y = y;
					}
					else
					{
						val.y = ((Component)this).transform.position.y;
					}
					GameObject val2 = Object.Instantiate<GameObject>(prefab, val, Quaternion.identity);
					m_spawnedEnemies.Add(val2);
					num2++;
					CharacterDrop[] componentsInChildren = val2.GetComponentsInChildren<CharacterDrop>(true);
					for (int num4 = 0; num4 < componentsInChildren.Length; num4++)
					{
						Object.Destroy((Object)(object)componentsInChildren[num4]);
					}
					BaseAI component = val2.GetComponent<BaseAI>();
					if (!((Object)(object)component != (Object)null))
					{
						continue;
					}
					component.Alert();
					Player closestPlayer = Player.GetClosestPlayer(val, 50f);
					if ((Object)(object)closestPlayer != (Object)null)
					{
						MonsterAI component2 = val2.GetComponent<MonsterAI>();
						if ((Object)(object)component2 != (Object)null)
						{
							component2.SetTarget(((Component)closestPlayer).GetComponent<Character>());
						}
					}
				}
				else if (BlightedConfigManager.DebugMode.Value)
				{
					Logger.LogWarning((object)("Wave enemy prefab " + text + " not found in ZNetScene."));
				}
			}
			if (BlightedConfigManager.DebugMode.Value)
			{
				Logger.LogInfo((object)$"Successfully spawned {num2} wave enemies.");
			}
			if (num2 > 0 && BlightedConfigManager.EnableWaveAnnouncement.Value)
			{
				Player.MessageAllInRange(((Component)this).transform.position, 100f, BlightedConfigManager.WaveAnnouncementLocation.Value, "The Blighted World Heart cries out for the fallen...", (Sprite)null);
			}
		}

		private void CheckSubBossThresholds()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (BlightedConfigManager.BiomeConfigs.TryGetValue(CurrentBiome, out var value))
			{
				float num = m_health / m_maxHealth;
				if (BlightedConfigManager.DebugMode.Value && Time.time - _lastLogTime > 5f)
				{
					_lastLogTime = Time.time;
					Logger.LogInfo((object)$"Checking SubBoss thresholds. Current Health: {num:P0}. T1: {value.SubBossThreshold1.Value:P0}, T2: {value.SubBossThreshold2.Value:P0}. Spawned: {_subBoss1Spawned}, {_subBoss2Spawned}");
				}
				if (!_subBoss1Spawned && num <= value.SubBossThreshold1.Value)
				{
					_subBoss1Spawned = true;
					SpawnSubBoss(1, value.SubBoss1HP.Value);
				}
				if (!_subBoss2Spawned && num <= value.SubBossThreshold2.Value)
				{
					_subBoss2Spawned = true;
					SpawnSubBoss(2, value.SubBoss2HP.Value);
				}
			}
		}

		private void SpawnSubBoss(int index, float maxHealth)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			string subBossForBiome = GetSubBossForBiome(CurrentBiome);
			if (BlightedConfigManager.DebugMode.Value)
			{
				Logger.LogInfo((object)$"Attempting to spawn subboss: {subBossForBiome} for biome {CurrentBiome}");
			}
			GameObject prefab = ZNetScene.instance.GetPrefab(subBossForBiome);
			if (!((Object)(object)prefab != (Object)null))
			{
				return;
			}
			Vector3 val = ((Component)this).transform.position + Random.insideUnitSphere * 5f;
			float y = default(float);
			if (ZoneSystem.instance.GetSolidHeight(val, ref y, 1000))
			{
				val.y = y;
			}
			else
			{
				val.y = ((Component)this).transform.position.y;
			}
			GameObject val2 = Object.Instantiate<GameObject>(prefab, val, Quaternion.identity);
			if (BlightedConfigManager.DebugMode.Value)
			{
				Logger.LogInfo((object)("Successfully spawned subboss " + subBossForBiome));
			}
			Transform transform = val2.transform;
			transform.localScale *= 1.5f;
			CharacterDrop[] componentsInChildren = val2.GetComponentsInChildren<CharacterDrop>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.Destroy((Object)(object)componentsInChildren[i]);
			}
			Component[] componentsInChildren2 = val2.GetComponentsInChildren<Component>(true);
			foreach (Component val3 in componentsInChildren2)
			{
				string name = ((object)val3).GetType().Name;
				if (name == "DropOnDestroy" || name == "SpawnOnDestroy")
				{
					Object.Destroy((Object)(object)val3);
				}
			}
			Character component = val2.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.SetLevel(3);
				component.SetMaxHealth(maxHealth);
				component.SetHealth(maxHealth);
			}
			val2.AddComponent<BlightedSubBoss>();
			switch (index)
			{
			case 1:
				m_subBoss1 = component;
				if ((Object)(object)m_nview != (Object)null && m_nview.GetZDO() != null && (Object)(object)component != (Object)null)
				{
					ZNetView component3 = ((Component)component).GetComponent<ZNetView>();
					if ((Object)(object)component3 != (Object)null && component3.GetZDO() != null)
					{
						m_nview.GetZDO().Set(ZDO_SubBoss1, component3.GetZDO().m_uid);
					}
				}
				break;
			case 2:
				m_subBoss2 = component;
				if ((Object)(object)m_nview != (Object)null && m_nview.GetZDO() != null && (Object)(object)component != (Object)null)
				{
					ZNetView component2 = ((Component)component).GetComponent<ZNetView>();
					if ((Object)(object)component2 != (Object)null && component2.GetZDO() != null)
					{
						m_nview.GetZDO().Set(ZDO_SubBoss2, component2.GetZDO().m_uid);
					}
				}
				break;
			}
		}

		private string[] GetWaveEnemiesForBiome(Biome biome)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected I4, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			if ((int)biome <= 8)
			{
				switch (biome - 1)
				{
				default:
					if ((int)biome != 8)
					{
						break;
					}
					return new string[3] { "Greydwarf", "Greydwarf_Elite", "Skeleton" };
				case 0:
					return new string[3] { "Boar", "Neck", "Greyling" };
				case 1:
					return new string[3] { "Draugr", "Blob", "Leech" };
				case 3:
					return new string[2] { "Wolf", "Hatchling" };
				case 2:
					break;
				}
			}
			else
			{
				if ((int)biome == 16)
				{
					return new string[2] { "Goblin", "Deathsquito" };
				}
				if ((int)biome == 32)
				{
					return new string[2] { "Charred_Melee", "Charred_Archer" };
				}
				if ((int)biome == 512)
				{
					return new string[2] { "Seeker", "SeekerBrood" };
				}
			}
			return new string[1] { "Boar" };
		}

		private string GetSubBossForBiome(Biome biome)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected I4, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			string[] array;
			if ((int)biome <= 8)
			{
				switch (biome - 1)
				{
				case 0:
					goto IL_0045;
				case 1:
					goto IL_0085;
				case 3:
					goto IL_00a6;
				case 2:
					goto IL_0112;
				}
				if ((int)biome != 8)
				{
					goto IL_0112;
				}
				array = new string[3] { "Greydwarf_Elite", "Troll", "Skeleton_Poison" };
			}
			else if ((int)biome != 16)
			{
				if ((int)biome != 32)
				{
					if ((int)biome != 512)
					{
						goto IL_0112;
					}
					array = new string[2] { "SeekerBrute", "Seeker" };
				}
				else
				{
					array = new string[2] { "Morgen", "Charred_Melee" };
				}
			}
			else
			{
				array = new string[3] { "GoblinBrute", "GoblinShaman", "Lox" };
			}
			goto IL_0121;
			IL_0121:
			return array[Random.Range(0, array.Length)];
			IL_0045:
			array = new string[2] { "Boar", "Neck" };
			goto IL_0121;
			IL_00a6:
			array = new string[2] { "Fenring", "StoneGolem" };
			goto IL_0121;
			IL_0112:
			array = new string[1] { "Boar" };
			goto IL_0121;
			IL_0085:
			array = new string[3] { "Draugr_Elite", "Wraith", "Abomination" };
			goto IL_0121;
		}
	}
	public static class BlightedConfigManager
	{
		public class BiomeConfig
		{
			public ConfigEntry<float> BossHP;

			public ConfigEntry<float> SubBossThreshold1;

			public ConfigEntry<float> SubBossThreshold2;

			public ConfigEntry<float> SubBoss1HP;

			public ConfigEntry<float> SubBoss2HP;

			public ConfigEntry<float> LootScaleFactor;

			public ConfigEntry<int> MaxEnemiesPerWave;

			public ConfigEntry<float> WaveTimerSeconds;

			public ConfigEntry<string> AltarSummonItem;

			public ConfigEntry<int> AltarSummonAmount;
		}

		public static Dictionary<Biome, BiomeConfig> BiomeConfigs = new Dictionary<Biome, BiomeConfig>();

		public static ConfigEntry<bool> DebugMode;

		public static ConfigEntry<bool> EnableWaveAnnouncement;

		public static ConfigEntry<MessageType> WaveAnnouncementLocation;

		public static void SetupConfig(BlightedHeartPlugin plugin)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			((BaseUnityPlugin)plugin).Config.SaveOnConfigSet = true;
			DebugMode = ((BaseUnityPlugin)plugin).Config.Bind<bool>("General", "Debug Mode", false, new ConfigDescription("Enable verbose debug logging.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			EnableWaveAnnouncement = ((BaseUnityPlugin)plugin).Config.Bind<bool>("General", "Enable Wave Announcement", true, new ConfigDescription("Toggle for wave spawn text.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			WaveAnnouncementLocation = ((BaseUnityPlugin)plugin).Config.Bind<MessageType>("General", "Wave Announcement Location", (MessageType)2, new ConfigDescription("Where the wave text displays.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			SetupBiomeConfig(plugin, (Biome)1, 3000f, 0.5f, 0.2f, 750f, 1250f, 1.5f, 6, 8f, "HardAntler", 1);
			SetupBiomeConfig(plugin, (Biome)8, 6000f, 0.5f, 0.2f, 1500f, 2500f, 2f, 7, 8f, "CryptKey", 1);
			SetupBiomeConfig(plugin, (Biome)2, 9000f, 0.5f, 0.2f, 2250f, 3750f, 2.5f, 8, 8f, "Wishbone", 1);
			SetupBiomeConfig(plugin, (Biome)4, 12000f, 0.5f, 0.2f, 3000f, 5000f, 3f, 9, 8f, "DragonTear", 1);
			SetupBiomeConfig(plugin, (Biome)16, 18000f, 0.5f, 0.2f, 4500f, 7500f, 3.5f, 10, 8f, "YagluthDrop", 1);
			SetupBiomeConfig(plugin, (Biome)512, 24000f, 0.5f, 0.2f, 6000f, 10000f, 4.5f, 11, 8f, "QueenDrop", 1);
			SetupBiomeConfig(plugin, (Biome)32, 30000f, 0.5f, 0.2f, 7500f, 12500f, 5.5f, 12, 8f, "FaderDrop", 1);
			SetupBiomeConfig(plugin, (Biome)64, 37500f, 0.5f, 0.2f, 9000f, 15000f, 6f, 13, 8f, "FaderDrop", 1);
		}

		private unsafe static void SetupBiomeConfig(BlightedHeartPlugin plugin, Biome biome, float defaultHP, float defaultThreshold1, float defaultThreshold2, float defaultSubBoss1HP, float defaultSubBoss2HP, float defaultLootScale, int defaultMaxEnemies, float defaultWaveTimer, string defaultSummonItem, int defaultSummonAmount)
		{
			//IL_003b: 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_0048: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0073: 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_0080: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Expected O, but got Unknown
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Expected O, but got Unknown
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Expected O, but got Unknown
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			string text = ((object)(*(Biome*)(&biome))/*cast due to .constrained prefix*/).ToString();
			BiomeConfig biomeConfig = new BiomeConfig();
			biomeConfig.BossHP = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Boss HP", defaultHP, new ConfigDescription("Base HP of the Blighted World Heart when summoned in the " + text + ".", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			biomeConfig.SubBossThreshold1 = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Sub-Boss Threshold 1", defaultThreshold1, new ConfigDescription("Health percentage (0.0 to 1.0) to spawn the first sub-boss.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			biomeConfig.SubBossThreshold2 = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Sub-Boss Threshold 2", defaultThreshold2, new ConfigDescription("Health percentage (0.0 to 1.0) to spawn the second sub-boss.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			biomeConfig.SubBoss1HP = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Sub-Boss 1 HP", defaultSubBoss1HP, new ConfigDescription("Max HP of the first sub-boss.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			biomeConfig.SubBoss2HP = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Sub-Boss 2 HP", defaultSubBoss2HP, new ConfigDescription("Max HP of the second sub-boss.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			biomeConfig.LootScaleFactor = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Loot Scale Factor", defaultLootScale, new ConfigDescription("Multiplier for the loot quality and drop amounts.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			biomeConfig.MaxEnemiesPerWave = ((BaseUnityPlugin)plugin).Config.Bind<int>(text, "Max Enemies Per Wave", defaultMaxEnemies, new ConfigDescription("Maximum number of standard enemies that can be alive in a single wave.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			biomeConfig.WaveTimerSeconds = ((BaseUnityPlugin)plugin).Config.Bind<float>(text, "Wave Timer Seconds", defaultWaveTimer, new ConfigDescription("Time in seconds between enemy wave spawns.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			biomeConfig.AltarSummonItem = ((BaseUnityPlugin)plugin).Config.Bind<string>(text, "Altar Summon Item", defaultSummonItem, new ConfigDescription("The prefab name of the item required to summon the boss in this biome.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			biomeConfig.AltarSummonAmount = ((BaseUnityPlugin)plugin).Config.Bind<int>(text, "Altar Summon Amount", defaultSummonAmount, new ConfigDescription("The amount of the summon item required.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			BiomeConfig value = biomeConfig;
			BiomeConfigs[biome] = value;
		}
	}
	[BepInPlugin("wubarrk.blightedworldheart", "BlightedWorldHeart", "1.0.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class BlightedHeartPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "wubarrk.blightedworldheart";

		public const string PluginName = "BlightedWorldHeart";

		public const string PluginVersion = "1.0.5";

		private readonly Harmony _harmony = new Harmony("wubarrk.blightedworldheart");

		private void Awake()
		{
			BlightedConfigManager.SetupConfig(this);
			PrefabManager.OnVanillaPrefabsAvailable += SetupBlightedHeartPrefab;
			PrefabManager.OnVanillaPrefabsAvailable += BlightedItemsManager.Setup;
			_harmony.PatchAll();
			Logger.LogInfo((object)"BlightedWorldHeart v1.0.5 loaded.");
		}

		private void SetupBlightedHeartPrefab()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0061: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= SetupBlightedHeartPrefab;
			Logger.LogInfo((object)"Setting up Blighted World Heart prefab...");
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("BlightedWorldHeart", "TheHive");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Could not create cloned prefab BlightedWorldHeart!");
				return;
			}
			CustomPrefab val2 = new CustomPrefab(val, true);
			val.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
			if ((Object)(object)val.GetComponent<ZNetView>() == (Object)null)
			{
				val.AddComponent<ZNetView>();
			}
			val.AddComponent<BlightedWorldHeartAI>();
			PrefabManager.Instance.AddPrefab(val2);
			Logger.LogInfo((object)"BlightedWorldHeart prefab registered. Runtime cleanup will happen on spawn.");
			GameObject val3 = new GameObject("BlightedUIManager");
			Object.DontDestroyOnLoad((Object)val3);
			val3.AddComponent<BlightedUIManager>();
		}
	}
	public class BlightedDamageForwarder : MonoBehaviour, IDestructible
	{
		public BlightedWorldHeartAI m_heart;

		public DestructibleType GetDestructibleType()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_heart != (Object)null))
			{
				return (DestructibleType)1;
			}
			return m_heart.GetDestructibleType();
		}

		public void Damage(HitData hit)
		{
			if ((Object)(object)m_heart != (Object)null)
			{
				m_heart.Damage(hit);
			}
		}
	}
	public class BlightedSubBoss : MonoBehaviour
	{
		public Character m_character;

		private void Awake()
		{
			m_character = ((Component)this).GetComponent<Character>();
			if ((Object)(object)m_character != (Object)null)
			{
				m_character.m_boss = false;
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BlightedHeart";

		public const string PLUGIN_NAME = "BlightedHeart";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}