Decompiled source of BiomeConqueror v1.1.1

BiomeConqueror.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BiomeConqueror")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BiomeConqueror")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("69445434-75c1-4c5a-ac41-b01dc8b00a95")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BiomeConqueror
{
	[BepInPlugin("Turbero.BiomeConqueror", "Biome Conqueror", "1.1.1")]
	public class BiomeConqueror : BaseUnityPlugin
	{
		public const string GUID = "Turbero.BiomeConqueror";

		public const string NAME = "Biome Conqueror";

		public const string VERSION = "1.1.1";

		private readonly Harmony harmony = new Harmony("Turbero.BiomeConqueror");

		private void Awake()
		{
			ConfigurationFile.LoadConfig((BaseUnityPlugin)(object)this);
			harmony.PatchAll();
		}

		private void onDestroy()
		{
			harmony.UnpatchSelf();
		}

		private void Update()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !Object.op_Implicit((Object)(object)InventoryGui.instance))
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)27) || Input.GetKeyDown((KeyCode)9) || ((Character)Player.m_localPlayer).IsDead())
			{
				((Component)InventoryGui.instance.m_textsDialog).gameObject.SetActive(false);
			}
			if (Input.GetKeyDown(ConfigurationFile.hotKey.Value) && Time.timeScale > 0f)
			{
				if (((Component)InventoryGui.instance.m_textsDialog).gameObject.activeSelf)
				{
					((Component)InventoryGui.instance.m_textsDialog).gameObject.SetActive(false);
					InventoryGui.instance.Hide();
				}
				else
				{
					InventoryGui.instance.Show((Container)null, 1);
					WaitForSecondsAsync(0.15f);
				}
			}
		}

		private static async Task WaitForSecondsAsync(float seconds)
		{
			await Task.Delay((int)(Math.Max(0f, seconds) * 1000f));
			InventoryGui.instance.m_textsDialog.Setup(Player.m_localPlayer);
			((Component)InventoryGui.instance.m_textsDialog).gameObject.SetActive(true);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Show")]
	public class InventoryGui_Show_Patch
	{
		private static void Postfix(InventoryGui __instance)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			if (!ConfigurationFile.modEnabled.Value || !((Object)(object)__instance.m_player != (Object)null))
			{
				return;
			}
			Transform val = ((Component)((Component)((Component)__instance).transform.Find("root")).transform.Find("Info")).transform.Find("Texts");
			if ((Object)(object)val != (Object)null)
			{
				UITooltip component = ((Component)val).GetComponent<UITooltip>();
				if ((Object)(object)component != (Object)null)
				{
					string text = "$inventory_texts";
					string text2 = $" ({ConfigurationFile.hotKey.Value})";
					component.m_text = text + text2;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "OnSpawned")]
	public class Player_OnSpawned_Patch
	{
		private static void Postfix(Player __instance, bool spawnValkyrie)
		{
			PlayerBuffs.ActivateCurrentEnvBiomeBenefitBuff();
		}
	}
	[HarmonyPatch(typeof(EnvMan))]
	public static class BiomeChangePatch
	{
		private static Biome previousBiome;

		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(EnvMan), "UpdateEnvironment", (Type[])null, (Type[])null);
		}

		public static void Postfix(long sec, 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_0016: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (biome != previousBiome)
			{
				Logger.Log($"Biome changed: {previousBiome} -> {biome}");
				previousBiome = biome;
				PlayerBuffs.ActivateCurrentEnvBiomeBenefitBuff();
			}
		}
	}
	public class BiomeConquerorUtils
	{
		private static bool hasUniqueKey(string key, bool configValue)
		{
			return ConfigurationFile.modEnabled.Value && configValue && ((Humanoid)Player.m_localPlayer).HaveUniqueKey(key);
		}

		private static bool hasGlobalKey(string key)
		{
			return ConfigurationFile.modEnabled.Value && ConfigurationFile.worldProgression.Value && ZoneSystem.instance.GetGlobalKey(key);
		}

		public static bool isBonemassDefeatedForPlayer()
		{
			return hasUniqueKey("BonemassDefeated", ConfigurationFile.bonemassBenefitEligibleEnabled.Value) || hasGlobalKey("defeated_bonemass");
		}

		public static bool isModerDefeatedForPlayer()
		{
			return hasUniqueKey("ModerDefeated", ConfigurationFile.moderBenefitEligibleEnabled.Value) || hasGlobalKey("defeated_dragon");
		}

		public static bool isYagluthDefeatedForPlayer()
		{
			return hasUniqueKey("YagluthDefeated", ConfigurationFile.yagluthBenefitEligibleEnabled.Value) || hasGlobalKey("defeated_goblinking");
		}

		public static bool isQueenDefeatedForPlayer()
		{
			return hasUniqueKey("QueenDefeated", ConfigurationFile.queenBenefitEligibleEnabled.Value) || hasGlobalKey("defeated_queen");
		}
	}
	[HarmonyPatch]
	public class CompendiumPatch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(TextsDialog), "AddActiveEffects", (Type[])null, (Type[])null);
		}

		private static void Postfix(ref TextsDialog __instance)
		{
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Expected O, but got Unknown
			FieldInfo field = typeof(TextsDialog).GetField("m_texts", BindingFlags.Instance | BindingFlags.NonPublic);
			List<TextInfo> list = (List<TextInfo>)field.GetValue(__instance);
			TextInfo val = list[0];
			string text = val.m_text;
			bool flag = BiomeConquerorUtils.isBonemassDefeatedForPlayer();
			bool flag2 = BiomeConquerorUtils.isModerDefeatedForPlayer();
			bool flag3 = BiomeConquerorUtils.isYagluthDefeatedForPlayer();
			bool flag4 = BiomeConquerorUtils.isQueenDefeatedForPlayer();
			if (flag || flag2 || flag4)
			{
				StringBuilder stringBuilder = new StringBuilder(256);
				stringBuilder.Append("\n\n");
				stringBuilder.Append("<color=yellow>BiomeConqueror Mod</color>\n");
				if (flag)
				{
					stringBuilder.Append("<color=orange>" + Localization.instance.Localize("$se_bonemass_name") + "</color>\n");
					stringBuilder.Append(Localization.instance.Localize("$biome_swamp") + " / " + Localization.instance.Localize("$se_wet_name") + " = " + Localization.instance.Localize("$menu_none"));
					stringBuilder.Append("\n");
				}
				if (flag2)
				{
					stringBuilder.Append("<color=orange>" + Localization.instance.Localize("$se_moder_name") + "</color>\n");
					stringBuilder.Append(Localization.instance.Localize("$biome_mountain") + " / " + Localization.instance.Localize("$se_freezing_name") + " = " + Localization.instance.Localize("$menu_none"));
					stringBuilder.Append("\n");
				}
				if (flag3)
				{
					stringBuilder.Append("<color=orange>" + Localization.instance.Localize("$se_yagluth_name") + "</color>\n");
					stringBuilder.Append(Localization.instance.Localize("$biome_plains") + " / " + Localization.instance.Localize("$enemy_deathsquito") + " = " + Localization.instance.Localize("$menu_none"));
					stringBuilder.Append("\n");
				}
				if (flag4)
				{
					stringBuilder.Append("<color=orange>" + Localization.instance.Localize("$se_queen_name") + "</color>\n");
					stringBuilder.Append(Localization.instance.Localize("$item_demister") + " = " + ConfigurationFile.queenBenefitEligibleRange.Value + "m.");
					stringBuilder.Append("\n");
				}
				list.RemoveAt(0);
				list.Insert(0, new TextInfo(Localization.instance.Localize("$inventory_activeeffects"), text + stringBuilder.ToString()));
			}
		}
	}
	internal class ConfigurationFile
	{
		public static ConfigEntry<bool> modEnabled;

		public static ConfigEntry<bool> debug;

		public static ConfigEntry<KeyCode> hotKey;

		public static ConfigEntry<bool> worldProgression;

		public static ConfigEntry<bool> benefitIcons;

		public static ConfigEntry<bool> bonemassBenefitEligibleEnabled;

		public static ConfigEntry<bool> moderBenefitEligibleEnabled;

		public static ConfigEntry<bool> yagluthBenefitEligibleEnabled;

		public static ConfigEntry<bool> queenBenefitEligibleEnabled;

		public static ConfigEntry<float> queenBenefitEligibleRange;

		private static ConfigFile config;

		internal static void LoadConfig(BaseUnityPlugin plugin)
		{
			config = plugin.Config;
			modEnabled = config.Bind<bool>("1 - General", "Enabled", true, "Enabling/Disabling the mod (default = true)");
			debug = config.Bind<bool>("1 - General", "DebugMode", false, "Enabling/Disabling the debugging in the console (default = false)");
			worldProgression = config.Bind<bool>("2 - Config", "WorldProgression", false, "Enabling/Disabling the benefits with the world progression (default = false, which is by player personal battle wins)");
			hotKey = config.Bind<KeyCode>("2 - Config", "HotKey", (KeyCode)284, "Hot key to open the compendium (default = F3)");
			benefitIcons = config.Bind<bool>("2 - Config", "BenefitIcons", false, "Enabling/Disabling the benefits as permanent buffs (default = false)");
			bonemassBenefitEligibleEnabled = config.Bind<bool>("3 - Victories", "BonemassBenefitEligibleEnabled", true, "Allows to earn the benefit that stops getting wet by rain in all swamps after killing Bonemass (default = true)");
			moderBenefitEligibleEnabled = config.Bind<bool>("3 - Victories", "ModerBenefitEligibleEnabled", true, "Allows to earn the benefit that stops getting frozen without protection effects in all mountains after killing Moder (default = true)");
			yagluthBenefitEligibleEnabled = config.Bind<bool>("3 - Victories", "YagluthBenefitEligibleEnabled", true, "Allows to earn the benefit that stops deathsquitos attacking you (default = true)");
			queenBenefitEligibleEnabled = config.Bind<bool>("3 - Victories", "QueenBenefitEligibleEnabled", true, "Allows to earn the benefit that increases the wisp light range after killing The Seeker Queen (default = true)");
			queenBenefitEligibleRange = config.Bind<float>("3 - Victories", "QueenBenefitRange", 100f, "Establishes the new wisp light range after killing The Seeker Queen (default = true)");
			modEnabled.SettingChanged += Configuration_SettingChanged;
			worldProgression.SettingChanged += Configuration_SettingChanged;
			benefitIcons.SettingChanged += BenefitIcons_SettingChanged;
			bonemassBenefitEligibleEnabled.SettingChanged += Configuration_SettingChanged;
			moderBenefitEligibleEnabled.SettingChanged += Configuration_SettingChanged;
			yagluthBenefitEligibleEnabled.SettingChanged += Configuration_SettingChanged;
			queenBenefitEligibleEnabled.SettingChanged += Configuration_SettingChanged;
			queenBenefitEligibleRange.SettingChanged += Configuration_SettingChanged;
		}

		private static void BenefitIcons_SettingChanged(object sender, EventArgs e)
		{
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				if (!benefitIcons.Value)
				{
					PlayerBuffs.RemoveAllBenefitBuffs();
				}
				else
				{
					PlayerBuffs.AddPlayerBiomeBenefitBuff();
				}
			}
		}

		private static void Configuration_SettingChanged(object sender, EventArgs e)
		{
			if (modEnabled.Value)
			{
				PlayerBuffs.RemoveAllBenefitBuffs();
				PlayerBuffs.AddPlayerBiomeBenefitBuff();
				ReloadWispLight();
			}
			else
			{
				PlayerBuffs.RemoveAllBenefitBuffs();
			}
		}

		private static async Task ReloadWispLight()
		{
			await Task.Delay(0);
			ItemData itemData = ((IEnumerable<ItemData>)((Humanoid)Player.m_localPlayer).GetInventory().GetEquippedItems()).FirstOrDefault((Func<ItemData, bool>)((ItemData i) => ((Object)i.m_dropPrefab).name == "Demister"));
			if (itemData != null)
			{
				((Humanoid)Player.m_localPlayer).UnequipItem(itemData, true);
				((Humanoid)Player.m_localPlayer).EquipItem(itemData, true);
			}
		}
	}
	public class Constants
	{
		public static readonly string BONEMASS_DEFEATED_MESSAGE_KEY = "$event_boss03_end";

		public static readonly string MODER_DEFEATED_MESSAGE_KEY = "$event_boss04_end";

		public static readonly string YAGLUTH_DEFEATED_MESSAGE_KEY = "$event_boss05_end";

		public static readonly string QUEEN_DEFEATED_MESSAGE_KEY = "$enemy_boss_queen_deathmessage";

		public static readonly string TROPHY_BONEMASS = "TrophyBonemass";

		public static readonly string TROPHY_MODER = "TrophyDragonQueen";

		public static readonly string TROPHY_YAGLUTH = "TrophyGoblinKing";

		public static readonly string TROPHY_QUEEN = "TrophySeekerQueen";

		public static readonly string BONEMASS_DEFEATED_PLAYER_KEY = "BonemassDefeated";

		public static readonly string MODER_DEFEATED_PLAYER_KEY = "ModerDefeated";

		public static readonly string YAGLUTH_DEFEATED_PLAYER_KEY = "YagluthDefeated";

		public static readonly string QUEEN_DEFEATED_PLAYER_KEY = "QueenDefeated";
	}
	public static class Logger
	{
		internal static void Log(object s)
		{
			if (ConfigurationFile.debug.Value)
			{
				string text = "[Biome Conqueror 1.1.1]: " + ((s != null) ? s.ToString() : "null");
				Debug.Log((object)text);
			}
		}

		internal static void LogWarning(object s)
		{
			string text = "[Biome Conqueror 1.1.1]: " + ((s != null) ? s.ToString() : "null");
			Debug.LogWarning((object)text);
		}

		internal static void LogError(object s)
		{
			string text = "[Biome Conqueror 1.1.1]: " + ((s != null) ? s.ToString() : "null");
			Debug.LogError((object)text);
		}
	}
	public class PlayerBuffs
	{
		private static Dictionary<string, Sprite> cachedSprites = new Dictionary<string, Sprite>();

		public static void AddBenefitBuff(Player player, string name, string spriteName)
		{
			RemoveAllBenefitBuffs();
			SEMan sEMan = ((Character)player).GetSEMan();
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((StatusEffect)val).m_name = name;
			((StatusEffect)val).m_tooltip = getBenefitTooltipBySpriteName(spriteName);
			((StatusEffect)val).m_icon = getSprite(spriteName);
			((Object)val).name = name;
			int num = ((StatusEffect)val).NameHash();
			Logger.Log($"name: {((Object)val).name}, m_name: {((StatusEffect)val).m_name}, nameHash: {num}");
			sEMan.AddStatusEffect((StatusEffect)(object)val, false, 0, 0f);
			Logger.Log("Added buff: " + ((StatusEffect)val).m_name);
		}

		public static void RemoveAllBenefitBuffs()
		{
			List<string> list = new List<string>
			{
				Constants.BONEMASS_DEFEATED_MESSAGE_KEY,
				Constants.MODER_DEFEATED_MESSAGE_KEY,
				Constants.YAGLUTH_DEFEATED_MESSAGE_KEY,
				Constants.QUEEN_DEFEATED_MESSAGE_KEY
			};
			foreach (string item in list)
			{
				Player localPlayer = Player.m_localPlayer;
				SEMan sEMan = ((Character)localPlayer).GetSEMan();
				StatusEffect statusEffect = sEMan.GetStatusEffect(item.GetHashCode());
				if ((Object)(object)statusEffect != (Object)null)
				{
					sEMan.RemoveStatusEffect(statusEffect, false);
					Logger.Log("Deleted buff: " + statusEffect.m_name);
				}
			}
		}

		public static Sprite getSprite(string name)
		{
			if (!cachedSprites.ContainsKey(name))
			{
				Logger.Log("Finding " + name + " sprite...");
				Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>();
				foreach (Sprite val in array)
				{
					if (((Object)val).name == name)
					{
						Logger.Log(name + " sprite found.");
						cachedSprites.Add(name, val);
						return val;
					}
				}
				Logger.Log(name + " sprite NOT found.");
				return null;
			}
			return GeneralExtensions.GetValueSafe<string, Sprite>(cachedSprites, name);
		}

		private static string getBenefitTooltipBySpriteName(string spriteName)
		{
			if (spriteName == Constants.TROPHY_BONEMASS)
			{
				return Localization.instance.Localize("$biome_swamp") + " / " + Localization.instance.Localize("$se_wet_name") + " = " + Localization.instance.Localize("$menu_none");
			}
			if (spriteName == Constants.TROPHY_MODER)
			{
				return Localization.instance.Localize("$biome_mountain") + " / " + Localization.instance.Localize("$se_freezing_name") + " = " + Localization.instance.Localize("$menu_none");
			}
			if (spriteName == Constants.TROPHY_YAGLUTH)
			{
				return Localization.instance.Localize("$biome_plains") + " / " + Localization.instance.Localize("$enemy_deathsquito") + " = " + Localization.instance.Localize("$menu_none");
			}
			if (spriteName == Constants.TROPHY_QUEEN)
			{
				return Localization.instance.Localize("$item_demister") + " = " + ConfigurationFile.queenBenefitEligibleRange.Value + "m.";
			}
			return "";
		}

		public static void ActivateCurrentEnvBiomeBenefitBuff()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Invalid comparison between Unknown and I4
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Invalid comparison between Unknown and I4
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			if ((int)EnvMan.instance.GetCurrentBiome() == 2 && BiomeConquerorUtils.isBonemassDefeatedForPlayer())
			{
				if (ConfigurationFile.benefitIcons.Value)
				{
					AddBenefitBuff(localPlayer, Constants.BONEMASS_DEFEATED_MESSAGE_KEY, Constants.TROPHY_BONEMASS);
				}
			}
			else if ((int)EnvMan.instance.GetCurrentBiome() == 4 && BiomeConquerorUtils.isModerDefeatedForPlayer())
			{
				if (ConfigurationFile.benefitIcons.Value)
				{
					AddBenefitBuff(localPlayer, Constants.MODER_DEFEATED_MESSAGE_KEY, Constants.TROPHY_MODER);
				}
			}
			else if ((int)EnvMan.instance.GetCurrentBiome() == 16 && BiomeConquerorUtils.isYagluthDefeatedForPlayer())
			{
				if (ConfigurationFile.benefitIcons.Value)
				{
					AddBenefitBuff(localPlayer, Constants.YAGLUTH_DEFEATED_MESSAGE_KEY, Constants.TROPHY_YAGLUTH);
				}
			}
			else if ((int)EnvMan.instance.GetCurrentBiome() == 512 && BiomeConquerorUtils.isQueenDefeatedForPlayer())
			{
				if (ConfigurationFile.benefitIcons.Value)
				{
					AddBenefitBuff(localPlayer, Constants.QUEEN_DEFEATED_MESSAGE_KEY, Constants.TROPHY_QUEEN);
				}
			}
			else
			{
				RemoveAllBenefitBuffs();
			}
		}

		public static void AddPlayerBiomeBenefitBuff()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Invalid comparison between Unknown and I4
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Invalid comparison between Unknown and I4
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Invalid comparison between Unknown and I4
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			if ((int)localPlayer.GetCurrentBiome() == 2 && BiomeConquerorUtils.isBonemassDefeatedForPlayer())
			{
				if (ConfigurationFile.benefitIcons.Value)
				{
					AddBenefitBuff(Player.m_localPlayer, Constants.BONEMASS_DEFEATED_MESSAGE_KEY, Constants.TROPHY_BONEMASS);
				}
			}
			else if ((int)localPlayer.GetCurrentBiome() == 4 && BiomeConquerorUtils.isModerDefeatedForPlayer())
			{
				if (ConfigurationFile.benefitIcons.Value)
				{
					AddBenefitBuff(Player.m_localPlayer, Constants.MODER_DEFEATED_MESSAGE_KEY, Constants.TROPHY_MODER);
				}
			}
			else if ((int)localPlayer.GetCurrentBiome() == 16 && BiomeConquerorUtils.isYagluthDefeatedForPlayer())
			{
				if (ConfigurationFile.benefitIcons.Value)
				{
					AddBenefitBuff(Player.m_localPlayer, Constants.YAGLUTH_DEFEATED_MESSAGE_KEY, Constants.TROPHY_YAGLUTH);
				}
			}
			else if ((int)localPlayer.GetCurrentBiome() == 512 && BiomeConquerorUtils.isQueenDefeatedForPlayer() && ConfigurationFile.benefitIcons.Value)
			{
				AddBenefitBuff(Player.m_localPlayer, Constants.QUEEN_DEFEATED_MESSAGE_KEY, Constants.TROPHY_QUEEN);
			}
		}
	}
}
namespace BiomeConqueror.Benefits
{
	public class EarnBenefit
	{
		[HarmonyPatch(typeof(Character), "OnDeath")]
		public class CharacterDeathPatch
		{
			private static void Postfix(Character __instance)
			{
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Invalid comparison between Unknown and I4
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Invalid comparison between Unknown and I4
				//IL_0156: Unknown result type (might be due to invalid IL or missing references)
				//IL_015d: Invalid comparison between Unknown and I4
				//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01df: Invalid comparison between Unknown and I4
				if (!ConfigurationFile.modEnabled.Value || !((Object)(object)__instance != (Object)null) || !__instance.IsBoss())
				{
					return;
				}
				Logger.Log("defeated name: " + __instance.m_name);
				if (__instance.m_name == "$enemy_bonemass" && (int)Player.m_localPlayer.GetCurrentBiome() == 2)
				{
					((Humanoid)Player.m_localPlayer).AddUniqueKey(Constants.BONEMASS_DEFEATED_PLAYER_KEY);
					Logger.Log("** Bonemass defeated");
					if (ConfigurationFile.benefitIcons.Value && ConfigurationFile.bonemassBenefitEligibleEnabled.Value)
					{
						PlayerBuffs.AddBenefitBuff(Player.m_localPlayer, Constants.BONEMASS_DEFEATED_MESSAGE_KEY, Constants.TROPHY_BONEMASS);
					}
				}
				else if (__instance.m_name == "$enemy_dragon" && (int)Player.m_localPlayer.GetCurrentBiome() == 4)
				{
					((Humanoid)Player.m_localPlayer).AddUniqueKey(Constants.MODER_DEFEATED_PLAYER_KEY);
					Logger.Log("** Moder defeated");
					if (ConfigurationFile.benefitIcons.Value && ConfigurationFile.moderBenefitEligibleEnabled.Value)
					{
						PlayerBuffs.AddBenefitBuff(Player.m_localPlayer, Constants.MODER_DEFEATED_MESSAGE_KEY, Constants.TROPHY_MODER);
					}
				}
				else if (__instance.m_name == "$enemy_goblinking" && (int)Player.m_localPlayer.GetCurrentBiome() == 16)
				{
					((Humanoid)Player.m_localPlayer).AddUniqueKey(Constants.YAGLUTH_DEFEATED_PLAYER_KEY);
					Logger.Log("** Yagluth defeated");
					if (ConfigurationFile.benefitIcons.Value && ConfigurationFile.yagluthBenefitEligibleEnabled.Value)
					{
						PlayerBuffs.AddBenefitBuff(Player.m_localPlayer, Constants.YAGLUTH_DEFEATED_MESSAGE_KEY, Constants.TROPHY_YAGLUTH);
					}
				}
				else
				{
					if (!(__instance.m_name == "$enemy_seekerqueen") || (int)Player.m_localPlayer.GetCurrentBiome() != 512)
					{
						return;
					}
					((Humanoid)Player.m_localPlayer).AddUniqueKey(Constants.QUEEN_DEFEATED_PLAYER_KEY);
					Logger.Log("** Queen defeated");
					if (ConfigurationFile.benefitIcons.Value && ConfigurationFile.queenBenefitEligibleEnabled.Value)
					{
						PlayerBuffs.AddBenefitBuff(Player.m_localPlayer, Constants.QUEEN_DEFEATED_MESSAGE_KEY, Constants.TROPHY_QUEEN);
						ItemData val = ((IEnumerable<ItemData>)((Humanoid)Player.m_localPlayer).GetInventory().GetEquippedItems()).FirstOrDefault((Func<ItemData, bool>)((ItemData i) => ((Object)i.m_dropPrefab).name == "Demister"));
						if (val != null)
						{
							((Humanoid)Player.m_localPlayer).UnequipItem(val, true);
							((Humanoid)Player.m_localPlayer).EquipItem(val, true);
						}
					}
				}
			}
		}
	}
	[HarmonyPatch]
	public class MistlandsPatch
	{
		public static float demisterRange;

		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(Demister), "OnEnable", (Type[])null, (Type[])null);
		}

		private static void Postfix(ref Demister __instance)
		{
			if (!ConfigurationFile.modEnabled.Value)
			{
				return;
			}
			try
			{
				if (BiomeConquerorUtils.isQueenDefeatedForPlayer())
				{
					ItemData val = ((IEnumerable<ItemData>)((Humanoid)Player.m_localPlayer).GetInventory().GetEquippedItems()).FirstOrDefault((Func<ItemData, bool>)((ItemData i) => ((Object)i.m_dropPrefab).name == "Demister"));
					if (!((Behaviour)__instance).isActiveAndEnabled || val == null)
					{
						return;
					}
					__instance.m_forceField.endRange = ConfigurationFile.queenBenefitEligibleRange.Value;
				}
				demisterRange = __instance.m_forceField.endRange;
				StatusEffect val2 = ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffects().First((StatusEffect effect) => ((Object)effect).name == "Demister");
				val2.m_name = "$item_demister: {demisterRange}m.";
				Logger.Log("demister buff text updated to " + val2.m_name);
			}
			catch (Exception)
			{
			}
		}
	}
	[HarmonyPatch]
	public class PlainsPatch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(MonsterAI), "PheromoneFleeCheck", (Type[])null, (Type[])null);
		}

		private static bool Prefix(MonsterAI __instance, Character target, ref bool __result)
		{
			if (BiomeConquerorUtils.isYagluthDefeatedForPlayer() && ((Object)__instance).name.Contains("Deathsquito"))
			{
				__result = true;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(EnvMan), "UpdateEnvironment")]
	public class WeatherPatch
	{
		private static void Prefix(EnvMan __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Invalid comparison between Unknown and I4
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer != (Object)null))
			{
				return;
			}
			if ((int)localPlayer.GetCurrentBiome() == 2)
			{
				if (BiomeConquerorUtils.isBonemassDefeatedForPlayer())
				{
					__instance.GetCurrentEnvironment().m_isWet = false;
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect("Wet".GetHashCode()))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect("Wet".GetHashCode(), false);
					}
				}
				else
				{
					__instance.GetCurrentEnvironment().m_isWet = true;
				}
			}
			else if ((int)localPlayer.GetCurrentBiome() == 4)
			{
				if (BiomeConquerorUtils.isModerDefeatedForPlayer())
				{
					__instance.GetCurrentEnvironment().m_isFreezing = false;
					__instance.GetCurrentEnvironment().m_isFreezingAtNight = false;
				}
				else
				{
					__instance.GetCurrentEnvironment().m_isFreezing = true;
					__instance.GetCurrentEnvironment().m_isFreezingAtNight = true;
				}
			}
		}
	}
}