Decompiled source of balrond Absolute Overhaul v2.2.1

plugins/BalrondAbsoluteOverhaul.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using Balrond.Alchemy;
using Balrond.Building;
using Balrond.Clutter;
using Balrond.Components;
using Balrond.Core;
using Balrond.Core.Assets;
using Balrond.Core.Commands;
using Balrond.Core.Compatibility;
using Balrond.Core.Configuration;
using Balrond.Core.Diagnostics;
using Balrond.Core.Lifecycle;
using Balrond.Core.Networking;
using Balrond.Core.Runtime;
using Balrond.Core.Translation;
using Balrond.Crafting;
using Balrond.Equipment;
using Balrond.Features;
using Balrond.Features.Building;
using Balrond.Features.Combat;
using Balrond.Features.DeepNorth;
using Balrond.Features.Exploration;
using Balrond.Features.Farming;
using Balrond.Features.FishingThrowing;
using Balrond.Features.Forsaken;
using Balrond.Features.Interface;
using Balrond.Features.Interface.Hover;
using Balrond.Features.Movement;
using Balrond.Features.QualityOfLife;
using Balrond.Features.Survival;
using Balrond.Features.Terrain;
using Balrond.Features.Traps;
using Balrond.Fletcher;
using Balrond.Locations;
using Balrond.Misc;
using Balrond.NPC;
using Balrond.NPC.DailyOffers;
using Balrond.NPC.Services;
using Balrond.Patches.Features;
using Balrond.Status;
using Balrond.Vegetation;
using Balrond.Weather;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using SoftReferenceableAssets;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BalrondAbsoluteOverhaul")]
[assembly: AssemblyDescription("Balrond Absolute Overhaul - unified Valheim content, progression and quality-of-life overhaul")]
[assembly: AssemblyCompany("Balrond")]
[assembly: AssemblyProduct("BalrondAbsoluteOverhaul")]
[assembly: ComVisible(false)]
[assembly: Guid("cde312a0-cf19-4264-8616-e1c74774beed")]
[assembly: AssemblyFileVersion("2.2.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
namespace Balrond.Patches.NPC
{
	[HarmonyPatch(typeof(Trader), "Interact")]
	internal static class Trader_Interact_BuildableTraderStock
	{
		private static void Prefix(Trader __instance)
		{
			BuildableTraderService.ReconcileOnInteract(__instance);
			DailyTraderRuntime.OpenTrader(__instance);
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch(typeof(Game), "Start")]
	internal static class DailyTraderNetworkBootstrap
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			DailyTraderRuntime.Register();
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch]
	internal static class DailyTraderSessionCleanupPatch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(ZNet), "Shutdown", (Type[])null, (Type[])null);
		}

		[HarmonyPrefix]
		private static void Prefix()
		{
			DailyTraderRuntime.ResetSession();
			HildirChestSaleService.Restore();
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch(typeof(StoreGui), "BuySelectedItem")]
	internal static class DailyTraderPurchasePatch
	{
		[HarmonyPrefix]
		private static bool Prefix(StoreGui __instance)
		{
			return DailyTraderRuntime.BeforeBuy(__instance);
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch(typeof(Trader), "GetAvailableItems")]
	internal static class DailyTraderAvailablePatch
	{
		[HarmonyPrefix]
		private static void Prefix(Trader __instance)
		{
			DailyTraderRuntime.OpenTrader(__instance);
			HearthstoneService.ReconcileOffer(__instance);
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch]
	internal static class HildirChestSellablesPatch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(StoreGui), "GetSellableItem", (Type[])null, (Type[])null);
		}

		[HarmonyPrefix]
		private static void Prefix(StoreGui __instance)
		{
			HildirChestSaleService.UpdateForStore(__instance);
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch]
	internal static class HildirChestSalePatch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(StoreGui), "SellItem", (Type[])null, (Type[])null);
		}

		[HarmonyPrefix]
		private static void Prefix(StoreGui __instance)
		{
			HildirChestSaleService.UpdateForStore(__instance);
		}

		[HarmonyFinalizer]
		private static void Finalizer()
		{
			HildirChestSaleService.Restore();
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch]
	internal static class HildirChestStoreHidePatch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(StoreGui), "Hide", (Type[])null, (Type[])null);
		}

		[HarmonyPrefix]
		private static void Prefix(StoreGui __instance)
		{
			try
			{
				DailyTraderRuntime.OnStoreHidden(__instance);
			}
			finally
			{
				HildirChestSaleService.Restore();
			}
		}
	}
}
namespace Balrond.Patches.Fletcher
{
	[HarmonyPatch]
	internal static class FletcherTurretPatches
	{
		[HarmonyPatch(typeof(Turret), "Awake")]
		[HarmonyPostfix]
		private static void Awake(Turret __instance)
		{
			FletcherTurretService.Ensure(__instance);
		}

		[HarmonyPatch(typeof(Turret), "FindAmmoItem")]
		[HarmonyPrefix]
		private static void FindAmmo(Turret __instance)
		{
			FletcherTurretService.Ensure(__instance);
		}

		[HarmonyPatch(typeof(Turret), "RPC_AddAmmo")]
		[HarmonyPrefix]
		private static void AddAmmo(Turret __instance)
		{
			FletcherTurretService.Ensure(__instance);
		}
	}
	[HarmonyPatch]
	internal static class FletcherTurretTargetLifecyclePatches
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondMonsterMayhem" })]
		private static void LateSceneReady(ZNetScene __instance)
		{
			Reconcile(__instance, "ZNetScene.Awake");
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondMonsterMayhem" })]
		private static void LateObjectDbReady(ObjectDB __instance)
		{
			if ((Object)(object)__instance != (Object)null && __instance == ObjectDB.instance)
			{
				Reconcile(ZNetScene.instance, "ObjectDB.Awake");
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyAfter(new string[] { "balrond.astafaraios.BalrondMonsterMayhem" })]
		private static void LateObjectDbCopied(ObjectDB __instance)
		{
			if ((Object)(object)__instance != (Object)null && __instance == ObjectDB.instance)
			{
				Reconcile(ZNetScene.instance, "ObjectDB.CopyOtherDB");
			}
		}

		private static void Reconcile(ZNetScene scene, string trigger)
		{
			if ((Object)(object)scene == (Object)null || scene.m_prefabs == null || (Object)(object)ObjectDB.instance == (Object)null)
			{
				return;
			}
			try
			{
				FletcherTurretTargetService.EnsureScene(scene);
			}
			catch (Exception ex)
			{
				ModLog.WarningOnce("fletcher-target-lifecycle:" + trigger, "[Fletcher] Late turret target reconciliation failed at " + trigger + ": " + ex.Message);
			}
		}
	}
	[HarmonyPatch]
	internal static class FletcherUiPatches
	{
		[HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")]
		[HarmonyPrefix]
		private static bool UpdateRecipe(InventoryGui __instance)
		{
			try
			{
				FletcherUiController.Tick(__instance);
				return !FletcherUiController.Active;
			}
			catch (Exception ex)
			{
				FletcherUiController.Reset();
				ModLog.WarningOnce("fletcher-ui", "[Fletcher] UI closed: " + ex);
				return true;
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "Show")]
		[HarmonyPostfix]
		private static void ShowPostfix(InventoryGui __instance)
		{
			try
			{
				FletcherUiController.AfterInventoryShow(__instance);
			}
			catch (Exception ex)
			{
				FletcherUiController.Reset();
				ModLog.WarningOnce("fletcher-ui-show", "[Fletcher] Tab initialization failed: " + ex);
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
		[HarmonyPrefix]
		private static bool DoCrafting()
		{
			return !FletcherUiController.Active;
		}

		[HarmonyPatch(typeof(InventoryGui), "Hide")]
		[HarmonyPrefix]
		private static void Hide()
		{
			FletcherUiController.Close();
		}

		[HarmonyPatch(typeof(InventoryGui), "OnTabCraftPressed")]
		[HarmonyPrefix]
		private static void CraftTab()
		{
			FletcherUiController.Close();
		}

		[HarmonyPatch(typeof(InventoryGui), "OnTabUpgradePressed")]
		[HarmonyPrefix]
		private static void UpgradeTab()
		{
			FletcherUiController.Close();
		}
	}
}
namespace Balrond.Patches.Crafting
{
	[HarmonyPatch(typeof(CraftingStation), "UseItem")]
	internal static class StationInteractionPatches
	{
		private static bool Prefix(CraftingStation __instance, Humanoid user, ItemData item, ref bool __result)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)user != (Object)(object)Player.m_localPlayer || (Object)(object)user == (Object)null || item == null)
			{
				return true;
			}
			string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject);
			if ((prefabName == "piece_workbench" || prefabName == "forge") && ShieldStyleService.TryChange(user, item))
			{
				__result = true;
				return false;
			}
			return prefabName != "piece_workbench" || !BaoFishCutter.TryFillet(user, item, ref __result);
		}
	}
}
namespace Balrond.Patches.Features
{
	[HarmonyPatch]
	internal static class TombstoneRecoveryPatches
	{
		[HarmonyPatch(typeof(TombStone), "EasyFitInInventory")]
		[HarmonyPostfix]
		private static void Fit(TombStone __instance, Player player, ref bool __result)
		{
			if (!__result)
			{
				__result = GraveRecoveryService.CanRecover(__instance, player);
			}
		}

		[HarmonyPatch(typeof(TombStone), "GiveBoost")]
		[HarmonyPostfix]
		private static void Boost(TombStone __instance)
		{
			GraveRecoveryService.OnRecovered(__instance);
		}

		[HarmonyPatch(typeof(TombStone), "OnTakeAllSuccess")]
		[HarmonyPostfix]
		private static void TakeAll(TombStone __instance)
		{
			InterfaceQoLService.CleanupDeathPin(__instance);
		}
	}
	[HarmonyPatch]
	internal static class AreaRepairPatches
	{
		private struct CaptureState
		{
			internal bool Armed;

			internal bool PreviousCapture;

			internal WearNTear PreviousAccepted;

			internal AreaRepairService.RepairState Probe;
		}

		[ThreadStatic]
		private static bool _capture;

		[ThreadStatic]
		private static WearNTear _accepted;

		[HarmonyPatch(typeof(Player), "Repair", new Type[]
		{
			typeof(ItemData),
			typeof(Piece)
		})]
		[HarmonyPrefix]
		private static void Prefix(Player __instance, ItemData toolItem, [HarmonyArgument(1)] Piece target, out CaptureState __state)
		{
			__state = default(CaptureState);
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				AreaRepairService.BeforeRepair(__instance, toolItem, out __state.Probe);
				FrontierRestorationService.BeforeRepair(__instance, target, out __state.Probe.Frontier);
				__state.PreviousCapture = _capture;
				__state.PreviousAccepted = _accepted;
				__state.Armed = true;
				_capture = true;
				_accepted = null;
			}
		}

		[HarmonyPatch(typeof(WearNTear), "Repair")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void CaptureNativeResult(WearNTear __instance, bool __result, bool __runOriginal)
		{
			if (_capture && __runOriginal && __result && (Object)(object)_accepted == (Object)null)
			{
				_accepted = __instance;
			}
		}

		[HarmonyPatch(typeof(Player), "Repair", new Type[]
		{
			typeof(ItemData),
			typeof(Piece)
		})]
		[HarmonyPostfix]
		private static void Postfix(Player __instance, ItemData toolItem, CaptureState __state, bool __runOriginal)
		{
			if (!__state.Armed)
			{
				return;
			}
			WearNTear accepted = _accepted;
			_capture = false;
			_accepted = null;
			if (__runOriginal)
			{
				AreaRepairService.AfterRepair(__instance, toolItem, __state.Probe, accepted);
				if ((Object)(object)accepted == (Object)null)
				{
					FrontierRestorationService.AfterRepair(__instance, toolItem, __state.Probe.Frontier);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Repair", new Type[]
		{
			typeof(ItemData),
			typeof(Piece)
		})]
		[HarmonyFinalizer]
		private static Exception RestoreCapture(Exception __exception, CaptureState __state)
		{
			if (__state.Armed)
			{
				_capture = __state.PreviousCapture;
				_accepted = __state.PreviousAccepted;
			}
			return __exception;
		}
	}
	[HarmonyPatch(typeof(Player), "UpdatePlacement", new Type[]
	{
		typeof(bool),
		typeof(float)
	})]
	[OptionalHarmonyPatch]
	internal static class WearNTearOnlyRepairInputPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Player __instance, [HarmonyArgument(0)] bool takeInput)
		{
			FrontierRestorationService.TryRepairNonPiece(__instance, takeInput);
		}
	}
	[HarmonyPatch]
	[OptionalHarmonyPatch]
	internal static class CompactTooltipPatches
	{
		[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
		{
			typeof(ItemData),
			typeof(int),
			typeof(bool),
			typeof(float),
			typeof(int),
			typeof(bool)
		})]
		[HarmonyPostfix]
		[HarmonyPriority(-100)]
		private unsafe static void ItemData_GetTooltip_FinalCompact(ref string __result)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Invalid comparison between Unknown and I4
			if (!TooltipCompatibility.BaoPresentationEnabled() || !TooltipCompatibility.CanCompactBaseTooltip())
			{
				return;
			}
			BaoTooltipStyle baoTooltipStyle = ResolveStyle();
			if (baoTooltipStyle == BaoTooltipStyle.Detailed || string.IsNullOrEmpty(__result))
			{
				return;
			}
			__result = Compact(__result, (baoTooltipStyle == BaoTooltipStyle.Abstract) ? 5 : 8);
			if (QualityOfLifeConfig.BaoTooltipDetailsHint == null || QualityOfLifeConfig.BaoTooltipDetailsHint.Value)
			{
				KeyCode val = (KeyCode)((QualityOfLifeConfig.BaoTooltipDetailsKey == null) ? 308 : ((int)QualityOfLifeConfig.BaoTooltipDetailsKey.Value));
				if ((int)val != 0)
				{
					__result = (__result ?? string.Empty).TrimEnd(Array.Empty<char>()) + "\n<color=#8F8F8F>Hold " + ((object)(*(KeyCode*)(&val))/*cast due to .constrained prefix*/).ToString() + " for full details</color>";
				}
			}
		}

		private static BaoTooltipStyle ResolveStyle()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			KeyCode val = (KeyCode)((QualityOfLifeConfig.BaoTooltipDetailsKey == null) ? 308 : ((int)QualityOfLifeConfig.BaoTooltipDetailsKey.Value));
			if ((int)val != 0 && Input.GetKey(val))
			{
				return BaoTooltipStyle.Detailed;
			}
			return (QualityOfLifeConfig.BaoTooltipDisplayStyle == null) ? BaoTooltipStyle.Iconic : QualityOfLifeConfig.BaoTooltipDisplayStyle.Value;
		}

		private static string Compact(string source, int maxUsefulLines)
		{
			StringBuilder stringBuilder = new StringBuilder(Mathf.Min(source.Length, 768));
			int num = 0;
			bool flag = false;
			int num2 = 0;
			while (num2 < source.Length && num < maxUsefulLines)
			{
				int i;
				for (i = num2; i < source.Length && source[i] != '\r' && source[i] != '\n'; i++)
				{
				}
				int num3 = i;
				while (num3 > num2 && char.IsWhiteSpace(source[num3 - 1]))
				{
					num3--;
				}
				if (num3 == num2)
				{
					if (!flag && stringBuilder.Length > 0)
					{
						stringBuilder.Append('\n');
						flag = true;
					}
				}
				else
				{
					if (stringBuilder.Length > 0 && !flag)
					{
						stringBuilder.Append('\n');
					}
					stringBuilder.Append(source, num2, num3 - num2);
					num++;
					flag = false;
				}
				if (i < source.Length && source[i] == '\r' && i + 1 < source.Length && source[i + 1] == '\n')
				{
					i++;
				}
				num2 = i + 1;
			}
			return stringBuilder.ToString().TrimEnd(Array.Empty<char>());
		}
	}
	[HarmonyPatch(typeof(Player), "StartGuardianPower")]
	internal static class CurseGuardianStatPatches
	{
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			int num = -1;
			int num2 = 0;
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldstr && object.Equals(list[i].operand, "Missing stat for guardian power: "))
				{
					num = i;
					num2++;
				}
			}
			int num3 = list.Count - 2;
			MethodInfo method = typeof(ForsakenPowerService).GetMethod("HasRegisteredGuardianPower", BindingFlags.Static | BindingFlags.NonPublic);
			if (method != null)
			{
				for (int j = 0; j < list.Count; j++)
				{
					if (CodeInstructionExtensions.Calls(list[j], method))
					{
						return list;
					}
				}
			}
			if (method == null || num2 != 1 || num3 <= num || list[num3].opcode != OpCodes.Ldc_I4_1 || list[num3 + 1].opcode != OpCodes.Ret)
			{
				HarmonyPatchHealthService.MarkRuntimeDegraded("Forsaken.NativeStat", "Player.StartGuardianPower warning block changed; native statistics and warnings retained");
				return list;
			}
			Label label = generator.DefineLabel();
			list[num3].labels.Add(label);
			CodeInstruction val = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
			val.labels.AddRange(list[num].labels);
			list[num].labels.Clear();
			list.InsertRange(num, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3]
			{
				val,
				new CodeInstruction(OpCodes.Call, (object)method),
				new CodeInstruction(OpCodes.Brtrue, (object)label)
			});
			return list;
		}
	}
	[HarmonyPatch(typeof(ShaderReplacment), "RunMaterialFix", new Type[] { typeof(bool) })]
	internal static class CustomExplorationMaterialPatches
	{
		[HarmonyPostfix]
		private static void AfterShaderMaterialFix()
		{
			CustomExplorationPrefabService.RepairRegisteredPrefabMaterials();
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch(typeof(Projectile), "SpawnOnHit")]
	internal static class EchoSpikeProjectilePatch
	{
		[HarmonyPrefix]
		private static void Prefix(Projectile __instance)
		{
			EchoSpikeOwnershipService.Begin(__instance);
		}

		[HarmonyFinalizer]
		private static void Finalizer()
		{
			EchoSpikeOwnershipService.End();
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch(typeof(Aoe), "Awake")]
	internal static class EchoSpikeAoePatch
	{
		[HarmonyPostfix]
		private static void Postfix(Aoe __instance)
		{
			EchoSpikeOwnershipService.AfterAoeAwake(__instance);
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch(typeof(Player), "UpdateDodge")]
	internal static class EitrArcaneStepPatches
	{
		[HarmonyPostfix]
		private static void Postfix(Player __instance)
		{
			EitrTraversalService.TryArcaneStep(__instance);
		}
	}
	[HarmonyPatch]
	internal static class ElementalDamageReworkPatches
	{
		[HarmonyPatch(typeof(Character), "RPC_Damage", new Type[]
		{
			typeof(long),
			typeof(HitData)
		})]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SplitBeforeApplyDamage(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Expected O, but got Unknown
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Expected O, but got Unknown
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Expected O, but got Unknown
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			ElementalDamageReworkService.TranspilerMatched = false;
			MethodInfo methodInfo = AccessTools.Method(typeof(ElementalDamageReworkService), "AdjustInstantHit", (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				return list;
			}
			for (int i = 0; i < list.Count; i++)
			{
				if (CodeInstructionExtensions.Calls(list[i], methodInfo))
				{
					ElementalDamageReworkService.TranspilerMatched = true;
					return list;
				}
			}
			string[] array = new string[5] { "AddFireDamage", "AddSpiritDamage", "AddPoisonDamage", "AddFrostDamage", "AddLightningDamage" };
			int num = -1;
			int[] array2 = new int[5];
			for (int j = 0; j < list.Count; j++)
			{
				MethodInfo methodInfo2 = list[j].operand as MethodInfo;
				if (!(methodInfo2 == null) && !(methodInfo2.DeclaringType != typeof(Character)) && methodInfo2.Name == "ApplyDamage")
				{
					if (num >= 0)
					{
						return list;
					}
					num = j;
				}
			}
			if (num < 0)
			{
				return list;
			}
			int num2 = num;
			for (int k = 0; k < array2.Length; k++)
			{
				array2[k] = -1;
				for (int l = num2 + 1; l < list.Count; l++)
				{
					MethodInfo methodInfo3 = list[l].operand as MethodInfo;
					if (methodInfo3 != null && methodInfo3.DeclaringType == typeof(Character) && methodInfo3.Name == array[k])
					{
						array2[k] = l;
						num2 = l;
						break;
					}
				}
				if (array2[k] < 0)
				{
					return list;
				}
				int num3 = 0;
				for (int m = num + 1; m < list.Count; m++)
				{
					MethodInfo methodInfo4 = list[m].operand as MethodInfo;
					if (methodInfo4 != null && methodInfo4.DeclaringType == typeof(Character) && methodInfo4.Name == array[k])
					{
						num3++;
					}
				}
				if (num3 != 1)
				{
					return list;
				}
			}
			if (!HasExpectedZeroing(list, num))
			{
				return list;
			}
			CodeInstruction val = SavedLocal(list, array2[0]);
			CodeInstruction val2 = SavedLocal(list, array2[1]);
			if (val == null || val2 == null || (val.opcode == val2.opcode && object.Equals(val.operand, val2.operand)))
			{
				return list;
			}
			if (list[num].labels.Count != 0 || list[num].blocks.Count != 0)
			{
				return list;
			}
			list.Insert(num++, new CodeInstruction(OpCodes.Ldarg_2, (object)null));
			list.Insert(num++, new CodeInstruction(val.opcode, val.operand));
			list.Insert(num++, new CodeInstruction(val2.opcode, val2.operand));
			list.Insert(num, new CodeInstruction(OpCodes.Call, (object)methodInfo));
			ElementalDamageReworkService.TranspilerMatched = true;
			return list;
		}

		private static bool HasExpectedZeroing(IList<CodeInstruction> code, int before)
		{
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			for (int i = Math.Max(0, before - 96); i < before; i++)
			{
				FieldInfo fieldInfo = code[i].operand as FieldInfo;
				if (i != 0 && !(code[i].opcode != OpCodes.Stfld) && !(fieldInfo == null) && !(fieldInfo.DeclaringType != typeof(DamageTypes)) && !(code[i - 1].opcode != OpCodes.Ldc_R4) && code[i - 1].operand is float && (float)code[i - 1].operand == 0f)
				{
					if (fieldInfo.Name == "m_poison")
					{
						flag = true;
					}
					if (fieldInfo.Name == "m_fire")
					{
						flag2 = true;
					}
					if (fieldInfo.Name == "m_spirit")
					{
						flag3 = true;
					}
				}
			}
			return flag && flag2 && flag3;
		}

		private static CodeInstruction SavedLocal(IList<CodeInstruction> code, int call)
		{
			if (call < 4 || code[call - 4].opcode != OpCodes.Ldarg_0 || code[call - 2].opcode != OpCodes.Ldarg_2 || code[call - 1].opcode != OpCodes.Ldfld)
			{
				return null;
			}
			FieldInfo fieldInfo = code[call - 1].operand as FieldInfo;
			if (fieldInfo == null || fieldInfo.DeclaringType != typeof(HitData) || fieldInfo.Name != "m_variant")
			{
				return null;
			}
			CodeInstruction val = code[call - 3];
			OpCode opcode = val.opcode;
			return (opcode == OpCodes.Ldloc || opcode == OpCodes.Ldloc_S || opcode == OpCodes.Ldloc_0 || opcode == OpCodes.Ldloc_1 || opcode == OpCodes.Ldloc_2 || opcode == OpCodes.Ldloc_3) ? val : null;
		}

		[HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[]
		{
			typeof(StatusEffect),
			typeof(bool),
			typeof(int),
			typeof(float),
			typeof(short)
		})]
		[HarmonyPrefix]
		private static bool SpiritImmune(SEMan __instance, StatusEffect statusEffect, ref StatusEffect __result)
		{
			if (!ElementalDamageReworkService.BlockImmuneNativeSpirit(__instance, statusEffect))
			{
				return true;
			}
			__result = null;
			return false;
		}

		[HarmonyPatch(typeof(Character), "AddFireDamage", new Type[]
		{
			typeof(float),
			typeof(short)
		})]
		[HarmonyPrefix]
		private static bool Fire(Character __instance, float damage, short variant)
		{
			if (!ElementalDamageReworkService.Active)
			{
				return true;
			}
			ElementalDamageReworkService.AddFire(__instance, damage, variant);
			return false;
		}

		[HarmonyPatch(typeof(Character), "AddSpiritDamage", new Type[]
		{
			typeof(float),
			typeof(short)
		})]
		[HarmonyPrefix]
		private static bool Spirit(Character __instance, float damage, short variant)
		{
			if (!ElementalDamageReworkService.Active)
			{
				return true;
			}
			ElementalDamageReworkService.AddSpirit(__instance, damage, variant);
			return false;
		}

		[HarmonyPatch(typeof(Character), "AddPoisonDamage", new Type[]
		{
			typeof(float),
			typeof(short)
		})]
		[HarmonyPrefix]
		private static bool Poison(Character __instance, float damage, short variant)
		{
			if (!ElementalDamageReworkService.Active)
			{
				return true;
			}
			ElementalDamageReworkService.AddPoison(__instance, damage, variant);
			return false;
		}

		[HarmonyPatch(typeof(Character), "AddFrostDamage", new Type[]
		{
			typeof(float),
			typeof(short)
		})]
		[HarmonyPrefix]
		private static bool Frost(Character __instance, float damage, short variant)
		{
			if (!ElementalDamageReworkService.Active)
			{
				return true;
			}
			ElementalDamageReworkService.AddFrost(__instance, damage, variant);
			return false;
		}

		[HarmonyPatch(typeof(Character), "AddLightningDamage", new Type[]
		{
			typeof(float),
			typeof(short)
		})]
		[HarmonyPrefix]
		private static bool Lightning(Character __instance, float damage, short variant)
		{
			if (!ElementalDamageReworkService.Active)
			{
				return true;
			}
			ElementalDamageReworkService.AddLightning(__instance, damage, variant);
			return false;
		}
	}
	[HarmonyPatch]
	internal static class FarmingUtilityPatches
	{
		[HarmonyPatch(typeof(Game), "Start")]
		private static class Game_Start_WaterNetwork
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				FarmingStructureWaterService.RegisterNetwork();
			}
		}

		[HarmonyPatch(typeof(Plant), "Awake")]
		private static class Plant_Awake_FarmingUtility
		{
			[HarmonyPostfix]
			private static void Postfix(Plant __instance)
			{
				FarmingPlantService.OnPlantAwake(__instance);
			}
		}

		[HarmonyPatch(typeof(Plant), "TimeSincePlanted")]
		private static class Plant_TimeSincePlanted_FarmingUtility
		{
			[HarmonyPostfix]
			private static void Postfix(Plant __instance, ref double __result)
			{
				FarmingPollinationService.ApplyGrowthAdjustmentReadOnly(__instance, ref __result);
			}
		}

		[HarmonyPatch(typeof(Plant), "GetHoverText")]
		private static class Plant_GetHoverText_FarmingUtility
		{
			[HarmonyPostfix]
			private static void Postfix(Plant __instance, ref string __result)
			{
				FarmingPresentationService.AppendPlantHover(__instance, ref __result);
			}
		}

		[HarmonyPatch(typeof(Beehive), "Awake")]
		private static class Beehive_Awake_FarmingUtility
		{
			[HarmonyPostfix]
			private static void Postfix(Beehive __instance)
			{
				FarmingPollinationService.OnBeehiveAwake(__instance);
			}
		}

		[HarmonyPatch(typeof(WearNTear), "Awake")]
		private static class WearNTear_Awake_FarmingUtility
		{
			[HarmonyPostfix]
			private static void Postfix(WearNTear __instance)
			{
				FarmingStructureWaterService.OnWearNTearAwake(__instance);
			}
		}

		[HarmonyPatch(typeof(WearNTear), "IsWet")]
		private static class WearNTear_IsWet_FarmingUtility
		{
			[HarmonyPostfix]
			private static void Postfix(WearNTear __instance, ref bool __result)
			{
				if (!__result && FarmingStructureWaterService.IsTemporarilyWet(__instance))
				{
					__result = true;
				}
			}
		}

		[HarmonyPatch(typeof(Aoe), "OnHit", new Type[]
		{
			typeof(Collider),
			typeof(Vector3)
		})]
		private static class Aoe_OnHit_FarmingUtility
		{
			[HarmonyPrefix]
			private static bool Prefix(Aoe __instance, Collider __0)
			{
				return !FarmingUtilityService.TryHandleWaterSplashHit(__instance, __0);
			}
		}

		[HarmonyPatch(typeof(Projectile), "Setup", new Type[]
		{
			typeof(Character),
			typeof(Vector3),
			typeof(float),
			typeof(HitData),
			typeof(ItemData),
			typeof(ItemData)
		})]
		[HarmonyPostfix]
		private static void WaterProjectileSetup(Projectile __instance)
		{
			FarmingUtilityService.NeutralizeWaterProjectileDamage(__instance);
		}

		[HarmonyPatch(typeof(Projectile), "OnHit", new Type[]
		{
			typeof(Collider),
			typeof(Vector3),
			typeof(bool),
			typeof(Vector3)
		})]
		[HarmonyPrefix]
		private static void WaterProjectileImpact(Projectile __instance, Collider __0, Vector3 __1)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			FarmingUtilityService.WaterProjectileImpact(__instance, __0, __1);
		}

		[HarmonyPatch(typeof(Aoe), "CheckHits")]
		[HarmonyPrefix]
		private static bool WaterSplashArea(Aoe __instance)
		{
			return !FarmingUtilityService.TryHandleWaterSplashArea(__instance);
		}
	}
	[HarmonyPatch]
	internal static class FishingThrowingPatches
	{
		[HarmonyPatch(typeof(Projectile), "OnHit", new Type[]
		{
			typeof(Collider),
			typeof(Vector3),
			typeof(bool),
			typeof(Vector3)
		})]
		private static class Projectile_OnHit
		{
			[HarmonyPrefix]
			private static void Prefix(Projectile __instance, Collider collider, Vector3 hitPoint, ref ThrowingProjectileRuntimeService.HitState __state)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				ThrowingProjectileRuntimeService.BeforeProjectileHit(__instance, collider, hitPoint, ref __state);
			}

			[HarmonyPostfix]
			private static void Postfix(ThrowingProjectileRuntimeService.HitState __state)
			{
				ThrowingProjectileRuntimeService.AfterProjectileHit(__state);
			}

			[HarmonyFinalizer]
			private static Exception Finalizer(Exception __exception, ThrowingProjectileRuntimeService.HitState __state)
			{
				return ThrowingProjectileRuntimeService.FinalizeProjectileHit(__exception, __state);
			}
		}

		[HarmonyPatch(typeof(Humanoid), "Pickup", new Type[]
		{
			typeof(GameObject),
			typeof(bool),
			typeof(bool)
		})]
		private static class Humanoid_Pickup
		{
			[HarmonyPrefix]
			private static void Prefix(GameObject go, ref ThrowingProjectileRuntimeService.PickupState __state)
			{
				ThrowingProjectileRuntimeService.BeforePickup(go, ref __state);
			}

			[HarmonyPostfix]
			private static void Postfix(bool __result, ThrowingProjectileRuntimeService.PickupState __state)
			{
				ThrowingProjectileRuntimeService.AfterPickup(__result, __state);
			}
		}

		[HarmonyPatch(typeof(Skills), "GetSkillDef")]
		[HarmonyPostfix]
		private static void Skills_GetSkillDef(SkillType type, List<SkillDef> ___m_skills, ref SkillDef __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			ThrowingSkillRuntimeService.ResolveSkillDef(type, ___m_skills, ref __result);
		}

		[HarmonyPatch(typeof(Skills), "IsSkillValid")]
		[HarmonyPostfix]
		private static void Skills_IsSkillValid(SkillType type, ref bool __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			ThrowingSkillRuntimeService.EnsureSkillValid(type, ref __result);
		}

		[HarmonyPatch(typeof(Skills), "CheatRaiseSkill")]
		[HarmonyPrefix]
		private static bool Skills_CheatRaiseSkill(Skills __instance, string name, float value, Player ___m_player)
		{
			return ThrowingSkillRuntimeService.CheatRaiseSkill(__instance, name, value, ___m_player);
		}

		[HarmonyPatch(typeof(Skills), "CheatResetSkill")]
		[HarmonyPrefix]
		private static bool Skills_CheatResetSkill(Skills __instance, string name)
		{
			return ThrowingSkillRuntimeService.CheatResetSkill(__instance, name);
		}

		[HarmonyPatch(typeof(Projectile), "Setup", new Type[]
		{
			typeof(Character),
			typeof(Vector3),
			typeof(float),
			typeof(HitData),
			typeof(ItemData),
			typeof(ItemData)
		})]
		[HarmonyPostfix]
		private static void Projectile_Setup(Projectile __instance, Character owner, ItemData item, ItemData ammo)
		{
			ThrowingProjectileRuntimeService.OnProjectileSetup(__instance, owner, item, ammo);
		}

		[HarmonyPatch(typeof(ItemDrop), "DropItem", new Type[]
		{
			typeof(ItemData),
			typeof(int),
			typeof(Vector3),
			typeof(Quaternion)
		})]
		[HarmonyPostfix]
		private static void ItemDrop_DropItem(ItemDrop __result)
		{
			ThrowingProjectileRuntimeService.CaptureNativeDrop(__result);
		}

		[HarmonyPatch(typeof(ItemDrop), "Awake")]
		[HarmonyPostfix]
		private static void ItemDrop_Awake(ItemDrop __instance)
		{
			ThrowingProjectileRuntimeService.RestoreLoadedDrop(__instance);
		}

		[HarmonyPatch(typeof(Fish), "Awake")]
		[HarmonyPostfix]
		private static void Fish_Awake_Experience(Fish __instance)
		{
			FishingFeatureService.OnFishAwake(__instance);
		}

		[HarmonyPatch(typeof(Fish), "OnHooked")]
		[HarmonyPostfix]
		private static void Fish_OnHooked(Fish __instance, FishingFloat ff)
		{
			FishingFeatureService.OnFishHooked(__instance, ff);
		}

		[HarmonyPatch(typeof(Player), "Message")]
		[HarmonyPrefix]
		private static bool Player_Message_FishingThrottle(Player __instance, string msg)
		{
			return !FishingFeatureService.ShouldSuppressMessage(__instance, msg);
		}
	}
	[OptionalHarmonyPatch]
	[HarmonyPatch(typeof(FishingFloat), "FixedUpdate")]
	internal static class BaoFishingFloatTuningPatch
	{
		private struct Snapshot
		{
			internal bool Active;

			internal float Move;

			internal float Pull;
		}

		private static void Prefix(FishingFloat __instance, ref float ___m_moveForce, ref float ___m_pullLineSpeed, out Snapshot __state)
		{
			__state = default(Snapshot);
			if (FeatureGate.Enabled(Balrond.Core.Configuration.RuntimeFeature.FishingThrowing) && FishingThrowingConfig.FishingFloatTuning != null && FishingThrowingConfig.FishingFloatTuning.Value && FishingThrowingConfig.FishingEnhancements != null && FishingThrowingConfig.FishingEnhancements.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)__instance.GetOwner() != (Object)(object)Player.m_localPlayer) && !BalrondModRegistry.IsLoaded(BalrondModId.ExtraSkills) && !RiverheimCompatibilityService.IsPluginLoaded("com.jotunn.AReasonToFish"))
			{
				float value = FishingThrowingConfig.FishingMoveForceMultiplier.Value;
				float value2 = FishingThrowingConfig.FishingPullSpeedMultiplier.Value;
				if (!float.IsNaN(value) && !float.IsInfinity(value) && !float.IsNaN(value2) && !float.IsInfinity(value2))
				{
					__state = new Snapshot
					{
						Active = true,
						Move = ___m_moveForce,
						Pull = ___m_pullLineSpeed
					};
					___m_moveForce *= Mathf.Clamp(value, 0.5f, 3f);
					___m_pullLineSpeed *= Mathf.Clamp(value2, 0.5f, 3f);
				}
			}
		}

		private static Exception Finalizer(Exception __exception, ref float ___m_moveForce, ref float ___m_pullLineSpeed, Snapshot __state)
		{
			if (__state.Active)
			{
				___m_moveForce = __state.Move;
				___m_pullLineSpeed = __state.Pull;
			}
			return __exception;
		}
	}
	[HarmonyPatch]
	internal static class HiddenCurseForsakenPatches
	{
		[HarmonyPatch]
		private static class Player_ConsumeItem_LuckyCharmProtection
		{
			private static MethodBase TargetMethod()
			{
				return AccessTools.Method(typeof(Player), "ConsumeItem", new Type[3]
				{
					typeof(Inventory),
					typeof(ItemData),
					typeof(bool)
				}, (Type[])null);
			}

			[HarmonyPrefix]
			private static bool Prefix(Player __instance, ItemData item, ref bool __result)
			{
				if (ForsakenPowerService.CanConsumeCurseArtifact(__instance, item))
				{
					return true;
				}
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Player), "ActivateGuardianPower")]
		private static class Player_ActivateGuardianPower
		{
			[HarmonyPrefix]
			private static void Prefix(Player __instance)
			{
				if (ForsakenPowerService.CanActivateCurrentCurse(__instance))
				{
					ForsakenPowerService.BeginGuardianActivation(__instance);
				}
			}

			[HarmonyFinalizer]
			private static void Finalizer(Player __instance)
			{
				ForsakenPowerService.EndGuardianActivation(__instance);
			}
		}

		[HarmonyPatch(typeof(SEMan), "AddStatusEffect", new Type[]
		{
			typeof(int),
			typeof(bool),
			typeof(int),
			typeof(float),
			typeof(short)
		})]
		[HarmonyPrefix]
		private static bool SEMan_AddStatusEffect(SEMan __instance, int nameHash)
		{
			return ForsakenPowerService.ShouldAllowCurseGuardianStatus(__instance, nameHash);
		}
	}
	[HarmonyPatch(typeof(SE_Rested), "CalculateComfortLevel", new Type[] { typeof(Player) })]
	internal static class HotSpringComfortPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Player player, ref int __result)
		{
			HotSpringRestService.AddComfort(player, ref __result);
		}
	}
	[HarmonyPatch]
	internal static class InspiredRunestonePatches
	{
		[HarmonyPatch(typeof(RuneStone), "Interact")]
		[HarmonyPostfix]
		private static void RuneStoneInteractPostfix(RuneStone __instance, Humanoid __0, bool __1)
		{
			if (!((Object)(object)__instance == (Object)null || __1))
			{
				Player val = (Player)(object)((__0 is Player) ? __0 : null);
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val != (Object)(object)Player.m_localPlayer))
				{
					InspiredRunestoneService.TryReward(__instance, val);
				}
			}
		}

		[HarmonyPatch(typeof(RuneStone), "GetHoverText")]
		[HarmonyPostfix]
		private static void RuneStoneGetHoverTextPostfix(RuneStone __instance, ref string __result)
		{
			InspiredRunestoneService.AppendHoverState(__instance, ref __result);
		}
	}
	[HarmonyPatch]
	internal static class InterfaceQoLPatches
	{
		[HarmonyPatch(typeof(Player), "AddKnownRecipe")]
		private static class Player_AddKnownRecipe
		{
			[HarmonyPrefix]
			private static void Prefix(Player __instance, Recipe recipe, HashSet<string> ___m_knownRecipes, out bool __state)
			{
				InterfaceQoLService.BeforeKnownRecipe(__instance, recipe, ___m_knownRecipes, out __state);
			}

			[HarmonyPostfix]
			private static void Postfix(Player __instance, Recipe recipe, bool __state)
			{
				InterfaceQoLService.AfterKnownRecipe(__instance, recipe, __state);
			}
		}

		[HarmonyPatch(typeof(Player), "AddKnownPiece")]
		private static class Player_AddKnownPiece
		{
			[HarmonyPrefix]
			private static void Prefix(Player __instance, Piece piece, HashSet<string> ___m_knownRecipes, out bool __state)
			{
				InterfaceQoLService.BeforeKnownPiece(__instance, piece, ___m_knownRecipes, out __state);
			}

			[HarmonyPostfix]
			private static void Postfix(Player __instance, Piece piece, bool __state)
			{
				InterfaceQoLService.AfterKnownPiece(__instance, piece, __state);
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "UpdateRecipeList", new Type[] { typeof(List<Recipe>) })]
		private static class InventoryGui_UpdateRecipeList
		{
			[HarmonyPriority(800)]
			private static bool Prefix(InventoryGui __instance, List<Recipe> recipes, out bool __state)
			{
				__state = InterfacePerformanceCache.ShouldRunVanillaRecipeRebuild(__instance, recipes);
				return __state;
			}

			[HarmonyPriority(0)]
			private static void Postfix(InventoryGui __instance, bool __state, bool __runOriginal)
			{
				if (__state && !__runOriginal)
				{
					InterfacePerformanceCache.InvalidateRecipeSignature();
				}
				InterfaceQoLService.MarkNewRecipes(__instance);
			}

			[HarmonyFinalizer]
			private static Exception Finalizer(Exception __exception)
			{
				if (__exception != null)
				{
					InterfacePerformanceCache.InvalidateRecipeSignature();
				}
				return __exception;
			}
		}

		[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
		{
			typeof(ItemData),
			typeof(int),
			typeof(bool),
			typeof(float),
			typeof(int),
			typeof(bool)
		})]
		[HarmonyPriority(0)]
		[HarmonyPostfix]
		private static void ItemData_GetTooltip_CompactCompare(ItemData item, ref string __result)
		{
			if (TooltipCompatibility.BaoPresentationEnabled())
			{
				CompactEquipmentCompareService.Append(item, ref __result);
			}
		}

		[HarmonyPatch(typeof(Player), "OnInventoryChanged")]
		[HarmonyPrefix]
		private static void Player_OnInventoryChanged_InvalidateSignature(Player __instance)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				InterfacePerformanceCache.InvalidateInventorySignature();
			}
		}

		[HarmonyPatch(typeof(Player), "OnInventoryChanged")]
		[HarmonyPostfix]
		private static void Player_OnInventoryChanged_Caches(Player __instance)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				AccessoryItemService.ReconcileLocalPlayerInventory(__instance);
				InterfacePerformanceCache.InvalidateComparisonCache();
				ItemQualityIconPresenter.Invalidate();
				GraveRecoveryService.Refresh(__instance);
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdatePieceList")]
		[HarmonyPriority(0)]
		[HarmonyPostfix]
		private static void Hud_UpdatePieceList(Hud __instance, Player player)
		{
			InterfaceQoLService.MarkNewPieces(__instance, player);
		}
	}
	[HarmonyPatch]
	[OptionalHarmonyPatch]
	internal static class InventoryDisplayQualityPatch
	{
		[HarmonyTargetMethod]
		private static MethodBase TargetMethod()
		{
			MethodInfo[] methods = typeof(InventoryGrid).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (!(methodInfo == null) && !(methodInfo.Name != "UpdateInventory"))
				{
					ParameterInfo[] parameters = methodInfo.GetParameters();
					if (parameters.Length != 0 && parameters[0].ParameterType == typeof(Inventory))
					{
						return methodInfo;
					}
				}
			}
			return null;
		}

		[HarmonyPostfix]
		private static void Postfix(InventoryGrid __instance, Inventory __0)
		{
			ItemQualityIconPresenter.ApplyInventory(__instance, __0);
		}
	}
	[HarmonyPatch]
	[OptionalHarmonyPatch]
	internal static class HotkeyDisplayQualityPatch
	{
		[HarmonyTargetMethod]
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("HotkeyBar");
			if (type == null)
			{
				return null;
			}
			MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo != null && methodInfo.Name == "UpdateIcons")
				{
					return methodInfo;
				}
			}
			return null;
		}

		[HarmonyPostfix]
		private static void Postfix(object __instance)
		{
			ItemQualityIconPresenter.ApplyHotkey(__instance);
		}
	}
	internal static class ItemQualityIconPresenter
	{
		private sealed class QualityLabelCache
		{
			internal TMP_Text Label;
		}

		private sealed class GridDecorationCache
		{
			internal Inventory Inventory;

			internal int Signature = int.MinValue;

			internal int ChildCount = -1;

			internal int Generation = -1;

			internal float NextSafetyCheck;
		}

		private static readonly Dictionary<Type, Dictionary<string, MemberInfo>> MemberCache = new Dictionary<Type, Dictionary<string, MemberInfo>>();

		private static ConditionalWeakTable<InventoryGrid, GridDecorationCache> GridCaches = new ConditionalWeakTable<InventoryGrid, GridDecorationCache>();

		private static WeakReference _lastHotkeyOwner;

		private static ConditionalWeakTable<Transform, QualityLabelCache> QualityLabels = new ConditionalWeakTable<Transform, QualityLabelCache>();

		private static int _lastHotkeySignature = int.MinValue;

		private static int _lastHotkeyGeneration = -1;

		private static float _nextHotkeySafetyCheck;

		private static int _displayGeneration;

		private const float SafetyReconcileSeconds = 1f;

		private static readonly string[] CommonQualityText = new string[10] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

		private static bool IsLastHotkeyOwner(object candidate)
		{
			return _lastHotkeyOwner != null && _lastHotkeyOwner.Target == candidate;
		}

		internal static void ApplyInventory(InventoryGrid grid, Inventory inventory)
		{
			if ((Object)(object)grid == (Object)null || inventory == null || (Object)(object)grid.m_gridRoot == (Object)null)
			{
				return;
			}
			try
			{
				int width = inventory.GetWidth();
				if (width <= 0)
				{
					return;
				}
				GridDecorationCache orCreateValue = GridCaches.GetOrCreateValue(grid);
				int childCount = ((Transform)grid.m_gridRoot).childCount;
				float unscaledTime = Time.unscaledTime;
				if (orCreateValue.Inventory == inventory && orCreateValue.Generation == _displayGeneration && orCreateValue.ChildCount == childCount && unscaledTime < orCreateValue.NextSafetyCheck)
				{
					return;
				}
				List<ItemData> allItems = inventory.GetAllItems();
				int num = ComputeInventoryDecorationSignature(allItems);
				if (orCreateValue.Inventory == inventory && orCreateValue.Signature == num && orCreateValue.ChildCount == childCount && orCreateValue.Generation == _displayGeneration)
				{
					orCreateValue.Generation = _displayGeneration;
					orCreateValue.NextSafetyCheck = unscaledTime + 1f;
					return;
				}
				for (int i = 0; i < allItems.Count; i++)
				{
					ItemData val = allItems[i];
					if (val != null)
					{
						int num2 = val.m_gridPos.y * width + val.m_gridPos.x;
						if (num2 >= 0 && num2 < childCount)
						{
							Transform child = ((Transform)grid.m_gridRoot).GetChild(num2);
							TMP_Text quality = FindQualityText(child);
							Apply(quality, val);
						}
					}
				}
				orCreateValue.Inventory = inventory;
				orCreateValue.Signature = num;
				orCreateValue.ChildCount = childCount;
				orCreateValue.Generation = _displayGeneration;
				orCreateValue.NextSafetyCheck = unscaledTime + 1f;
			}
			catch
			{
			}
		}

		private static int ComputeInventoryDecorationSignature(List<ItemData> items)
		{
			int num = 17;
			num = num * 31 + items.Count;
			for (int i = 0; i < items.Count; i++)
			{
				ItemData val = items[i];
				if (val == null)
				{
					num *= 31;
					continue;
				}
				num = num * 31 + ((object)val).GetHashCode();
				num = num * 31 + val.m_gridPos.x;
				num = num * 31 + val.m_gridPos.y;
				num = num * 31 + val.m_stack;
				num = num * 31 + val.m_quality;
				num = num * 31 + ItemDisplayQuality.Get(val);
			}
			return num;
		}

		internal static void ApplyHotkey(object hotkeyBar)
		{
			if (hotkeyBar == null)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			if (IsLastHotkeyOwner(hotkeyBar) && _lastHotkeyGeneration == _displayGeneration && unscaledTime < _nextHotkeySafetyCheck)
			{
				return;
			}
			try
			{
				IList list = ReadList(hotkeyBar, "m_items", "m_hotkeyItems");
				IList list2 = ReadList(hotkeyBar, "m_elements", "m_hotkeyElements");
				if (list == null || list2 == null)
				{
					return;
				}
				int num = Math.Min(list.Count, list2.Count);
				int num2 = ComputeHotkeySignature(list, num);
				if (IsLastHotkeyOwner(hotkeyBar) && _lastHotkeySignature == num2 && _lastHotkeyGeneration == _displayGeneration)
				{
					_lastHotkeyGeneration = _displayGeneration;
					_nextHotkeySafetyCheck = unscaledTime + 1f;
					return;
				}
				for (int i = 0; i < list2.Count; i++)
				{
					object obj = list2[i];
					Transform val = ResolveElementTransform(obj);
					ItemData val2 = ((i < num) ? ResolveItem(list[i]) : null);
					if (val2 == null)
					{
						DisableHotbarLevelLabel(val);
						continue;
					}
					TMP_Text val3 = FindQualityText(obj);
					if ((Object)(object)val3 == (Object)null && (Object)(object)val != (Object)null)
					{
						val3 = FindQualityText(val);
					}
					if ((Object)(object)val3 != (Object)null)
					{
						Apply(val3, val2);
						DisableHotbarLevelLabel(val);
					}
					else if ((Object)(object)val != (Object)null)
					{
						ApplyHotbarLevelLabel(val, val2);
					}
				}
				if (!IsLastHotkeyOwner(hotkeyBar))
				{
					_lastHotkeyOwner = new WeakReference(hotkeyBar);
				}
				_lastHotkeySignature = num2;
				_lastHotkeyGeneration = _displayGeneration;
				_nextHotkeySafetyCheck = unscaledTime + 1f;
			}
			catch
			{
			}
		}

		internal static void Invalidate()
		{
			_displayGeneration++;
			if (_displayGeneration == int.MinValue)
			{
				_displayGeneration = 0;
			}
		}

		internal static void Reset()
		{
			ItemDisplayQuality.ResetPrefabNameCache();
			MemberCache.Clear();
			GridCaches = new ConditionalWeakTable<InventoryGrid, GridDecorationCache>();
			QualityLabels = new ConditionalWeakTable<Transform, QualityLabelCache>();
			_lastHotkeyOwner = null;
			_lastHotkeySignature = int.MinValue;
			_lastHotkeyGeneration = -1;
			_nextHotkeySafetyCheck = 0f;
			_displayGeneration = 0;
		}

		private static Transform ResolveElementTransform(object element)
		{
			Component val = (Component)((element is Component) ? element : null);
			if ((Object)(object)val != (Object)null)
			{
				return val.transform;
			}
			GameObject val2 = (GameObject)((element is GameObject) ? element : null);
			if ((Object)(object)val2 != (Object)null)
			{
				return val2.transform;
			}
			object obj = ReadMember(element, "m_go") ?? ReadMember(element, "gameObject");
			GameObject val3 = (GameObject)((obj is GameObject) ? obj : null);
			if ((Object)(object)val3 != (Object)null)
			{
				return val3.transform;
			}
			Component val4 = (Component)((obj is Component) ? obj : null);
			return ((Object)(object)val4 != (Object)null) ? val4.transform : null;
		}

		private static void DisableHotbarLevelLabel(Transform slot)
		{
			if (!((Object)(object)slot == (Object)null))
			{
				Transform val = slot.Find("bao_hotbar_level");
				if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeSelf)
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
		}

		private static void ApplyHotbarLevelLabel(Transform slot, ItemData item)
		{
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Invalid comparison between Unknown and I4
			//IL_01fe: 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_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: 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_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)slot == (Object)null || item == null)
			{
				return;
			}
			int num = ItemDisplayQuality.Get(item);
			Transform val = slot.Find("bao_hotbar_level");
			TMP_Text val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<TMP_Text>() : null);
			if (num <= 0)
			{
				if ((Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeSelf)
				{
					((Component)val2).gameObject.SetActive(false);
				}
				return;
			}
			if ((Object)(object)val2 == (Object)null)
			{
				TMP_Text val3 = FindQualityText(slot);
				if ((Object)(object)val3 == (Object)null)
				{
					Transform val4 = Utils.FindChild(slot, "binding", (IterativeSearchType)0);
					if ((Object)(object)val4 != (Object)null)
					{
						val3 = ((Component)val4).GetComponent<TMP_Text>();
					}
				}
				if ((Object)(object)val3 == (Object)null)
				{
					Transform val5 = Utils.FindChild(slot, "amount", (IterativeSearchType)0);
					if ((Object)(object)val5 != (Object)null)
					{
						val3 = ((Component)val5).GetComponent<TMP_Text>();
					}
				}
				if ((Object)(object)val3 == (Object)null)
				{
					return;
				}
				val2 = Object.Instantiate<TMP_Text>(val3, slot);
				((Object)val2).name = "bao_hotbar_level";
				((Graphic)val2).raycastTarget = false;
			}
			if (!((Component)val2).gameObject.activeSelf)
			{
				((Component)val2).gameObject.SetActive(true);
			}
			if (!((Behaviour)val2).enabled)
			{
				((Behaviour)val2).enabled = true;
			}
			string text = QualityText(num);
			if (!string.Equals(val2.text, text, StringComparison.Ordinal))
			{
				val2.text = text;
			}
			if ((int)val2.alignment != 260)
			{
				val2.alignment = (TextAlignmentOptions)260;
			}
			if (val2.fontSize < 9f)
			{
				val2.fontSize = 9f;
			}
			RectTransform rectTransform = val2.rectTransform;
			if ((Object)(object)rectTransform != (Object)null)
			{
				Vector2 val6 = default(Vector2);
				((Vector2)(ref val6))..ctor(1f, 1f);
				if (rectTransform.anchorMin != val6)
				{
					rectTransform.anchorMin = val6;
				}
				if (rectTransform.anchorMax != val6)
				{
					rectTransform.anchorMax = val6;
				}
				if (rectTransform.pivot != val6)
				{
					rectTransform.pivot = val6;
				}
				Vector2 val7 = default(Vector2);
				((Vector2)(ref val7))..ctor(-3f, -2f);
				if (rectTransform.anchoredPosition != val7)
				{
					rectTransform.anchoredPosition = val7;
				}
				Vector2 val8 = default(Vector2);
				((Vector2)(ref val8))..ctor(24f, 18f);
				if (rectTransform.sizeDelta != val8)
				{
					rectTransform.sizeDelta = val8;
				}
			}
		}

		private static int ComputeHotkeySignature(IList items, int count)
		{
			int num = 17;
			num = num * 31 + count;
			for (int i = 0; i < count; i++)
			{
				ItemData val = ResolveItem(items[i]);
				if (val == null)
				{
					num *= 31;
					continue;
				}
				num = num * 31 + ((object)val).GetHashCode();
				num = num * 31 + val.m_stack;
				num = num * 31 + val.m_quality;
				num = num * 31 + ItemDisplayQuality.Get(val);
			}
			return num;
		}

		private static string QualityText(int quality)
		{
			return (quality >= 0 && quality < CommonQualityText.Length) ? CommonQualityText[quality] : quality.ToString();
		}

		private static void Apply(TMP_Text quality, ItemData item)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00d9: 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_00f5: 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)
			if ((Object)(object)quality == (Object)null || item == null)
			{
				return;
			}
			bool perfect;
			int num = ItemDisplayQuality.Get(item, out perfect);
			if (num <= 0)
			{
				return;
			}
			if (!((Behaviour)quality).enabled)
			{
				((Behaviour)quality).enabled = true;
			}
			string text = (perfect ? "★" : QualityText(num));
			if (!string.Equals(quality.text, text, StringComparison.Ordinal))
			{
				quality.text = text;
			}
			if ((int)quality.alignment != 260)
			{
				quality.alignment = (TextAlignmentOptions)260;
			}
			RectTransform rectTransform = quality.rectTransform;
			if ((Object)(object)rectTransform != (Object)null)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(1f, 1f);
				if (rectTransform.anchorMin != val)
				{
					rectTransform.anchorMin = val;
				}
				if (rectTransform.anchorMax != val)
				{
					rectTransform.anchorMax = val;
				}
				if (rectTransform.pivot != val)
				{
					rectTransform.pivot = val;
				}
			}
		}

		private static ItemData ResolveItem(object value)
		{
			ItemData val = (ItemData)((value is ItemData) ? value : null);
			if (val != null)
			{
				return val;
			}
			object obj = ReadMember(value, "m_item") ?? ReadMember(value, "m_itemData") ?? ReadMember(value, "item");
			return (ItemData)((obj is ItemData) ? obj : null);
		}

		private static TMP_Text FindQualityText(object source)
		{
			if (source == null)
			{
				return null;
			}
			object obj = ReadMember(source, "m_quality");
			TMP_Text val = (TMP_Text)((obj is TMP_Text) ? obj : null);
			if ((Object)(object)val == (Object)null)
			{
				object obj2 = ReadMember(source, "quality");
				val = (TMP_Text)((obj2 is TMP_Text) ? obj2 : null);
			}
			if ((Object)(object)val == (Object)null)
			{
				object obj3 = ReadMember(source, "m_qualityText");
				val = (TMP_Text)((obj3 is TMP_Text) ? obj3 : null);
			}
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Component val2 = (Component)((source is Component) ? source : null);
			GameObject val3 = (GameObject)((source is GameObject) ? source : null);
			if ((Object)(object)val2 != (Object)null)
			{
				val3 = val2.gameObject;
			}
			if ((Object)(object)val3 == (Object)null)
			{
				object obj4 = ReadMember(source, "m_go") ?? ReadMember(source, "gameObject");
				val3 = (GameObject)((obj4 is GameObject) ? obj4 : null);
				Component val4 = (Component)((obj4 is Component) ? obj4 : null);
				if ((Object)(object)val3 == (Object)null && (Object)(object)val4 != (Object)null)
				{
					val3 = val4.gameObject;
				}
			}
			if ((Object)(object)val3 == (Object)null)
			{
				return null;
			}
			return FindQualityText(val3.transform);
		}

		private static TMP_Text FindQualityText(Transform root)
		{
			if ((Object)(object)root == (Object)null)
			{
				return null;
			}
			if (QualityLabels.TryGetValue(root, out var value) && (Object)(object)value.Label != (Object)null && value.Label.transform.IsChildOf(root))
			{
				return value.Label;
			}
			Transform val = Utils.FindChild(root, "quality", (IterativeSearchType)0);
			TMP_Text val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<TMP_Text>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				if (value == null)
				{
					value = QualityLabels.GetOrCreateValue(root);
				}
				value.Label = val2;
			}
			return val2;
		}

		private static IList ReadList(object target, string primaryName, string fallbackName)
		{
			IList list = ReadMember(target, primaryName) as IList;
			return list ?? (ReadMember(target, fallbackName) as IList);
		}

		private static object ReadMember(object target, string name)
		{
			if (target == null || string.IsNullOrEmpty(name))
			{
				return null;
			}
			Type type = target.GetType();
			if (!MemberCache.TryGetValue(type, out var value))
			{
				value = new Dictionary<string, MemberInfo>(StringComparer.Ordinal);
				MemberCache.Add(type, value);
			}
			if (!value.TryGetValue(name, out var value2))
			{
				value2 = (value[name] = FindMember(type, name));
			}
			FieldInfo fieldInfo = value2 as FieldInfo;
			if (fieldInfo != null)
			{
				return fieldInfo.GetValue(target);
			}
			PropertyInfo propertyInfo = value2 as PropertyInfo;
			return (propertyInfo != null) ? propertyInfo.GetValue(target, null) : null;
		}

		private static MemberInfo FindMember(Type type, string name)
		{
			while (type != null)
			{
				FieldInfo field = type.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return field;
				}
				PropertyInfo property = type.GetProperty(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property != null && property.CanRead && property.GetIndexParameters().Length == 0)
				{
					return property;
				}
				type = type.BaseType;
			}
			return null;
		}
	}
	[HarmonyPatch]
	[OptionalHarmonyPatch]
	internal static class ItemStandCompatibilityPatches
	{
		private static readonly HashSet<string> DisplayableMaterialIds = new HashSet<string>(StringComparer.Ordinal)
		{
			"AcidSludge_bal", "Amethyst_bal", "AncientSeed", "Bearberry_bal", "BeeWax_bal", "Bilebag", "BlackCore", "BlackTissue_bal", "Blackberries_bal", "Bloodbag",
			"Bloodfruit_bal", "Blueberries", "BoneFragments", "Carapace", "Carrot", "Cattail_bal", "CelestialFeather", "CharcoalResin", "Chitin", "Cloudberry",
			"Coal", "CorruptedEitr_bal", "CrownJewel", "Crystal", "CuredSquirrelHamstring", "CursedBone_bal", "Dandelion", "Darkbul_bal", "Diamond_bal", "DragonTear",
			"Ectoplasm", "Eitr", "Eldmetal_bal", "ElementalExtract_bal", "Emerald_bal", "EnrichedEitr_bal", "Entrails", "EverFrostCrystal_bal", "FaderDrop", "Feathers",
			"Fiddlehead", "FirConeFrost", "FireGland_bal", "FragrantBundle", "FreezeGland", "FreshSeaweed", "FrozenFuel", "Garlic_bal", "GemChunks_bal", "GemstoneBlue",
			"GemstoneGreen", "GemstoneRed", "GiantBloodSack", "GrayMushroom_bal", "GreydwarfEye", "Guck", "HatefulBlood", "Honey", "Ice", "Iceberry_bal",
			"Ignicap_bal", "Lavender_bal", "Lingonberry", "MagmaStone_bal", "Mandible", "MeadBase_Draught_bal", "MeadBase_Flask_bal", "MeadBase_Major_bal", "MeadBase_Medium_bal", "MeadBase_Minor_bal",
			"MeadBase_Tonic_bal", "Mint_bal", "MoleClaws", "MoltenCore", "MooseSinew", "Moss_bal", "Mugwort_bal", "Mushroom", "MushroomBlue", "MushroomBzerker",
			"MushroomIcecap_bal", "MushroomInkcap_bal", "MushroomJotunPuffs", "MushroomMagecap", "MushroomSmokePuff", "MushroomYellow", "Mycelium_bal", "Nettle_bal", "NornThread", "Obsidian",
			"Oil_bal", "Onion", "Onyx_bal", "Ooze", "Opal_bal", "OrbThunderBlood", "PepperCorn_bal", "PowderedDragonEgg", "ProustitePowder", "PungentPebbles",
			"QueenDrop", "Raspberry", "RedKelp_bal", "Resin", "Root", "RoyalJelly", "Ruby", "Sage_bal", "SaltCrystal_bal", "Sap",
			"Sapphire_bal", "SealBlubber", "SerpentScale", "SmallBloodSack_bal", "Snowleaf_bal", "Softtissue", "SoulCore_bal", "SpiritDust_bal", "SulfurStone", "SurtSpark_bal",
			"SurtlingCore", "Tar", "Thistle", "ThunderGland_bal", "Thunderstone", "TrophyBoar", "TrophyBonemass", "TrophyCharredMage", "TrophyCultist", "TrophyDeathsquito",
			"TrophyDeer", "TrophyDragonQueen", "TrophyEikthyr", "TrophyFader", "TrophyFallenValkyrie", "TrophyFenring", "TrophyFrostTroll", "TrophyGoblinBrute", "TrophyGoblinKing", "TrophyGoblinShaman",
			"TrophySGolem", "TrophySeekerBrute", "TrophySeekerQueen", "TrophySerpent", "TrophyTheElder", "TrophyWolf", "TrophyWraith", "Turnip", "Vineberry", "VitalBinder_bal",
			"WaterLily_bal", "WillowBark_bal", "Wisp", "WispCore_bal", "WispCorrupted_bal", "WolfFang", "WrithanRoots", "YagluthDrop", "Yarrow_bal", "YewBark_bal",
			"YmirRemains"
		};

		private static IEnumerable<MethodBase> TargetMethods()
		{
			foreach (MethodInfo method in AccessTools.GetDeclaredMethods(typeof(ItemStand)))
			{
				if (method.Name != "CanAttach" || method.ReturnType != typeof(bool))
				{
					continue;
				}
				ParameterInfo[] parameters = method.GetParameters();
				foreach (ParameterInfo parameter in parameters)
				{
					if (!(parameter.ParameterType != typeof(ItemData)))
					{
						yield return method;
						break;
					}
				}
			}
		}

		[HarmonyPostfix]
		private static void AllowDisplayableItems(ItemStand __instance, object[] __args, ref bool __result)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Invalid comparison between Unknown and I4
			if (__result || (Object)(object)__instance == (Object)null || __args == null)
			{
				return;
			}
			string text = ((Object)((Component)__instance).gameObject).name;
			if (text.EndsWith("(Clone)", StringComparison.Ordinal))
			{
				text = text.Substring(0, text.Length - "(Clone)".Length);
			}
			if (text != "itemstand" && text != "itemstandh")
			{
				return;
			}
			ItemData val = null;
			foreach (object obj in __args)
			{
				val = (ItemData)((obj is ItemData) ? obj : null);
				if (val != null)
				{
					break;
				}
			}
			if (val != null && val.m_shared != null && !((Object)(object)val.m_dropPrefab == (Object)null))
			{
				bool flag = (int)val.m_shared.m_itemType == 13;
				string name = ((Object)val.m_dropPrefab).name;
				bool flag2 = DisplayableMaterialIds.Contains(name) || AlchemyGeneratedPrefabCatalog.IsGenerated(name);
				if ((flag || flag2) && HasAttachTransform(val.m_dropPrefab.transform))
				{
					__result = true;
				}
			}
		}

		private static bool HasAttachTransform(Transform root)
		{
			if ((Object)(object)root == (Object)null)
			{
				return false;
			}
			if (string.Equals(((Object)root).name, "attach", StringComparison.Ordinal))
			{
				return true;
			}
			for (int i = 0; i < root.childCount; i++)
			{
				if (HasAttachTransform(root.GetChild(i)))
				{
					return true;
				}
			}
			return false;
		}
	}
	[HarmonyPatch]
	internal static class LogoutStatusPersistencePatches
	{
		[HarmonyPatch(typeof(Player), "Save", new Type[] { typeof(ZPackage) })]
		[HarmonyPrefix]
		private static void Player_Save(Player __instance)
		{
			CraftingOverflowDeliveryService.BeforePlayerSave(__instance);
			LogoutStatusPersistenceService.BeforePlayerSave(__instance);
			AlchemyConsumableCooldownService.BeforePlayerSave(__instance);
		}

		[HarmonyPatch(typeof(Player), "OnSpawned", new Type[] { typeof(bool) })]
		[HarmonyPostfix]
		private static void Player_OnSpawned(Player __instance)
		{
			CraftingOverflowDeliveryService.AfterPlayerSpawned(__instance);
			LogoutStatusPersistenceService.AfterPlayerSpawned(__instance);
			AlchemyConsumableCooldownService.AfterPlayerSpawned(__instance);
		}
	}
	[HarmonyPatch]
	internal static class MapPinPatches
	{
		[HarmonyPatch]
		private static class VehicleLifecycle
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				MethodInfo method = AccessTools.DeclaredMethod(typeof(Ship), "OnEnable", Type.EmptyTypes, (Type[])null);
				if (method != null)
				{
					yield return method;
				}
				method = AccessTools.DeclaredMethod(typeof(Ship), "Awake", (Type[])null, (Type[])null);
				if (method != null)
				{
					yield return method;
				}
				method = AccessTools.DeclaredMethod(typeof(Vagon), "Awake", (Type[])null, (Type[])null);
				if (method != null)
				{
					yield return method;
				}
			}

			[HarmonyPostfix]
			private static void Postfix(object __instance)
			{
				Ship val = (Ship)((__instance is Ship) ? __instance : null);
				if ((Object)(object)val != (Object)null)
				{
					MapPinService.RegisterShip(val);
					return;
				}
				Vagon val2 = (Vagon)((__instance is Vagon) ? __instance : null);
				if ((Object)(object)val2 != (Object)null)
				{
					MapPinService.RegisterCart(val2);
				}
			}
		}

		[HarmonyPatch]
		private static class VehicleDestruction
		{
			private static bool Prepare()
			{
				return AccessTools.DeclaredMethod(typeof(Ship), "OnDisable", Type.EmptyTypes, (Type[])null) != null || AccessTools.DeclaredMethod(typeof(Vagon), "OnDestroy", Type.EmptyTypes, (Type[])null) != null;
			}

			private static IEnumerable<MethodBase> TargetMethods()
			{
				MethodInfo method = AccessTools.DeclaredMethod(typeof(Ship), "OnDisable", Type.EmptyTypes, (Type[])null);
				if (method != null)
				{
					yield return method;
				}
				method = AccessTools.DeclaredMethod(typeof(Vagon), "OnDestroy", Type.EmptyTypes, (Type[])null);
				if (method != null)
				{
					yield return method;
				}
			}

			[HarmonyPrefix]
			private static void Prefix(object __instance)
			{
				Ship val = (Ship)((__instance is Ship) ? __instance : null);
				if (val != null)
				{
					MapPinService.UnregisterShip(val);
					return;
				}
				Vagon val2 = (Vagon)((__instance is Vagon) ? __instance : null);
				if (val2 != null)
				{
					MapPinService.UnregisterCart(val2);
				}
			}
		}

		[HarmonyPatch(typeof(Minimap), "Start")]
		[HarmonyPostfix]
		private static void Minimap_Start(Minimap __instance)
		{
			MapPinService.OnMinimapStart(__instance);
		}

		[HarmonyPatch(typeof(Minimap), "UpdatePins")]
		[HarmonyPrefix]
		private static void Minimap_UpdatePinsPrefix(Minimap __instance)
		{
			MapPinService.PrepareSearchBeforePins(__instance);
		}

		[HarmonyPatch(typeof(Minimap), "UpdatePins")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Minimap_UpdatePinsFilter(IEnumerable<CodeInstruction> instructions)
		{
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Expected O, but got Unknown
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			FieldInfo fieldInfo = AccessTools.Field(typeof(PinData), "m_pos");
			MethodInfo methodInfo = AccessTools.Method(typeof(MapPinService), "FilterNativeVisibility", (Type[])null, (Type[])null);
			int num = -1;
			int num2 = 0;
			for (int i = 4; i + 1 < list.Count; i++)
			{
				if (list[i].operand is MethodInfo methodInfo2 && !(methodInfo2.DeclaringType != typeof(Minimap)) && !(methodInfo2.Name != "IsPointVisible") && !(methodInfo2.ReturnType != typeof(bool)) && methodInfo2.GetParameters().Length == 2)
				{
					num2++;
					if ((!(list[i].opcode != OpCodes.Call) || !(list[i].opcode != OpCodes.Callvirt)) && !(list[i - 4].opcode != OpCodes.Ldarg_0) && !(list[i - 3].opcode != OpCodes.Ldloc_S) && !(list[i - 2].opcode != OpCodes.Ldfld) && object.Equals(list[i - 2].operand, fieldInfo) && !(list[i - 1].opcode != OpCodes.Ldloc_0) && (!(list[i + 1].opcode != OpCodes.Brfalse) || !(list[i + 1].opcode != OpCodes.Brfalse_S)) && list[i].blocks.Count == 0)
					{
						num = i;
					}
				}
			}
			bool flag = num2 == 1 && num >= 0 && fieldInfo != null && methodInfo != null;
			MapPinService.SetNativeSearchFilter(flag);
			if (!flag)
			{
				ModLog.WarningOnce("bao-map-native-filter-shape", "Map pin search native filter shape changed; using presentation fallback.");
				return list;
			}
			list.Insert(num + 1, new CodeInstruction(list[num - 3].opcode, list[num - 3].operand));
			list.Insert(num + 2, new CodeInstruction(OpCodes.Call, (object)methodInfo));
			return list;
		}

		[HarmonyPatch(typeof(Minimap), "UpdatePins")]
		[HarmonyPostfix]
		private static void Minimap_UpdatePins(Minimap __instance)
		{
			MapPinService.ApplySearchAfterPins(__instance);
		}

		[HarmonyPatch(typeof(Minimap), "SelectIcon")]
		[HarmonyPostfix]
		private static void Minimap_SelectIcon()
		{
			MapPinService.OnVanillaIconSelected();
		}

		[HarmonyPatch(typeof(Minimap), "InTextInput")]
		[HarmonyPostfix]
		private static void Minimap_InTextInput(ref bool __result)
		{
			if (MapPinService.IsSearchFocused())
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch]
	[OptionalHarmonyPatch]
	internal static class ObjectHoverPatches
	{
		private static readonly Type[] HoverTypes = new Type[10]
		{
			typeof(Fireplace),
			typeof(Smelter),
			typeof(CookingStation),
			typeof(Fermenter),
			typeof(Beehive),
			typeof(SapCollector),
			typeof(WispSpawner),
			typeof(ShieldGenerator),
			typeof(CraftingStation),
			typeof(Container)
		};

		[HarmonyTargetMethods]
		private static IEnumerable<MethodBase> TargetMethods()
		{
			HashSet<MethodBase> found = new HashSet<MethodBase>();
			BindingFlags flags = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			int num;
			for (int i = 0; i < HoverTypes.Length; num = i + 1, i = num)
			{
				MethodInfo[] methods;
				try
				{
					methods = HoverTypes[i].GetMethods(flags);
				}
				catch
				{
					continue;
				}
				for (int j = 0; j < methods.Length; j = num)
				{
					MethodInfo method = methods[j];
					if (!(method == null) && !method.IsAbstract && !(method.ReturnType != typeof(string)) && IsHoverCallback(method.Name) && found.Add(method))
					{
						yield return method;
					}
					num = j + 1;
				}
			}
		}

		private static bool IsHoverCallback(string name)
		{
			return string.Equals(name, "GetHoverText", StringComparison.Ordinal) || string.Equals(name, "HoverText", StringComparison.Ordinal) || name.StartsWith("OnHover", StringComparison.Ordinal);
		}

		[HarmonyPostfix]
		private static void Postfix(object __instance, MethodBase __originalMethod, ref string __result)
		{
			StationHoverService.Append(__instance, ref __result);
			Piece val = (Piece)((__instance is Piece) ? __instance : null);
			Beehive val2 = (Beehive)((__instance is Beehive) ? __instance : null);
			if ((Object)(object)val2 != (Object)null && __originalMethod != null && string.Equals(__originalMethod.Name, "GetHoverText", StringComparison.Ordinal))
			{
				FarmingPresentationService.TouchBeehiveHover(val2, ref __result);
			}
		}
	}
	[HarmonyPatch(typeof(Pickable), "GetHoverText")]
	[OptionalHarmonyPatch]
	internal static class PickableHoverPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Pickable __instance, ref string __result)
		{
			StationHoverService.AppendPickable(__instance, ref __result);
		}
	}
	[HarmonyPatch]
	[OptionalHarmonyPatch]
	internal static class HudFoodColorPatch
	{
		[HarmonyTargetMethod]
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(Hud), "UpdateFood", (Type[])null, (Type[])null);
		}

		[HarmonyPostfix]
		private static void Postfix(Hud __instance)
		{
			InterfaceQoLService.ApplyFoodSlotColors(__instance);
		}
	}
	[HarmonyPatch]
	[OptionalHarmonyPatch]
	internal static class PlantPlacementSpacingPatch
	{
		[HarmonyTargetMethod]
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(Player), "UpdatePlacementGhost", (Type[])null, (Type[])null);
		}

		[HarmonyPostfix]
		private static void Postfix(Player __instance)
		{
			FarmingPresentationService.ApplyPlantSpacingPlacementWarning(__instance);
		}
	}
	[HarmonyPatch]
	[OptionalHarmonyPatch]
	internal static class FishFightFeedbackPatch
	{
		[HarmonyTargetMethod]
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(Fish), "Escape", (Type[])null, (Type[])null);
		}

		[HarmonyPostfix]
		private static void Postfix(Fish __instance)
		{
			FishingFeatureService.OnFishEscape(__instance);
		}
	}
	[HarmonyPatch]
	internal static class ShieldBashPatches
	{
		[HarmonyPatch(typeof(Character), "Awake")]
		[HarmonyPostfix]
		private static void CharacterAwakePostfix(Character __instance)
		{
			ShieldBashService.AttachReceiver(__instance);
		}
	}
	[HarmonyPatch]
	[OptionalHarmonyPatch]
	internal static class ShieldGeneratorRadiusPatches
	{
		[HarmonyPatch(typeof(ShieldGenerator), "Start")]
		[HarmonyPostfix]
		private static void StartPostfix(ShieldGenerator __instance)
		{
			ShieldGeneratorRadiusService.RegisterRpc(__instance);
		}

		[HarmonyPatch(typeof(ShieldGenerator), "UpdateShield")]
		[HarmonyPrefix]
		private static void UpdateShieldPrefix(ShieldGenerator __instance)
		{
			ShieldGeneratorRadiusService.ApplyRadius(__instance);
		}

		[HarmonyPatch(typeof(ShieldGenerator), "GetHoverText")]
		[HarmonyPostfix]
		private static void GeneratorHoverPostfix(ShieldGenerator __instance, ref string __result)
		{
			ShieldGeneratorRadiusService.AppendHover(__instance, ref __result);
		}

		[HarmonyPatch(typeof(Switch), "GetHoverText")]
		[HarmonyPostfix]
		private static void FuelSwitchHoverPostfix(Switch __instance, ref string __result)
		{
			ShieldGenerator componentInParent = ((Component)__instance).GetComponentInParent<ShieldGenerator>();
			ShieldGeneratorRadiusService.AppendHover(componentInParent, ref __result);
		}

		[HarmonyPatch(typeof(Player), "UpdateHover")]
		[HarmonyPostfix]
		private static void UpdateHoverPostfix(Player __instance)
		{
			ShieldGeneratorRadiusService.HandleLocalInput(__instance);
		}
	}
	[HarmonyPatch(typeof(Player), "TryPlacePiece", new Type[] { typeof(Piece) })]
	internal static class StationTutorialPlacePiecePatch
	{
		[HarmonyPostfix]
		private static void Postfix(Player __instance, Piece __0, bool __result)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && __result && !((Object)(object)__0 == (Object)null))
			{
				string prefabName = Utils.GetPrefabName(((Component)__0).gameObject);
				if (!string.IsNullOrEmpty(prefabName))
				{
					StationTutorialService.OnLocalPiecePlaced(prefabName);
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class TraversalPatches
	{
		[HarmonyPatch(typeof(Character), "Jump", new Type[] { typeof(bool) })]
		private static class CharacterJump
		{
			[HarmonyPrefix]
			private static bool Prefix(Character __instance, bool force, out SprintJumpBoostService.JumpStart __state)
			{
				__state = default(SprintJumpBoostService.JumpStart);
				EitrTraversalService.BeginJump(__instance);
				if (TraversalService.TryConsumeJump(__instance, force))
				{
					return false;
				}
				__state = (force ? default(SprintJumpBoostService.JumpStart) : SprintJumpBoostService.Capture(__instance));
				EitrTraversalService.SetSprintJumpCostEligibility(__instance, __state.Eligible);
				return true;
			}

			[HarmonyPostfix]
			private static void Postfix(Character __instance, SprintJumpBoostService.JumpStart __state)
			{
				SprintJumpBoostService.ApplyAfterJump(__instance, __state);
			}

			[HarmonyFinalizer]
			private static void Finalizer(Character __instance)
			{
				EitrTraversalService.EndJump(__instance);
			}
		}

		[HarmonyPatch(typeof(Character), "UpdateMotion", new Type[] { typeof(float) })]
		private static class CharacterUpdateMotion
		{
			[HarmonyPrefix]
			private static bool Prefix(Character __instance, float dt)
			{
				if ((Object)(object)__instance == (Object)null || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
				{
					return true;
				}
				EitrTraversalService.BeginMotion(__instance);
				TraversalService.TryAutomaticStep(__instance, dt);
				TraversalService.TryPendingGrab(__instance);
				if (!TraversalService.IsActive(__instance))
				{
					return true;
				}
				if ((Object)(object)__instance == (Object)null || __instance.IsDead())
				{
					TraversalService.Cancel(__instance);
					return true;
				}
				TraversalService.Tick(__instance, dt);
				return !TraversalService.IsActive(__instance);
			}

			[HarmonyPostfix]
			private static void Postfix(Character __instance, float dt)
			{
				if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
				{
					FeatherfallService.AfterMotion(__instance, dt);
					EitrTraversalService.AfterMotion(__instance, dt);
					EitrTraversalService.ReconcileGroundedAnimation(__instance, dt);
				}
			}

			[HarmonyFinalizer]
			private static void Finalizer(Character __instance)
			{
				EitrTraversalService.EndMotion(__instance);
			}
		}
	}
}
namespace Balrond.Patches.Core
{
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	internal static class BaoTerminalInitPatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			BaoCommandService.RegisterTerminalCommands();
		}
	}
}
namespace Balrond.Weather
{
	internal static class VanillaWeatherExpansionCatalog
	{
		internal static readonly IReadOnlyList<WeatherDefinition> Environments = new WeatherDefinition[24]
		{
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Vinland_Sunmeadow",
				ParticleParent = "Clear",
				IsWet = false,
				IsFreezing = false,
				IsFreezingAtNight = false,
				IsCold = false,
				IsColdAtNight = false,
				AlwaysDark = false,
				WindMin = 0.08f,
				WindMax = 0.42f,
				RainCloudAlpha = 0.18f,
				AmbientVol = 0.42f,
				AmbientDay = new Color(0.57f, 0.66f, 0.43f, 1f),
				AmbientNight = new Color(0.24f, 0.31f, 0.3f, 1f),
				SunMorning = new Color(1f, 0.78f, 0.42f, 1f),
				SunDay = new Color(1f, 0.86f, 0.48f, 1f),
				SunEvening = new Color(0.96f, 0.56f, 0.25f, 1f),
				SunNight = new Color(0.35f, 0.44f, 0.48f, 1f),
				FogMorning = new Color(0.6f, 0.66f, 0.46f, 1f),
				FogDay = new Color(0.52f, 0.67f, 0.48f, 1f),
				FogEvening = new Color(0.56f, 0.55f, 0.39f, 1f),
				FogNight = new Color(0.21f, 0.29f, 0.3f, 1f),
				FogSunMorning = new Color(0.86f, 0.72f, 0.42f, 1f),
				FogSunDay = new Color(0.78f, 0.73f, 0.43f, 1f),
				FogSunEvening = new Color(0.82f, 0.5f, 0.27f, 1f),
				FogSunNight = new Color(0.29f, 0.37f, 0.4f, 1f),
				FogDensityMorning = 0.012f,
				FogDensityDay = 0.006f,
				FogDensityEvening = 0.016f,
				FogDensityNight = 0.028f,
				LightIntensityDay = 1.15f,
				LightIntensityNight = 0.62f,
				SunAngle = 45f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Vinland_WarmBreeze",
				ParticleParent = "Heath clear",
				IsWet = false,
				IsFreezing = false,
				IsFreezingAtNight = false,
				IsCold = false,
				IsColdAtNight = false,
				AlwaysDark = false,
				WindMin = 0.22f,
				WindMax = 0.62f,
				RainCloudAlpha = 0.26f,
				AmbientVol = 0.46f,
				AmbientDay = new Color(0.55f, 0.61f, 0.44f, 1f),
				AmbientNight = new Color(0.23f, 0.29f, 0.35f, 1f),
				SunMorning = new Color(0.98f, 0.7f, 0.38f, 1f),
				SunDay = new Color(0.95f, 0.78f, 0.44f, 1f),
				SunEvening = new Color(0.94f, 0.42f, 0.2f, 1f),
				SunNight = new Color(0.34f, 0.4f, 0.49f, 1f),
				FogMorning = new Color(0.52f, 0.58f, 0.43f, 1f),
				FogDay = new Color(0.48f, 0.58f, 0.46f, 1f),
				FogEvening = new Color(0.48f, 0.48f, 0.39f, 1f),
				FogNight = new Color(0.2f, 0.27f, 0.33f, 1f),
				FogSunMorning = new Color(0.78f, 0.62f, 0.38f, 1f),
				FogSunDay = new Color(0.72f, 0.66f, 0.4f, 1f),
				FogSunEvening = new Color(0.75f, 0.39f, 0.22f, 1f),
				FogSunNight = new Color(0.27f, 0.34f, 0.42f, 1f),
				FogDensityMorning = 0.016f,
				FogDensityDay = 0.008f,
				FogDensityEvening = 0.02f,
				FogDensityNight = 0.03f,
				LightIntensityDay = 1f,
				LightIntensityNight = 0.56f,
				SunAngle = 45f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Wold_MoorMist",
				ParticleParent = "Misty",
				IsCold = true,
				IsColdAtNight = true,
				WindMin = 0.12f,
				WindMax = 0.52f,
				RainCloudAlpha = 0.72f,
				AmbientVol = 0.54f,
				AmbientDay = new Color(0.42f, 0.38f, 0.32f, 1f),
				AmbientNight = new Color(0.18f, 0.2f, 0.23f, 1f),
				SunMorning = new Color(0.78f, 0.58f, 0.38f, 1f),
				SunDay = new Color(0.62f, 0.58f, 0.46f, 1f),
				SunEvening = new Color(0.84f, 0.44f, 0.24f, 1f),
				SunNight = new Color(0.26f, 0.3f, 0.38f, 1f),
				FogMorning = new Color(0.52f, 0.48f, 0.4f, 1f),
				FogDay = new Color(0.45f, 0.43f, 0.37f, 1f),
				FogEvening = new Color(0.58f, 0.41f, 0.29f, 1f),
				FogNight = new Color(0.22f, 0.25f, 0.3f, 1f),
				FogSunMorning = new Color(0.78f, 0.64f, 0.44f, 1f),
				FogSunDay = new Color(0.68f, 0.6f, 0.44f, 1f),
				FogSunEvening = new Color(0.82f, 0.46f, 0.26f, 1f),
				FogSunNight = new Color(0.28f, 0.32f, 0.4f, 1f),
				FogDensityMorning = 0.052f,
				FogDensityDay = 0.04f,
				FogDensityEvening = 0.058f,
				FogDensityNight = 0.068f,
				LightIntensityDay = 0.58f,
				LightIntensityNight = 0.32f,
				SunAngle = 42f,
				IsFreezing = false
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Bogwood_DampCanopy",
				ParticleParent = "DeepForest Mist",
				IsWet = false,
				IsFreezing = false,
				IsFreezingAtNight = false,
				IsCold = false,
				IsColdAtNight = false,
				AlwaysDark = false,
				WindMin = 0.03f,
				WindMax = 0.28f,
				RainCloudAlpha = 0.78f,
				AmbientVol = 0.55f,
				AmbientDay = new Color(0.31f, 0.42f, 0.31f, 1f),
				AmbientNight = new Color(0.13f, 0.2f, 0.2f, 1f),
				SunMorning = new Color(0.72f, 0.61f, 0.4f, 1f),
				SunDay = new Color(0.5f, 0.62f, 0.43f, 1f),
				SunEvening = new Color(0.68f, 0.45f, 0.29f, 1f),
				SunNight = new Color(0.2f, 0.29f, 0.32f, 1f),
				FogMorning = new Color(0.39f, 0.49f, 0.4f, 1f),
				FogDay = new Color(0.31f, 0.43f, 0.34f, 1f),
				FogEvening = new Color(0.4f, 0.39f, 0.32f, 1f),
				FogNight = new Color(0.15f, 0.23f, 0.24f, 1f),
				FogSunMorning = new Color(0.58f, 0.61f, 0.42f, 1f),
				FogSunDay = new Color(0.45f, 0.57f, 0.4f, 1f),
				FogSunEvening = new Color(0.58f, 0.43f, 0.29f, 1f),
				FogSunNight = new Color(0.19f, 0.28f, 0.31f, 1f),
				FogDensityMorning = 0.055f,
				FogDensityDay = 0.044f,
				FogDensityEvening = 0.06f,
				FogDensityNight = 0.072f,
				LightIntensityDay = 0.54f,
				LightIntensityNight = 0.4f,
				SunAngle = 45f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Bogwood_RootMist",
				ParticleParent = "Misty",
				IsWet = false,
				IsFreezing = false,
				IsFreezingAtNight = false,
				IsCold = false,
				IsColdAtNight = false,
				AlwaysDark = false,
				WindMin = 0.02f,
				WindMax = 0.2f,
				RainCloudAlpha = 0.66f,
				AmbientVol = 0.48f,
				AmbientDay = new Color(0.28f, 0.39f, 0.33f, 1f),
				AmbientNight = new Color(0.12f, 0.18f, 0.21f, 1f),
				SunMorning = new Color(0.64f, 0.59f, 0.39f, 1f),
				SunDay = new Color(0.45f, 0.56f, 0.42f, 1f),
				SunEvening = new Color(0.6f, 0.43f, 0.31f, 1f),
				SunNight = new Color(0.19f, 0.27f, 0.33f, 1f),
				FogMorning = new Color(0.36f, 0.46f, 0.39f, 1f),
				FogDay = new Color(0.3f, 0.4f, 0.35f, 1f),
				FogEvening = new Color(0.35f, 0.38f, 0.34f, 1f),
				FogNight = new Color(0.14f, 0.21f, 0.25f, 1f),
				FogSunMorning = new Color(0.51f, 0.55f, 0.39f, 1f),
				FogSunDay = new Color(0.41f, 0.51f, 0.39f, 1f),
				FogSunEvening = new Color(0.52f, 0.41f, 0.3f, 1f),
				FogSunNight = new Color(0.18f, 0.26f, 0.32f, 1f),
				FogDensityMorning = 0.075f,
				FogDensityDay = 0.062f,
				FogDensityEvening = 0.078f,
				FogDensityNight = 0.095f,
				LightIntensityDay = 0.46f,
				LightIntensityNight = 0.36f,
				SunAngle = 45f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Morass_StillMire",
				ParticleParent = "Misty",
				IsWet = false,
				IsFreezing = false,
				IsFreezingAtNight = false,
				IsCold = false,
				IsColdAtNight = false,
				AlwaysDark = false,
				WindMin = 0.02f,
				WindMax = 0.22f,
				RainCloudAlpha = 0.56f,
				AmbientVol = 0.4f,
				AmbientDay = new Color(0.48f, 0.46f, 0.35f, 1f),
				AmbientNight = new Color(0.22f, 0.23f, 0.24f, 1f),
				SunMorning = new Color(0.86f, 0.72f, 0.43f, 1f),
				SunDay = new Color(0.68f, 0.67f, 0.48f, 1f),
				SunEvening = new Color(0.78f, 0.54f, 0.31f, 1f),
				SunNight = new Color(0.28f, 0.31f, 0.35f, 1f),
				FogMorning = new Color(0.56f, 0.55f, 0.45f, 1f),
				FogDay = new Color(0.49f, 0.5f, 0.42f, 1f),
				FogEvening = new Color(0.58f, 0.49f, 0.38f, 1f),
				FogNight = new Color(0.22f, 0.25f, 0.27f, 1f),
				FogSunMorning = new Color(0.76f, 0.69f, 0.45f, 1f),
				FogSunDay = new Color(0.65f, 0.64f, 0.46f, 1f),
				FogSunEvening = new Color(0.72f, 0.51f, 0.32f, 1f),
				FogSunNight = new Color(0.27f, 0.3f, 0.34f, 1f),
				FogDensityMorning = 0.05f,
				FogDensityDay = 0.036f,
				FogDensityEvening = 0.055f,
				FogDensityNight = 0.064f,
				LightIntensityDay = 0.68f,
				LightIntensityNight = 0.46f,
				SunAngle = 45f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Morass_PaleMarsh",
				ParticleParent = "DeepForest Mist",
				IsWet = false,
				IsFreezing = false,
				IsFreezingAtNight = false,
				IsCold = false,
				IsColdAtNight = false,
				AlwaysDark = false,
				WindMin = 0.06f,
				WindMax = 0.34f,
				RainCloudAlpha = 0.46f,
				AmbientVol = 0.42f,
				AmbientDay = new Color(0.52f, 0.52f, 0.43f, 1f),
				AmbientNight = new Color(0.22f, 0.25f, 0.27f, 1f),
				SunMorning = new Color(0.85f, 0.74f, 0.51f, 1f),
				SunDay = new Color(0.72f, 0.72f, 0.57f, 1f),
				SunEvening = new Color(0.79f, 0.57f, 0.39f, 1f),
				SunNight = new Color(0.29f, 0.34f, 0.39f, 1f),
				FogMorning = new Color(0.6f, 0.61f, 0.52f, 1f),
				FogDay = new Color(0.55f, 0.57f, 0.49f, 1f),
				FogEvening = new Color(0.58f, 0.52f, 0.45f, 1f),
				FogNight = new Color(0.23f, 0.28f, 0.31f, 1f),
				FogSunMorning = new Color(0.77f, 0.72f, 0.52f, 1f),
				FogSunDay = new Color(0.69f, 0.69f, 0.53f, 1f),
				FogSunEvening = new Color(0.72f, 0.53f, 0.39f, 1f),
				FogSunNight = new Color(0.28f, 0.33f, 0.37f, 1f),
				FogDensityMorning = 0.035f,
				FogDensityDay = 0.026f,
				FogDensityEvening = 0.038f,
				FogDensityNight = 0.05f,
				LightIntensityDay = 0.74f,
				LightIntensityNight = 0.48f,
				SunAngle = 45f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Darklands_RottenRain",
				ParticleParent = "Bonemass",
				IsWet = true,
				IsFreezing = false,
				IsFreezingAtNight = false,
				IsCold = true,
				IsColdAtNight = true,
				AlwaysDark = true,
				WindMin = 0.08f,
				WindMax = 0.28f,
				RainCloudAlpha = 2.2f,
				AmbientVol = 0.55f,
				AmbientDay = new Color(0.075f, 0.09f, 0.055f, 1f),
				AmbientNight = new Color(0.028f, 0.045f, 0.035f, 1f),
				SunMorning = new Color(0.12f, 0.14f, 0.075f, 1f),
				SunDay = new Color(0.12f, 0.14f, 0.075f, 1f),
				SunEvening = new Color(0.12f, 0.14f, 0.075f, 1f),
				SunNight = new Color(0.045f, 0.07f, 0.065f, 1f),
				FogMorning = new Color(0.06f, 0.08f, 0.045f, 1f),
				FogDay = new Color(0.06f, 0.08f, 0.045f, 1f),
				FogEvening = new Color(0.06f, 0.08f, 0.045f, 1f),
				FogNight = new Color(0.022f, 0.04f, 0.032f, 1f),
				FogSunMorning = new Color(0.08f, 0.1f, 0.05f, 1f),
				FogSunDay = new Color(0.08f, 0.1f, 0.05f, 1f),
				FogSunEvening = new Color(0.08f, 0.1f, 0.05f, 1f),
				FogSunNight = new Color(0.035f, 0.055f, 0.04f, 1f),
				FogDensityMorning = 0.075f,
				FogDensityDay = 0.075f,
				FogDensityEvening = 0.084f,
				FogDensityNight = 0.105f,
				LightIntensityDay = 0.105f,
				LightIntensityNight = 0.055f,
				SunAngle = 18f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Highlands_PineFrost",
				ParticleParent = "Snow",
				IsFreezing = true,
				IsCold = true,
				IsColdAtNight = true,
				WindMin = 0.16f,
				WindMax = 0.58f,
				RainCloudAlpha = 0.55f,
				AmbientVol = 0.58f,
				AmbientDay = new Color(0.34f, 0.42f, 0.43f, 1f),
				AmbientNight = new Color(0.12f, 0.17f, 0.25f, 1f),
				SunMorning = new Color(0.72f, 0.76f, 0.78f, 1f),
				SunDay = new Color(0.58f, 0.66f, 0.65f, 1f),
				SunEvening = new Color(0.66f, 0.5f, 0.42f, 1f),
				SunNight = new Color(0.22f, 0.3f, 0.42f, 1f),
				FogMorning = new Color(0.46f, 0.52f, 0.54f, 1f),
				FogDay = new Color(0.39f, 0.47f, 0.48f, 1f),
				FogEvening = new Color(0.48f, 0.44f, 0.42f, 1f),
				FogNight = new Color(0.17f, 0.24f, 0.34f, 1f),
				FogSunMorning = new Color(0.72f, 0.76f, 0.78f, 1f),
				FogSunDay = new Color(0.58f, 0.66f, 0.65f, 1f),
				FogSunEvening = new Color(0.66f, 0.5f, 0.42f, 1f),
				FogSunNight = new Color(0.22f, 0.3f, 0.42f, 1f),
				FogDensityMorning = 0.04f,
				FogDensityDay = 0.022f,
				FogDensityEvening = 0.05f,
				FogDensityNight = 0.055f,
				LightIntensityDay = 0.58f,
				LightIntensityNight = 0.33f,
				SunAngle = 48f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Highlands_AlpineWhiteout",
				ParticleParent = "SnowStorm",
				IsWet = false,
				IsFreezing = true,
				IsFreezingAtNight = false,
				IsCold = true,
				IsColdAtNight = true,
				AlwaysDark = false,
				WindMin = 0.64f,
				WindMax = 1f,
				RainCloudAlpha = 1.35f,
				AmbientVol = 0.62f,
				AmbientDay = new Color(0.47f, 0.53f, 0.57f, 1f),
				AmbientNight = new Color(0.14f, 0.19f, 0.27f, 1f),
				SunMorning = new Color(0.65f, 0.71f, 0.75f, 1f),
				SunDay = new Color(0.58f, 0.66f, 0.7f, 1f),
				SunEvening = new Color(0.59f, 0.6f, 0.64f, 1f),
				SunNight = new Color(0.24f, 0.31f, 0.43f, 1f),
				FogMorning = new Color(0.62f, 0.67f, 0.69f, 1f),
				FogDay = new Color(0.64f, 0.69f, 0.71f, 1f),
				FogEvening = new Color(0.56f, 0.6f, 0.63f, 1f),
				FogNight = new Color(0.19f, 0.25f, 0.34f, 1f),
				FogSunMorning = new Color(0.63f, 0.68f, 0.71f, 1f),
				FogSunDay = new Color(0.66f, 0.71f, 0.73f, 1f),
				FogSunEvening = new Color(0.58f, 0.61f, 0.64f, 1f),
				FogSunNight = new Color(0.23f, 0.29f, 0.4f, 1f),
				FogDensityMorning = 0.065f,
				FogDensityDay = 0.072f,
				FogDensityEvening = 0.075f,
				FogDensityNight = 0.095f,
				LightIntensityDay = 0.38f,
				LightIntensityNight = 0.25f,
				SunAngle = 45f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Frostvale_CanyonWind",
				ParticleParent = "Moder",
				IsFreezing = true,
				IsCold = true,
				IsColdAtNight = true,
				WindMin = 0.38f,
				WindMax = 0.9f,
				RainCloudAlpha = 0.55f,
				AmbientVol = 0.58f,
				AmbientDay = new Color(0.36f, 0.34f, 0.42f, 1f),
				AmbientNight = new Color(0.184f, 0.175f, 0.265f, 1f),
				SunMorning = new Color(0.7f, 0.78f, 0.9f, 1f),
				SunDay = new Color(0.58f, 0.68f, 0.86f, 1f),
				SunEvening = new Color(0.82f, 0.22f, 0.18f, 1f),
				SunNight = new Color(0.202f, 0.281f, 0.381f, 1f),
				FogMorning = new Color(0.42f, 0.5f, 0.62f, 1f),
				FogDay = new Color(0.38f, 0.48f, 0.62f, 1f),
				FogEvening = new Color(0.36f, 0.34f, 0.48f, 1f),
				FogNight = new Color(0.276f, 0.132f, 0.204f, 1f),
				FogSunMorning = new Color(0.74f, 0.84f, 0.98f, 1f),
				FogSunDay = new Color(0.62f, 0.74f, 0.92f, 1f),
				FogSunEvening = new Color(0.6f, 0.44f, 0.58f, 1f),
				FogSunNight = new Color(0.175f, 0.289f, 0.406f, 1f),
				FogDensityMorning = 0.04f,
				FogDensityDay = 0.018f,
				FogDensityEvening = 0.05f,
				FogDensityNight = 0.03f,
				LightIntensityDay = 0.56f,
				LightIntensityNight = 0.48f,
				SunAngle = 64f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Barrens_DustWind",
				ParticleParent = "GoblinKing",
				IsWet = false,
				IsFreezing = false,
				IsColdAtNight = false,
				WindMin = 0.42f,
				WindMax = 0.86f,
				RainCloudAlpha = 0.45f,
				AmbientVol = 0.7f,
				AmbientDay = new Color(0.46f, 0.36f, 0.27f, 1f),
				AmbientNight = new Color(0.391f, 0.228f, 0.282f, 1f),
				SunMorning = new Color(0.93f, 0.58f, 0.27f, 1f),
				SunDay = new Color(0.76f, 0.52f, 0.34f, 1f),
				SunEvening = new Color(0.93f, 0.35f, 0.16f, 1f),
				SunNight = new Color(0.321f, 0.272f, 0.327f, 1f),
				FogMorning = new Color(0.58f, 0.45f, 0.31f, 1f),
				FogDay = new Color(0.5f, 0.39f, 0.3f, 1f),
				FogEvening = new Color(0.64f, 0.32f, 0.2f, 1f),
				FogNight = new Color(0.27f, 0.193f, 0.237f, 1f),
				FogSunMorning = new Color(0.78f, 0.55f, 0.3f, 1f),
				FogSunDay = new Color(0.72f, 0.52f, 0.34f, 1f),
				FogSunEvening = new Color(0.89f, 0.38f, 0.18f, 1f),
				FogSunNight = new Color(0.289f, 0.252f, 0.28f, 1f),
				FogDensityMorning = 0.027f,
				FogDensityDay = 0.02f,
				FogDensityEvening = 0.03f,
				FogDensityNight = 0.04f,
				LightIntensityDay = 0.65f,
				LightIntensityNight = 0.56f,
				SunAngle = 60f,
				IsCold = false
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Badlands_GoldenHeat",
				ParticleParent = "Misty",
				IsWet = false,
				IsCold = false,
				IsFreezing = false,
				IsColdAtNight = true,
				IsFreezingAtNight = true,
				AlwaysDark = false,
				WindMin = 0.1f,
				WindMax = 0.42f,
				RainCloudAlpha = 0.3f,
				AmbientVol = 0.48f,
				AmbientDay = new Color(0.58f, 0.44f, 0.27f, 1f),
				AmbientNight = new Color(0.19f, 0.17f, 0.2f, 1f),
				SunMorning = new Color(1f, 0.72f, 0.34f, 1f),
				SunDay = new Color(1f, 0.72f, 0.34f, 1f),
				SunEvening = new Color(1f, 0.39f, 0.12f, 1f),
				SunNight = new Color(0.29f, 0.32f, 0.43f, 1f),
				FogMorning = new Color(0.64f, 0.49f, 0.28f, 1f),
				FogDay = new Color(0.64f, 0.49f, 0.28f, 1f),
				FogEvening = new Color(0.74f, 0.39f, 0.16f, 1f),
				FogNight = new Color(0.16f, 0.17f, 0.23f, 1f),
				FogSunMorning = new Color(0.95f, 0.65f, 0.27f, 1f),
				FogSunDay = new Color(0.95f, 0.65f, 0.27f, 1f),
				FogSunEvening = new Color(1f, 0.34f, 0.1f, 1f),
				FogSunNight = new Color(0.24f, 0.29f, 0.4f, 1f),
				FogDensityMorning = 0.0253f,
				FogDensityDay = 0.022f,
				FogDensityEvening = 0.03f,
				FogDensityNight = 0.05f,
				LightIntensityDay = 0.98f,
				LightIntensityNight = 0.42f,
				SunAngle = 58f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Wold_DrySun",
				ParticleParent = "Twilight_Clear",
				IsCold = true,
				IsColdAtNight = true,
				WindMin = 0.18f,
				WindMax = 0.55f,
				RainCloudAlpha = 0.18f,
				AmbientVol = 0.42f,
				AmbientDay = new Color(0.5f, 0.43f, 0.31f, 1f),
				AmbientNight = new Color(0.18f, 0.19f, 0.23f, 1f),
				SunMorning = new Color(0.92f, 0.7f, 0.38f, 1f),
				SunDay = new Color(0.82f, 0.68f, 0.42f, 1f),
				SunEvening = new Color(0.96f, 0.48f, 0.2f, 1f),
				SunNight = new Color(0.26f, 0.3f, 0.38f, 1f),
				FogMorning = new Color(0.56f, 0.49f, 0.37f, 1f),
				FogDay = new Color(0.46f, 0.42f, 0.34f, 1f),
				FogEvening = new Color(0.62f, 0.39f, 0.25f, 1f),
				FogNight = new Color(0.22f, 0.25f, 0.3f, 1f),
				FogSunMorning = new Color(0.78f, 0.64f, 0.44f, 1f),
				FogSunDay = new Color(0.68f, 0.6f, 0.44f, 1f),
				FogSunEvening = new Color(0.82f, 0.46f, 0.26f, 1f),
				FogSunNight = new Color(0.28f, 0.32f, 0.4f, 1f),
				FogDensityMorning = 0.018f,
				FogDensityDay = 0.012f,
				FogDensityEvening = 0.022f,
				FogDensityNight = 0.032f,
				LightIntensityDay = 0.76f,
				LightIntensityNight = 0.34f,
				SunAngle = 52f,
				IsFreezing = false
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_RedThicket_CrimsonHaze",
				ParticleParent = "GoblinKing",
				IsWet = false,
				IsFreezing = false,
				IsColdAtNight = false,
				AlwaysDark = false,
				WindMin = 0.05f,
				WindMax = 0.3f,
				RainCloudAlpha = 0.36f,
				AmbientVol = 0.48f,
				AmbientDay = new Color(0.55f, 0.35f, 0.27f, 1f),
				AmbientNight = new Color(0.34f, 0.25f, 0.34f, 1f),
				SunMorning = new Color(1f, 0.55f, 0.25f, 1f),
				SunDay = new Color(0.9f, 0.55f, 0.35f, 1f),
				SunEvening = new Color(1f, 0.26f, 0.18f, 1f),
				SunNight = new Color(0.5f, 0.34f, 0.56f, 1f),
				FogMorning = new Color(0.62f, 0.36f, 0.27f, 1f),
				FogDay = new Color(0.52f, 0.3f, 0.27f, 1f),
				FogEvening = new Color(0.64f, 0.18f, 0.22f, 1f),
				FogNight = new Color(0.27f, 0.2f, 0.3f, 1f),
				FogSunMorning = new Color(0.94f, 0.49f, 0.25f, 1f),
				FogSunDay = new Color(0.82f, 0.46f, 0.32f, 1f),
				FogSunEvening = new Color(0.94f, 0.22f, 0.2f, 1f),
				FogSunNight = new Color(0.42f, 0.27f, 0.47f, 1f),
				FogDensityMorning = 0.024f,
				FogDensityDay = 0.03f,
				FogDensityEvening = 0.03f,
				FogDensityNight = 0.05f,
				LightIntensityDay = 0.78f,
				LightIntensityNight = 0.85f,
				SunAngle = 58f,
				IsCold = false
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Darklands_BlackStorm",
				ParticleParent = "Mistlands_thunder",
				IsWet = true,
				IsFreezing = false,
				IsFreezingAtNight = false,
				IsCold = true,
				IsColdAtNight = true,
				AlwaysDark = true,
				WindMin = 0.3f,
				WindMax = 0.72f,
				RainCloudAlpha = 2.8f,
				AmbientVol = 0.55f,
				AmbientDay = new Color(0.07f, 0.07f, 0.085f, 1f),
				AmbientNight = new Color(0.025f, 0.025f, 0.04f, 1f),
				SunMorning = new Color(0.1f, 0.09f, 0.12f, 1f),
				SunDay = new Color(0.1f, 0.09f, 0.12f, 1f),
				SunEvening = new Color(0.1f, 0.09f, 0.12f, 1f),
				SunNight = new Color(0.04f, 0.035f, 0.065f, 1f),
				FogMorning = new Color(0.055f, 0.05f, 0.07f, 1f),
				FogDay = new Color(0.055f, 0.05f, 0.07f, 1f),
				FogEvening = new Color(0.055f, 0.05f, 0.07f, 1f),
				FogNight = new Color(0.02f, 0.02f, 0.038f, 1f),
				FogSunMorning = new Color(0.075f, 0.065f, 0.09f, 1f),
				FogSunDay = new Color(0.075f, 0.065f, 0.09f, 1f),
				FogSunEvening = new Color(0.075f, 0.065f, 0.09f, 1f),
				FogSunNight = new Color(0.03f, 0.028f, 0.055f, 1f),
				FogDensityMorning = 0.075f,
				FogDensityDay = 0.075f,
				FogDensityEvening = 0.084f,
				FogDensityNight = 0.105f,
				LightIntensityDay = 0.085f,
				LightIntensityNight = 0.045f,
				SunAngle = 16f
			},
			new WeatherDefinition
			{
				Name = "BalrondBiomes_Coldmoor_GraveWind",
				ParticleParent = "Moder",
				IsWet = false,
				IsCold = true,
				IsFreezing = true,
				IsColdAtNight = true,
				AlwaysDark = true,
				WindMin = 0.72f,
				WindMax = 1f,
				RainCloudAlpha = 1.25f,
				AmbientVol = 0.78f,