Decompiled source of ZenoxDev v1.0.31

Zenox.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Splatform;
using TMPro;
using UnityEngine;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Zenox")]
[assembly: AssemblyConfiguration("DevBuild")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Zenox")]
[assembly: AssemblyTitle("Zenox")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Zenox
{
	[BepInPlugin("zenox.zenox", "Zenox", "1.0.31")]
	public class ZenoxPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(MonsterAI), "FindClosestConsumableItem")]
		private static class MonsterAI_FindClosestConsumableItem_AnimalFeeding_Patch
		{
			private static void Postfix(MonsterAI __instance, float maxRange, ref ItemDrop __result)
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				if (AnimalFeedingEnabled.Value && !((Object)(object)__result != (Object)null) && __instance.m_consumeItems != null && __instance.m_consumeItems.Count != 0)
				{
					var (val, val2) = FindFoodInNearbyContainers(((Component)__instance).transform.position, maxRange, __instance.m_consumeItems);
					if (!((Object)(object)val == (Object)null))
					{
						ItemDrop val3 = ItemDrop.DropItem(val2, 1, ((Component)val).transform.position, Quaternion.identity);
						val.GetInventory().RemoveItem(val2, 1);
						__result = val3;
					}
				}
			}
		}

		[HarmonyPatch(typeof(MonsterAI), "UpdateTarget")]
		private static class MonsterAI_UpdateTarget_AnimalFeeding_Patch
		{
			private static void Postfix(MonsterAI __instance, ref Character ___m_targetCreature, Tameable ___m_tamable)
			{
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				if (AnimalFeedingEnabled.Value && !((Object)(object)___m_tamable == (Object)null) && !___m_tamable.IsTamed() && !((Object)(object)___m_targetCreature == (Object)null) && ___m_targetCreature.IsPlayer() && __instance.m_consumeItems != null && __instance.m_consumeItems.Count != 0)
				{
					Container item = FindFoodInNearbyContainers(((Component)__instance).transform.position, __instance.m_consumeSearchRange, __instance.m_consumeItems).container;
					if (!((Object)(object)item == (Object)null))
					{
						___m_targetCreature = null;
						Traverse.Create((object)__instance).Method("SetAlerted", new object[1] { false }).GetValue();
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "OnDeath")]
		private static class Player_OnDeath_BackCommand_Patch
		{
			private static void Postfix(Player __instance)
			{
				if (BackCommandEnabled.Value && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
				{
					lastDeathTime = Time.time;
					Chat instance = Chat.instance;
					if (instance != null)
					{
						((Terminal)instance).AddString($"[Zenox] Use /back to return to your death position. Expires in {BackCommandExpirySeconds.Value:0}s.");
					}
				}
			}
		}

		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		private static class Terminal_InitTerminal_BackCommand_Patch
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static ConsoleEvent <>9__0_0;

				internal void <Postfix>b__0_0(ConsoleEventArgs <p0>)
				{
					//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
					if (!BackCommandEnabled.Value)
					{
						return;
					}
					Player localPlayer = Player.m_localPlayer;
					if ((Object)(object)localPlayer == (Object)null)
					{
						return;
					}
					float num = Time.time - lastBackUseTime;
					if (num < BackCommandCooldownSeconds.Value)
					{
						Chat instance = Chat.instance;
						if (instance != null)
						{
							((Terminal)instance).AddString($"[Zenox] /back is on cooldown for {BackCommandCooldownSeconds.Value - num:0}s.");
						}
						return;
					}
					float num2 = Time.time - lastDeathTime;
					if (num2 > BackCommandExpirySeconds.Value)
					{
						Chat instance2 = Chat.instance;
						if (instance2 != null)
						{
							((Terminal)instance2).AddString("[Zenox] No recent death to return to.");
						}
					}
					else
					{
						Vector3 deathPoint = Game.instance.GetPlayerProfile().GetDeathPoint();
						((Character)localPlayer).TeleportTo(deathPoint, ((Component)localPlayer).transform.rotation, true);
						lastBackUseTime = Time.time;
						lastDeathTime = float.NegativeInfinity;
					}
				}
			}

			private static void Postfix()
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				object obj = <>c.<>9__0_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate
					{
						//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
						//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
						//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
						if (BackCommandEnabled.Value)
						{
							Player localPlayer = Player.m_localPlayer;
							if (!((Object)(object)localPlayer == (Object)null))
							{
								float num = Time.time - lastBackUseTime;
								if (num < BackCommandCooldownSeconds.Value)
								{
									Chat instance = Chat.instance;
									if (instance != null)
									{
										((Terminal)instance).AddString($"[Zenox] /back is on cooldown for {BackCommandCooldownSeconds.Value - num:0}s.");
									}
								}
								else
								{
									float num2 = Time.time - lastDeathTime;
									if (num2 > BackCommandExpirySeconds.Value)
									{
										Chat instance2 = Chat.instance;
										if (instance2 != null)
										{
											((Terminal)instance2).AddString("[Zenox] No recent death to return to.");
										}
									}
									else
									{
										Vector3 deathPoint = Game.instance.GetPlayerProfile().GetDeathPoint();
										((Character)localPlayer).TeleportTo(deathPoint, ((Component)localPlayer).transform.rotation, true);
										lastBackUseTime = Time.time;
										lastDeathTime = float.NegativeInfinity;
									}
								}
							}
						}
					};
					<>c.<>9__0_0 = val;
					obj = (object)val;
				}
				new ConsoleCommand("back", "Return to your last death position.", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			}
		}

		[HarmonyPatch(typeof(Hud), "Awake")]
		private static class Hud_Awake_XPBar_Patch
		{
			private static void Postfix(Hud __instance)
			{
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_014f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_0162: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				if (!CharacterXPEnabled.Value || (Object)(object)xpBar != (Object)null)
				{
					return;
				}
				Transform val = Utils.FindChild(((Component)__instance).gameObject.transform, "hudroot", (IterativeSearchType)0);
				if (!((Object)(object)val == (Object)null) && !((Object)(object)__instance.m_stealthBar == (Object)null))
				{
					GuiBar val2 = Object.Instantiate<GuiBar>(__instance.m_stealthBar, val, true);
					((Object)val2).name = "ZenoxCharacterXPBar";
					val2.SetMaxValue(1f);
					val2.SetValue(0f);
					Transform transform = ((Component)val2).transform;
					RectTransform val3 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
					val3.anchorMin = Vector2.zero;
					val3.anchorMax = new Vector2(1f, 0f);
					val3.anchoredPosition = Vector2.zero;
					val3.offsetMin = Vector2.zero;
					val3.offsetMax = Vector2.zero;
					val3.sizeDelta = new Vector2(0f, 9f);
					val2.m_bar.anchorMin = Vector2.zero;
					val2.m_bar.anchorMax = new Vector2(1f, 0.5f);
					val2.m_bar.offsetMin = Vector2.zero;
					val2.m_bar.offsetMax = Vector2.zero;
					RectTransform bar = val2.m_bar;
					Rect rect = val3.rect;
					bar.sizeDelta = new Vector2(((Rect)(ref rect)).width, 9f);
					Image component = ((Component)val2.m_bar).GetComponent<Image>();
					if ((Object)(object)component != (Object)null)
					{
						((Graphic)component).color = Color.yellow;
					}
					((Component)val2).gameObject.SetActive(true);
					xpBar = val2;
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		private static class Hud_Update_XPBar_Patch
		{
			private static void Postfix()
			{
				if (!CharacterXPEnabled.Value)
				{
					return;
				}
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null) && (Object)(object)xpPlayer == (Object)null)
				{
					XP_Awake(localPlayer);
					GuiBar xpBar = ZenoxPlugin.xpBar;
					if (xpBar != null)
					{
						xpBar.SetValue(XP_GetLevelPercentage());
					}
				}
			}
		}

		[HarmonyPatch(typeof(Skill), "Raise")]
		private static class SkillsSkill_Raise_XPBar_Patch
		{
			private static void Postfix(float factor)
			{
				if (CharacterXPEnabled.Value && !((Object)(object)xpBar == (Object)null) && !((Object)(object)xpPlayer == (Object)null))
				{
					XP_RaiseXP();
					xpBar.SetValue(XP_GetLevelPercentage());
				}
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "UpdateCharacterList")]
		private static class FejdStartup_UpdateCharacterList_Stats_Patch
		{
			private static void Postfix(List<PlayerProfile> ___m_profiles, int ___m_profileIndex, FejdStartup __instance)
			{
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				if (ShowCharacterSelectStats.Value && ___m_profiles != null && ___m_profileIndex >= 0 && ___m_profileIndex < ___m_profiles.Count && !((Object)(object)__instance.m_csName == (Object)null) && ((Component)__instance.m_csName).gameObject.activeSelf)
				{
					RectTransform rectTransform = __instance.m_csName.rectTransform;
					if (float.IsNaN(csNameBaseY))
					{
						csNameBaseY = rectTransform.anchoredPosition.y;
					}
					rectTransform.anchoredPosition = new Vector2(rectTransform.anchoredPosition.x, csNameBaseY + CharacterSelectStatsYOffset.Value);
					PlayerProfile val = ___m_profiles[___m_profileIndex];
					int num = (int)val.GetStat((PlayerStatType)6);
					int num2 = (int)val.GetStat((PlayerStatType)0);
					int num3 = (int)val.GetStat((PlayerStatType)1);
					int num4 = (int)val.GetStat((PlayerStatType)2);
					TMP_Text csName = __instance.m_csName;
					csName.text += $"\n<size={CharacterSelectStatsFontSize.Value}>Kills: {num}   Deaths: {num2}   Crafts: {num3}   Builds: {num4}</size>";
				}
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "UpdateCharacterStats")]
		private static class InventoryGui_UpdateCharacterStats_CombinedStats_Patch
		{
			private static void Postfix(InventoryGui __instance, Player player)
			{
				if (ShowCombinedItemStats.Value && !((Object)(object)player == (Object)null) && !((Object)(object)__instance.m_armor == (Object)null) && (!((Object)(object)combinedStatsTooltip == (Object)null) || TryCreateOverlay(__instance)))
				{
					statsBuilder.Clear();
					AppendWeaponStats(player, statsBuilder);
					AppendBlockStats(player, statsBuilder);
					statsBuilder.AppendFormat("\n\n$item_armor: <color=orange>{0}</color>", Mathf.RoundToInt(((Character)player).GetBodyArmor()));
					float equipmentMovementModifier = ((Character)player).GetEquipmentMovementModifier();
					if (equipmentMovementModifier != 0f)
					{
						string arg = ((equipmentMovementModifier > 0f) ? "green" : "red");
						statsBuilder.AppendFormat("\n$item_movement_modifier: <color={0}>{1:+0;-0}%</color>", arg, equipmentMovementModifier * 100f);
					}
					combinedStatsTooltip.m_text = Localization.instance.Localize(statsBuilder.ToString());
					combinedStatsTooltip.m_topic = $"Lv.{CharacterLevel} {player.GetPlayerName()}";
				}
			}
		}

		private class DoorTracking
		{
			public bool WasInRange;

			public bool OpenedByMod;

			public bool IsManual;

			public bool WasOpenLastTick;

			public float OutOfRangeTimer;
		}

		[HarmonyPatch(typeof(Door), "UpdateState")]
		private static class Door_UpdateState_Patch
		{
			private static void Postfix(Door __instance)
			{
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.RegisterDoor(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(ZNet), "LocalPlayerIsAdminOrHost")]
		private static class ZNet_LocalPlayerIsAdminOrHost_DevBuild_Patch
		{
			private static void Postfix(ref bool __result)
			{
				__result = true;
			}
		}

		[HarmonyPatch(typeof(ZNet), "PlayerIsAdmin")]
		private static class ZNet_PlayerIsAdmin_DevBuild_Patch
		{
			private static void Postfix(ref bool __result)
			{
				__result = true;
			}
		}

		[HarmonyPatch(typeof(ZNet), "IsAdmin")]
		private static class ZNet_IsAdmin_DevBuild_Patch
		{
			private static void Postfix(ref bool __result)
			{
				__result = true;
			}
		}

		[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
		private static class InventoryGrid_UpdateGui_DurabilityColor_Patch
		{
			private static void Postfix(List<InventoryElement> ___m_elements, Inventory ___m_inventory)
			{
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				if (!DurabilityColorEnabled.Value || ___m_inventory == null || ___m_elements == null)
				{
					return;
				}
				foreach (InventoryElement ___m_element in ___m_elements)
				{
					if (___m_element.m_used && !((Object)(object)___m_element.m_durability == (Object)null) && ((Component)___m_element.m_durability).gameObject.activeSelf)
					{
						ItemData itemAt = ___m_inventory.GetItemAt(___m_element.Position.x, ___m_element.Position.y);
						if (itemAt != null && itemAt.m_shared.m_useDurability && !(itemAt.m_durability <= 0f))
						{
							ApplyDurabilityColor(___m_element.m_durability, itemAt.GetDurabilityPercentage());
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")]
		private static class HotkeyBar_UpdateIcons_DurabilityColor_Patch
		{
			private static void Postfix(IList ___m_elements, List<ItemData> ___m_items)
			{
				if (!DurabilityColorEnabled.Value || ___m_elements == null || ___m_items == null)
				{
					return;
				}
				foreach (ItemData ___m_item in ___m_items)
				{
					int x = ___m_item.m_gridPos.x;
					if (x < 0 || x >= ___m_elements.Count || !___m_item.m_shared.m_useDurability || ___m_item.m_durability <= 0f)
					{
						continue;
					}
					object obj = ___m_elements[x];
					if (obj != null)
					{
						if (hotkeyDurabilityField == null || hotkeyDurabilityField.DeclaringType != obj.GetType())
						{
							hotkeyDurabilityField = AccessTools.Field(obj.GetType(), "m_durability");
						}
						object? obj2 = hotkeyDurabilityField?.GetValue(obj);
						GuiBar val = (GuiBar)((obj2 is GuiBar) ? obj2 : null);
						if (val != null && ((Component)val).gameObject.activeSelf)
						{
							ApplyDurabilityColor(val, ___m_item.GetDurabilityPercentage());
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnemyHud), "Awake")]
		private static class EnemyHud_Awake_DistanceMultiplier_Patch
		{
			private static void Postfix(EnemyHud __instance)
			{
				float num = Mathf.Clamp(EnemyHudDistanceMultiplier.Value, 0.1f, 5f);
				__instance.m_maxShowDistance *= num;
				__instance.m_maxShowDistanceBoss *= num;
			}
		}

		[HarmonyPatch(typeof(EnemyHud), "UpdateHuds")]
		private static class EnemyHud_UpdateHuds_AlwaysShowDistance_Patch
		{
			private static void Prefix(EnemyHud __instance)
			{
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_015e: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				if (EnemyUIAlwaysShowDistance.Value <= 0f || (Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				IDictionary dictionary = (IDictionary)HudsField.GetValue(__instance);
				if (dictionary == null)
				{
					return;
				}
				Vector3 position = ((Component)Player.m_localPlayer).transform.position;
				float num = EnemyUIAlwaysShowDistance.Value * EnemyUIAlwaysShowDistance.Value;
				int num2 = 0;
				foreach (DictionaryEntry item in dictionary)
				{
					object value = item.Value;
					if (value == null)
					{
						continue;
					}
					if (hudDataHoverTimerField == null || hudDataHoverTimerField.DeclaringType != value.GetType())
					{
						hudDataCharacterField = AccessTools.Field(value.GetType(), "m_character");
						hudDataHoverTimerField = AccessTools.Field(value.GetType(), "m_hoverTimer");
					}
					object? obj = hudDataCharacterField?.GetValue(value);
					Character val = (Character)(((obj is Character) ? obj : null) ?? ((object)/*isinst with value type is only supported in some contexts*/));
					if (!((Object)(object)val == (Object)null) && !val.IsPlayer() && !val.IsBoss())
					{
						Vector3 val2 = ((Component)val).transform.position - position;
						float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
						if (!(sqrMagnitude > num))
						{
							hudDataHoverTimerField?.SetValue(value, 0f);
							num2++;
						}
					}
				}
				if (!loggedAlwaysShowOnce && num2 > 0)
				{
					loggedAlwaysShowOnce = true;
					ZenoxPlugin instance = Instance;
					if (instance != null)
					{
						((BaseUnityPlugin)instance).Logger.LogInfo((object)$"[BetterUI] EnemyUIAlwaysShowDistance active: {num2} enemy hud(s) kept visible within {EnemyUIAlwaysShowDistance.Value}m this frame.");
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnemyHud), "LateUpdate")]
		private static class EnemyHud_LateUpdate_LevelPrefix_Patch
		{
			private static void Postfix(EnemyHud __instance)
			{
				//IL_0186: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0529: Unknown result type (might be due to invalid IL or missing references)
				//IL_0538: Unknown result type (might be due to invalid IL or missing references)
				//IL_0547: Unknown result type (might be due to invalid IL or missing references)
				//IL_0556: Unknown result type (might be due to invalid IL or missing references)
				//IL_043d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0436: Unknown result type (might be due to invalid IL or missing references)
				//IL_042f: Unknown result type (might be due to invalid IL or missing references)
				IDictionary dictionary = (IDictionary)HudsField.GetValue(__instance);
				if (dictionary == null)
				{
					return;
				}
				Image val6 = default(Image);
				Image val8 = default(Image);
				foreach (DictionaryEntry item in dictionary)
				{
					object value = item.Value;
					if (value == null)
					{
						continue;
					}
					if (hudDataNameField == null || hudDataNameField.DeclaringType != value.GetType())
					{
						hudDataNameField = AccessTools.Field(value.GetType(), "m_name");
						hudDataCharacterField = AccessTools.Field(value.GetType(), "m_character");
						hudDataLevel2Field = AccessTools.Field(value.GetType(), "m_level2");
						hudDataLevel3Field = AccessTools.Field(value.GetType(), "m_level3");
						hudDataHealthFastField = AccessTools.Field(value.GetType(), "m_healthFast");
					}
					if (hudDataNameField == null)
					{
						break;
					}
					object? value2 = hudDataNameField.GetValue(value);
					TextMeshProUGUI val = (TextMeshProUGUI)((value2 is TextMeshProUGUI) ? value2 : null);
					if (val == null)
					{
						continue;
					}
					object? obj = hudDataCharacterField?.GetValue(value);
					Character val2 = (Character)(((obj is Character) ? obj : null) ?? ((object)/*isinst with value type is only supported in some contexts*/));
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					if (!enemyNameBaseY.TryGetValue(value, out var value3))
					{
						value3 = ((TMP_Text)val).rectTransform.anchoredPosition.y;
						enemyNameBaseY[value] = value3;
					}
					if (!val2.IsPlayer() && !val2.IsBoss())
					{
						Vector2 anchoredPosition = ((TMP_Text)val).rectTransform.anchoredPosition;
						((TMP_Text)val).rectTransform.anchoredPosition = new Vector2(anchoredPosition.x, value3 + EnemyNameYOffset.Value);
					}
					Transform val3 = null;
					if (!val2.IsPlayer())
					{
						object? obj2 = hudDataHealthFastField?.GetValue(value);
						GuiBar val4 = (GuiBar)((obj2 is GuiBar) ? obj2 : null);
						if (val4 != null && (Object)(object)val4 != (Object)null)
						{
							val3 = ((Component)val4).transform.parent;
							if ((Object)(object)val3 != (Object)null)
							{
								if (!val2.IsBoss())
								{
									float num = Mathf.Clamp(EnemyHealthBarScale.Value, 0.5f, 3f);
									float num2 = num * Mathf.Clamp(EnemyHealthBarHeightScale.Value, 0.5f, 3f);
									val3.localScale = new Vector3(num, num2, 1f);
								}
								if (HideEnemyBarBackground.Value)
								{
									Transform val5 = val3.Find("darken");
									if ((Object)(object)val5 != (Object)null && ((Component)val5).TryGetComponent<Image>(ref val6))
									{
										((Behaviour)val6).enabled = false;
									}
									Transform val7 = val3.Find("bkg");
									if ((Object)(object)val7 != (Object)null && ((Component)val7).TryGetComponent<Image>(ref val8))
									{
										((Behaviour)val8).enabled = false;
									}
								}
							}
						}
					}
					int value4 = EnemyLevelStyle.Value;
					if (!val2.IsPlayer() && !val2.IsBoss())
					{
						((TMP_Text)val).text = ((value4 == 0) ? val2.GetHoverName() : ("<color=#ffdb3c>" + StarText(val2.GetLevel()) + "</color> " + val2.GetHoverName()));
						bool active = value4 != 1;
						object? obj3 = hudDataLevel2Field?.GetValue(value);
						SetActiveIfPresent((RectTransform)((obj3 is RectTransform) ? obj3 : null), active);
						object? obj4 = hudDataLevel3Field?.GetValue(value);
						SetActiveIfPresent((RectTransform)((obj4 is RectTransform) ? obj4 : null), active);
						if (ColorEnemyNameByAlertState.Value)
						{
							BaseAI baseAI = val2.GetBaseAI();
							bool flag = (Object)(object)baseAI != (Object)null && baseAI.IsAlerted();
							bool flag2 = (Object)(object)baseAI != (Object)null && baseAI.HaveTarget();
							((Graphic)val).color = (flag ? Color.red : (flag2 ? Color.yellow : Color.white));
						}
					}
					TMP_Text value5;
					if (ShowEnemyHpText.Value && !val2.IsPlayer() && (Object)(object)val3 != (Object)null)
					{
						TMP_Text orCreateHpLabel = GetOrCreateHpLabel(value, val);
						int num3 = (val2.IsBoss() ? BossHpTextFontSize.Value : EnemyHpTextFontSize.Value);
						orCreateHpLabel.text = $"<size={num3}>{Mathf.CeilToInt(val2.GetHealth())}/{Mathf.CeilToInt(val2.GetMaxHealth())}</size>";
						RectTransform val9 = (RectTransform)(object)((val3 is RectTransform) ? val3 : null);
						RectTransform rectTransform = orCreateHpLabel.rectTransform;
						if ((Object)(object)((Transform)rectTransform).parent != (Object)(object)val3.parent)
						{
							((Transform)rectTransform).SetParent(val3.parent, false);
						}
						if ((Object)(object)val9 != (Object)null)
						{
							rectTransform.anchorMin = val9.anchorMin;
							rectTransform.anchorMax = val9.anchorMax;
							rectTransform.pivot = val9.pivot;
							rectTransform.anchoredPosition = val9.anchoredPosition;
						}
					}
					else if (enemyHpLabels.TryGetValue(value, out value5) && (Object)(object)value5 != (Object)null)
					{
						((Component)value5).gameObject.SetActive(false);
					}
				}
			}
		}

		[HarmonyPatch(typeof(StatusEffect), "Clone")]
		private static class StatusEffect_Clone_Patch
		{
			private static void Postfix(StatusEffect __instance, ref StatusEffect __result)
			{
				if (PermanentGuardianPower.Value && (Object)(object)__result != (Object)null && ((Object)__result).name.StartsWith("GP_"))
				{
					__result.m_ttl = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(ItemStand), "DelayedPowerActivation")]
		private static class ItemStand_DelayedPowerActivation_Patch
		{
			private static void Postfix(ItemStand __instance)
			{
				if (PermanentGuardianPower.Value && !((Object)(object)__instance.m_guardianPower == (Object)null) && !((Object)(object)ZoneSystem.instance == (Object)null))
				{
					ZoneSystem.instance.SetGlobalKey("zenox_gp_" + ((Object)__instance.m_guardianPower).name);
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdateGuardianPower")]
		private static class Hud_UpdateGuardianPower_Patch
		{
			private static bool Prefix(Hud __instance)
			{
				if (!HideGuardianPowerHUD.Value)
				{
					return true;
				}
				((Component)__instance.m_gpRoot).gameObject.SetActive(false);
				return false;
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdateStatusEffects")]
		private static class Hud_UpdateStatusEffects_Patch
		{
			private static void Prefix(List<StatusEffect> statusEffects)
			{
				if (HideGuardianPowerHUD.Value)
				{
					statusEffects.RemoveAll((StatusEffect se) => (Object)(object)se != (Object)null && ((Object)se).name.StartsWith("GP_"));
				}
			}
		}

		[HarmonyPatch(typeof(Container), "GetHoverText")]
		private static class Container_GetHoverText_Style_Patch
		{
			private static void Postfix(Container __instance, ref string __result)
			{
				if (HoverTextExtensionsEnabled.Value && ContainerHoverStyle.Value != 0 && !string.IsNullOrEmpty(__result))
				{
					Inventory inventory = __instance.GetInventory();
					if (inventory != null && inventory.NrOfItems() != 0)
					{
						__result = string.Concat(str2: ContainerHoverStyle.Value switch
						{
							1 => $"{inventory.SlotsUsedPercentage():F0}%", 
							2 => $"{inventory.NrOfItems()}/{inventory.GetWidth() * inventory.GetHeight()}", 
							_ => $"{inventory.GetEmptySlots()} free", 
						}, str0: __result, str1: " ( ", str3: " )");
					}
				}
			}
		}

		[HarmonyPatch(typeof(Fermenter), "GetHoverText")]
		private static class Fermenter_GetHoverText_TimeLeft_Patch
		{
			private static void Postfix(Fermenter __instance, ZNetView ___m_nview, ref string __result)
			{
				if (!HoverTextExtensionsEnabled.Value || FermenterHoverStyle.Value == 0 || string.IsNullOrEmpty(__result) || (Object)(object)___m_nview == (Object)null || !___m_nview.IsValid())
				{
					return;
				}
				long num = ___m_nview.GetZDO().GetLong(ZDOVars.s_startTime, 0L);
				if (num != 0)
				{
					double totalSeconds = (ZNet.instance.GetTime() - new DateTime(num)).TotalSeconds;
					double num2 = (double)__instance.m_fermentationDuration - totalSeconds;
					if (!(num2 <= 0.0))
					{
						string text = ((FermenterHoverStyle.Value == 1) ? $"{totalSeconds / (double)__instance.m_fermentationDuration:P0} done" : (FormatDuration(num2) + " remaining"));
						__result = __result + "\n" + text;
					}
				}
			}
		}

		[HarmonyPatch(typeof(CookingStation), "GetHoverText")]
		private static class CookingStation_GetHoverText_Style_Patch
		{
			private static void Postfix(CookingStation __instance, ref string __result)
			{
				if (!HoverTextExtensionsEnabled.Value || CookingStationHoverStyle.Value == 0)
				{
					return;
				}
				if ((object)cookingStationNviewField == null)
				{
					cookingStationNviewField = AccessTools.Field(typeof(CookingStation), "m_nview");
				}
				if ((object)cookingStationGetSlotMethod == null)
				{
					cookingStationGetSlotMethod = AccessTools.Method(typeof(CookingStation), "GetSlot", (Type[])null, (Type[])null);
				}
				if ((object)cookingStationGetItemConversionMethod == null)
				{
					cookingStationGetItemConversionMethod = AccessTools.Method(typeof(CookingStation), "GetItemConversion", (Type[])null, (Type[])null);
				}
				if ((object)cookingStationIsFireLitMethod == null)
				{
					cookingStationIsFireLitMethod = AccessTools.Method(typeof(CookingStation), "IsFireLit", (Type[])null, (Type[])null);
				}
				if (cookingStationNviewField == null || cookingStationGetSlotMethod == null || cookingStationGetItemConversionMethod == null || cookingStationIsFireLitMethod == null)
				{
					return;
				}
				object? value = cookingStationNviewField.GetValue(__instance);
				ZNetView val = (ZNetView)((value is ZNetView) ? value : null);
				if (val == null || !val.IsValid() || !val.IsOwner() || !(bool)cookingStationIsFireLitMethod.Invoke(__instance, null))
				{
					return;
				}
				string text = "";
				int num = 0;
				for (int i = 0; i < __instance.m_slots.Length; i++)
				{
					object[] array = new object[5] { i, null, null, null, null };
					cookingStationGetSlotMethod.Invoke(__instance, array);
					string text2 = array[1] as string;
					if (string.IsNullOrEmpty(text2) || text2 == ((Object)__instance.m_overCookedItem).name)
					{
						continue;
					}
					object? obj = cookingStationGetItemConversionMethod.Invoke(__instance, new object[1] { text2 });
					ItemConversion val2 = (ItemConversion)((obj is ItemConversion) ? obj : null);
					if (val2 != null)
					{
						num++;
						float num2 = (float)array[2];
						if (num2 > val2.m_cookTime)
						{
							float num3 = val2.m_cookTime * 2f;
							string text3 = ((CookingStationHoverStyle.Value == 1) ? $"{num2 / num3:P0}" : FormatDuration(num3 - num2));
							text = text + "\n" + __instance.m_overCookedItem.GetHoverName() + ": <color=red>" + text3 + "</color>";
						}
						else
						{
							string text4 = ((CookingStationHoverStyle.Value == 1) ? $"{num2 / val2.m_cookTime:P0}" : FormatDuration(val2.m_cookTime - num2));
							text = text + "\n" + val2.m_to.GetHoverName() + ": " + text4;
						}
					}
				}
				if (num > 0)
				{
					__result = Localization.instance.Localize(__instance.m_name + text);
				}
			}
		}

		private class BarOffset
		{
			public ConfigEntry<float> OffsetX;

			public ConfigEntry<float> OffsetY;

			public ConfigEntry<float> Scale;

			public Vector2[] BaseAnchoredPositions;

			public Vector3[] BaseScales;

			public bool Captured;
		}

		[HarmonyPatch(typeof(HotkeyBar), "Update")]
		private static class HotkeyBar_Update_CacheInstance_HudEditor_Patch
		{
			private static void Postfix(HotkeyBar __instance)
			{
				if (((Object)__instance).name == "HotKeyBar")
				{
					cachedHotkeyBar = __instance;
				}
			}
		}

		[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
		private static class GameCamera_UpdateMouseCapture_HudEditor_Patch
		{
			private static void Postfix()
			{
				if ((Object)(object)Instance != (Object)null && Instance.editModeActive)
				{
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerController), "TakeInput", new Type[] { typeof(bool) })]
		private static class PlayerController_TakeInput_HudEditor_Patch
		{
			private static void Postfix(ref bool __result)
			{
				if ((Object)(object)Instance != (Object)null && Instance.editModeActive)
				{
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		private static class Hud_Update_ForceBarsVisible_HudEditor_Patch
		{
			private static readonly string[] FightingBars = new string[3] { "StaminaBar", "EitrBar", "AdrenalineBar" };

			private static bool forcedGpActive;

			public static void RestoreForcedActiveStates()
			{
				Hud instance = Hud.instance;
				if (!((Object)(object)instance == (Object)null))
				{
					if (forcedGpActive && (Object)(object)instance.m_gpRoot != (Object)null)
					{
						((Component)instance.m_gpRoot).gameObject.SetActive(false);
					}
					forcedGpActive = false;
				}
			}

			private static void Postfix(Hud __instance)
			{
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: Unknown result type (might be due to invalid IL or missing references)
				//IL_0158: Unknown result type (might be due to invalid IL or missing references)
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				//IL_017e: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)Instance == (Object)null || !Instance.editModeActive)
				{
					return;
				}
				if ((Object)(object)__instance.m_staminaAnimator != (Object)null)
				{
					__instance.m_staminaAnimator.SetBool("Visible", true);
				}
				if ((Object)(object)__instance.m_eitrAnimator != (Object)null)
				{
					__instance.m_eitrAnimator.SetBool("Visible", true);
				}
				if ((Object)(object)__instance.m_adrenalineAnimator != (Object)null)
				{
					__instance.m_adrenalineAnimator.SetBool("Visible", true);
				}
				if ((Object)(object)__instance.m_gpRoot != (Object)null && !((Component)__instance.m_gpRoot).gameObject.activeSelf)
				{
					((Component)__instance.m_gpRoot).gameObject.SetActive(true);
					forcedGpActive = true;
				}
				string[] fightingBars = FightingBars;
				foreach (string text in fightingBars)
				{
					if (Instance.barOffsets.TryGetValue(text, out var value) && value.Captured)
					{
						RectTransform barRoot = GetBarRoot(text);
						if (!((Object)(object)barRoot == (Object)null))
						{
							barRoot.anchoredPosition = value.BaseAnchoredPositions[0] + new Vector2(value.OffsetX.Value, value.OffsetY.Value);
							((Transform)barRoot).localScale = value.BaseScales[0] * value.Scale.Value;
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")]
		private static class ZInput_GetMouseScrollWheel_HudEditor_Patch
		{
			private static void Postfix(ref float __result)
			{
				if ((Object)(object)Instance != (Object)null && Instance.editModeActive)
				{
					__result = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
		private static class InventoryGrid_UpdateGui_ItemLevelStars_Patch
		{
			private static void Postfix(List<InventoryElement> ___m_elements, Inventory ___m_inventory)
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				if (!ItemLevelStarsEnabled.Value || ___m_inventory == null || ___m_elements == null)
				{
					return;
				}
				foreach (InventoryElement ___m_element in ___m_elements)
				{
					if (___m_element.m_used && !((Object)(object)___m_element.m_quality == (Object)null))
					{
						ItemData itemAt = ___m_inventory.GetItemAt(___m_element.Position.x, ___m_element.Position.y);
						if (itemAt != null && itemAt.m_shared.m_maxQuality > 1)
						{
							___m_element.m_quality.text = $"<size={InventoryStarFontSize.Value}>{StarText(itemAt.m_quality)}</size>";
							((Graphic)___m_element.m_quality).color = StarColor;
							___m_element.m_quality.enableWordWrapping = false;
							___m_element.m_quality.rectTransform.sizeDelta = new Vector2((float)itemAt.m_quality * ((float)InventoryStarFontSize.Value * 0.85f), 20f);
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(HotkeyBar), "UpdateIcons")]
		private static class HotkeyBar_UpdateIcons_ItemLevelStars_Patch
		{
			private static void Postfix(IList ___m_elements, List<ItemData> ___m_items)
			{
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				if (!ItemLevelStarsEnabled.Value || ___m_elements == null || ___m_items == null)
				{
					return;
				}
				HashSet<int> hashSet = new HashSet<int>();
				foreach (ItemData ___m_item in ___m_items)
				{
					int x = ___m_item.m_gridPos.x;
					if (x < 0 || x >= ___m_elements.Count)
					{
						continue;
					}
					object obj = ___m_elements[x];
					if (obj == null)
					{
						continue;
					}
					if (hotkeyGoField == null || hotkeyGoField.DeclaringType != obj.GetType())
					{
						hotkeyGoField = AccessTools.Field(obj.GetType(), "m_go");
					}
					object? obj2 = hotkeyGoField?.GetValue(obj);
					GameObject val = (GameObject)((obj2 is GameObject) ? obj2 : null);
					if (val == null)
					{
						continue;
					}
					Transform obj3 = val.transform.Find("binding");
					TMP_Text val2 = ((obj3 != null) ? ((Component)obj3).GetComponent<TMP_Text>() : null);
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					hashSet.Add(x);
					if (___m_item.m_shared.m_maxQuality <= 1)
					{
						if (hotkeyStarLabels.TryGetValue(obj, out var value) && (Object)(object)value != (Object)null)
						{
							((Component)value).gameObject.SetActive(false);
						}
						continue;
					}
					TMP_Text orCreateHotkeyStarLabel = GetOrCreateHotkeyStarLabel(obj, val2);
					((Component)orCreateHotkeyStarLabel).gameObject.SetActive(true);
					orCreateHotkeyStarLabel.fontSize = HotbarStarFontSize.Value;
					orCreateHotkeyStarLabel.text = StarText(___m_item.m_quality);
					((Graphic)orCreateHotkeyStarLabel).color = StarColor;
					LogVisibilityChangeDiagnostic(orCreateHotkeyStarLabel);
				}
				for (int i = 0; i < ___m_elements.Count; i++)
				{
					if (!hashSet.Contains(i) && ___m_elements[i] != null && hotkeyStarLabels.TryGetValue(___m_elements[i], out var value2) && (Object)(object)value2 != (Object)null)
					{
						((Component)value2).gameObject.SetActive(false);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Interact")]
		private static class Player_Interact_MassFarming_Patch
		{
			private static readonly FieldInfo InteractMaskField = AccessTools.Field(typeof(Player), "m_interactMask");

			private static readonly MethodInfo BeehiveExtractMethod = AccessTools.Method(typeof(Beehive), "Extract", (Type[])null, (Type[])null);

			private static void Prefix(Player __instance, GameObject go, bool hold, bool alt)
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				if (!MassFarmingEnabled.Value || hold || ((Character)__instance).InAttack() || ((Character)__instance).InDodge())
				{
					return;
				}
				KeyboardShortcut value = MassFarmingKey.Value;
				if (!((KeyboardShortcut)(ref value)).IsPressed())
				{
					return;
				}
				Interactable componentInParent = go.GetComponentInParent<Interactable>();
				int num = (int)InteractMaskField.GetValue(__instance);
				float value2 = MassFarmingRange.Value;
				Pickable val = (Pickable)(object)((componentInParent is Pickable) ? componentInParent : null);
				if (val != null)
				{
					Collider[] array = Physics.OverlapSphere(go.transform.position, value2, num);
					foreach (Collider val2 in array)
					{
						Pickable componentInParent2 = ((Component)val2).gameObject.GetComponentInParent<Pickable>();
						if (componentInParent2 != null && (Object)(object)componentInParent2 != (Object)(object)val && ((Object)componentInParent2.m_itemPrefab).name == ((Object)val.m_itemPrefab).name)
						{
							componentInParent2.Interact((Humanoid)(object)__instance, false, alt);
						}
					}
					return;
				}
				Beehive val3 = (Beehive)(object)((componentInParent is Beehive) ? componentInParent : null);
				if (val3 == null)
				{
					return;
				}
				Collider[] array2 = Physics.OverlapSphere(go.transform.position, value2, num);
				foreach (Collider val4 in array2)
				{
					Beehive componentInParent3 = ((Component)val4).gameObject.GetComponentInParent<Beehive>();
					if (componentInParent3 != null && (Object)(object)componentInParent3 != (Object)(object)val3 && PrivateArea.CheckAccess(((Component)componentInParent3).transform.position, 0f, true, false))
					{
						BeehiveExtractMethod.Invoke(componentInParent3, null);
					}
				}
			}
		}

		[HarmonyPatch]
		private static class Player_MassPlant_Patch
		{
			private static readonly FieldInfo NoPlacementCostField = AccessTools.Field(typeof(Player), "m_noPlacementCost");

			private static readonly FieldInfo PlacementGhostField = AccessTools.Field(typeof(Player), "m_placementGhost");

			private static readonly FieldInfo BuildPiecesField = AccessTools.Field(typeof(Player), "m_buildPieces");

			private static readonly MethodInfo GetRightItemMethod = AccessTools.Method(typeof(Humanoid), "GetRightItem", (Type[])null, (Type[])null);

			private static Vector3 placedPosition;

			private static Quaternion placedRotation;

			private static Piece placedPiece;

			private static bool placeSuccessful;

			private static int? savedRotation;

			private static GameObject[] ghosts = (GameObject[])(object)new GameObject[1];

			private static Piece fakeResourcePiece;

			private static readonly int PlantSpaceMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "piece_nonsolid" });

			private static bool HotkeyPressed
			{
				get
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					int result;
					if (MassFarmingEnabled.Value)
					{
						KeyboardShortcut value = MassFarmingKey.Value;
						result = (((KeyboardShortcut)(ref value)).IsPressed() ? 1 : 0);
					}
					else
					{
						result = 0;
					}
					return (byte)result != 0;
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(Player), "TryPlacePiece")]
			private static void TryPlacePiecePrefix(int ___m_placeRotation)
			{
				if (HotkeyPressed)
				{
					int? num = savedRotation;
					if (!num.HasValue)
					{
						savedRotation = ___m_placeRotation;
					}
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(Player), "TryPlacePiece")]
			private static void TryPlacePiecePostfix(Player __instance, ref bool __result, Piece piece, ref int ___m_placeRotation)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Expected O, but got Unknown
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				placeSuccessful = __result;
				if (__result)
				{
					GameObject val = (GameObject)PlacementGhostField.GetValue(__instance);
					placedPosition = val.transform.position;
					placedRotation = val.transform.rotation;
					placedPiece = piece;
				}
				if (HotkeyPressed && savedRotation.HasValue)
				{
					___m_placeRotation = savedRotation.Value;
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(Player), "UpdatePlacement")]
			private static void UpdatePlacementPrefix(ref int ___m_placeRotation)
			{
				placeSuccessful = false;
				if (HotkeyPressed && savedRotation.HasValue)
				{
					___m_placeRotation = savedRotation.Value;
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(Player), "UpdatePlacement")]
			private static void UpdatePlacementPostfix(Player __instance, int ___m_placeRotation)
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_018a: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0258: Unknown result type (might be due to invalid IL or missing references)
				if (HotkeyPressed)
				{
					savedRotation = ___m_placeRotation;
				}
				if (!placeSuccessful || (Object)(object)placedPiece == (Object)null || !HotkeyPressed)
				{
					return;
				}
				Plant component = ((Component)placedPiece).GetComponent<Plant>();
				if ((Object)(object)component == (Object)null)
				{
					return;
				}
				Heightmap val = Heightmap.FindHeightmap(placedPosition);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				foreach (Vector3 item in BuildGridPositions(placedPosition, component, placedRotation))
				{
					if ((placedPiece.m_cultivatedGroundOnly && !val.IsCultivated(item)) || item == placedPosition || !HasGrowSpace(item, ((Component)placedPiece).gameObject))
					{
						continue;
					}
					object? obj = GetRightItemMethod.Invoke(__instance, null);
					ItemData val2 = (ItemData)((obj is ItemData) ? obj : null);
					if (val2 == null)
					{
						continue;
					}
					if (!((Character)__instance).HaveStamina(val2.m_shared.m_attack.m_attackStamina))
					{
						Hud.instance.StaminaBarUppgradeFlash();
						break;
					}
					if (!(bool)NoPlacementCostField.GetValue(__instance) && !__instance.HaveRequirements(placedPiece, (RequirementMode)0))
					{
						break;
					}
					GameObject val3 = Object.Instantiate<GameObject>(((Component)placedPiece).gameObject, item, placedRotation);
					Piece component2 = val3.GetComponent<Piece>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.SetCreator(__instance.GetPlayerID(), ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID);
					}
					placedPiece.m_placeEffect.Create(item, placedRotation, val3.transform, 1f, -1, default(ZDOID));
					Game.instance.IncrementPlayerStat((PlayerStatType)2, 1f, false);
					__instance.ConsumeResources(placedPiece.m_resources, 0, -1, 1);
					((Character)__instance).UseStamina(val2.m_shared.m_attack.m_attackStamina);
					object? value = BuildPiecesField.GetValue(__instance);
					PieceTable val4 = (PieceTable)((value is PieceTable) ? value : null);
					if (val4 != null)
					{
						((Character)__instance).RaiseSkill(val4.m_skill, 1f);
					}
					if (val2.m_shared.m_useDurability)
					{
						val2.m_durability -= val2.m_shared.m_useDurabilityDrain;
						if (val2.m_durability <= 0f)
						{
							break;
						}
					}
				}
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(Player), "SetupPlacementGhost")]
			private static void SetupPlacementGhostPrefix(int ___m_placeRotation)
			{
				if (HotkeyPressed)
				{
					int? num = savedRotation;
					if (!num.HasValue)
					{
						savedRotation = ___m_placeRotation;
					}
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(Player), "SetupPlacementGhost")]
			private static void SetupPlacementGhostPostfix(ref int ___m_placeRotation)
			{
				if (HotkeyPressed && savedRotation.HasValue)
				{
					___m_placeRotation = savedRotation.Value;
				}
				DestroyGhosts();
			}

			[HarmonyPostfix]
			[HarmonyPatch(typeof(Player), "UpdatePlacementGhost")]
			private static void UpdatePlacementGhostPostfix(Player __instance)
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Expected O, but got Unknown
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_020c: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = (GameObject)PlacementGhostField.GetValue(__instance);
				if ((Object)(object)val == (Object)null || !val.activeSelf || !HotkeyPressed)
				{
					SetGhostsActive(active: false);
					return;
				}
				Plant component = val.GetComponent<Plant>();
				if ((Object)(object)component == (Object)null)
				{
					SetGhostsActive(active: false);
					return;
				}
				if (!EnsureGhostsBuilt(__instance))
				{
					SetGhostsActive(active: false);
					return;
				}
				Piece component2 = val.GetComponent<Piece>();
				Requirement val2 = null;
				Requirement[] resources = component2.m_resources;
				foreach (Requirement val3 in resources)
				{
					if ((Object)(object)val3.m_resItem != (Object)null && val3.m_amount > 0)
					{
						val2 = val3;
						break;
					}
				}
				float num = __instance.GetStamina();
				object? obj = GetRightItemMethod.Invoke(__instance, null);
				ItemData val4 = (ItemData)((obj is ItemData) ? obj : null);
				if (val4 == null)
				{
					return;
				}
				Heightmap val5 = Heightmap.FindHeightmap(val.transform.position);
				List<Vector3> list = BuildGridPositions(val.transform.position, component, val.transform.rotation);
				for (int j = 0; j < ghosts.Length; j++)
				{
					Vector3 val6 = list[j];
					if (val.transform.position == val6)
					{
						ghosts[j].SetActive(false);
						continue;
					}
					if (val2 != null)
					{
						Requirement obj2 = fakeResourcePiece.m_resources[0];
						obj2.m_amount += val2.m_amount;
					}
					ghosts[j].transform.position = val6;
					ghosts[j].transform.rotation = val.transform.rotation;
					ghosts[j].SetActive(true);
					bool invalidPlacementHeightlight = false;
					if (component2.m_cultivatedGroundOnly && ((Object)(object)val5 == (Object)null || !val5.IsCultivated(val6)))
					{
						invalidPlacementHeightlight = true;
					}
					else if (!HasGrowSpace(val6, val.gameObject))
					{
						invalidPlacementHeightlight = true;
					}
					else if (num < val4.m_shared.m_attack.m_attackStamina)
					{
						invalidPlacementHeightlight = true;
					}
					else if (val2 != null && !(bool)NoPlacementCostField.GetValue(__instance) && !__instance.HaveRequirements(fakeResourcePiece, (RequirementMode)0))
					{
						invalidPlacementHeightlight = true;
					}
					num -= val4.m_shared.m_attack.m_attackStamina;
					ghosts[j].GetComponent<Piece>().SetInvalidPlacementHeightlight(invalidPlacementHeightlight);
				}
			}

			private static List<Vector3> BuildGridPositions(Vector3 origin, Plant plant, Quaternion rotation)
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				float num = plant.m_growRadius * 2f;
				int num2 = Mathf.Max(1, MassPlantGridWidth.Value);
				int num3 = Mathf.Max(1, MassPlantGridLength.Value);
				List<Vector3> list = new List<Vector3>(num2 * num3);
				Vector3 val = rotation * Vector3.left * num;
				Vector3 val2 = rotation * Vector3.forward * num;
				Vector3 val3 = origin - val2 * (float)(num3 / 2) - val * (float)(num2 / 2);
				for (int i = 0; i < num3; i++)
				{
					Vector3 val4 = val3;
					for (int j = 0; j < num2; j++)
					{
						val4.y = ZoneSystem.instance.GetGroundHeight(val4);
						list.Add(val4);
						val4 += val;
					}
					val3 += val2;
				}
				return list;
			}

			private static bool HasGrowSpace(Vector3 pos, GameObject go)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				Plant component = go.GetComponent<Plant>();
				if (component != null)
				{
					Collider[] array = Physics.OverlapSphere(pos, component.m_growRadius, PlantSpaceMask);
					return array.Length == 0;
				}
				return true;
			}

			private static bool EnsureGhostsBuilt(Player player)
			{
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0124: Expected O, but got Unknown
				int num = Mathf.Max(1, MassPlantGridWidth.Value) * Mathf.Max(1, MassPlantGridLength.Value);
				if (ghosts.Length == 0 || (Object)(object)ghosts[0] == (Object)null || ghosts.Length != num)
				{
					DestroyGhosts();
					ghosts = (GameObject[])(object)new GameObject[num];
					object? value = BuildPiecesField.GetValue(player);
					PieceTable val = (PieceTable)((value is PieceTable) ? value : null);
					if (val != null)
					{
						GameObject selectedPrefab = val.GetSelectedPrefab();
						if (selectedPrefab != null)
						{
							if (selectedPrefab.GetComponent<Piece>().m_repairPiece)
							{
								return false;
							}
							for (int i = 0; i < ghosts.Length; i++)
							{
								ghosts[i] = BuildGhost(selectedPrefab);
							}
							goto IL_00df;
						}
					}
					return false;
				}
				goto IL_00df;
				IL_00df:
				if ((Object)(object)fakeResourcePiece == (Object)null)
				{
					fakeResourcePiece = ghosts[0].GetComponent<Piece>();
					fakeResourcePiece.m_dlc = string.Empty;
					fakeResourcePiece.m_resources = (Requirement[])(object)new Requirement[1]
					{
						new Requirement()
					};
				}
				return true;
			}

			private static void DestroyGhosts()
			{
				for (int i = 0; i < ghosts.Length; i++)
				{
					if ((Object)(object)ghosts[i] != (Object)null)
					{
						Object.Destroy((Object)(object)ghosts[i]);
						ghosts[i] = null;
					}
				}
				fakeResourcePiece = null;
			}

			private static void SetGhostsActive(bool active)
			{
				GameObject[] array = ghosts;
				foreach (GameObject val in array)
				{
					if (val != null)
					{
						val.SetActive(active);
					}
				}
			}

			private static GameObject BuildGhost(GameObject prefab)
			{
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a5: Expected O, but got Unknown
				ZNetView.m_forceDisableInit = true;
				GameObject val = Object.Instantiate<GameObject>(prefab);
				ZNetView.m_forceDisableInit = false;
				((Object)val).name = ((Object)prefab).name;
				Joint[] componentsInChildren = val.GetComponentsInChildren<Joint>();
				foreach (Joint val2 in componentsInChildren)
				{
					Object.Destroy((Object)(object)val2);
				}
				Rigidbody[] componentsInChildren2 = val.GetComponentsInChildren<Rigidbody>();
				foreach (Rigidbody val3 in componentsInChildren2)
				{
					Object.Destroy((Object)(object)val3);
				}
				int layer = LayerMask.NameToLayer("ghost");
				Transform[] componentsInChildren3 = val.GetComponentsInChildren<Transform>();
				foreach (Transform val4 in componentsInChildren3)
				{
					((Component)val4).gameObject.layer = layer;
				}
				TerrainModifier[] componentsInChildren4 = val.GetComponentsInChildren<TerrainModifier>();
				foreach (TerrainModifier val5 in componentsInChildren4)
				{
					Object.Destroy((Object)(object)val5);
				}
				GuidePoint[] componentsInChildren5 = val.GetComponentsInChildren<GuidePoint>();
				foreach (GuidePoint val6 in componentsInChildren5)
				{
					Object.Destroy((Object)(object)val6);
				}
				Light[] componentsInChildren6 = val.GetComponentsInChildren<Light>();
				foreach (Light val7 in componentsInChildren6)
				{
					Object.Destroy((Object)(object)val7);
				}
				Transform val8 = val.transform.Find("_GhostOnly");
				if ((Object)(object)val8 != (Object)null)
				{
					((Component)val8).gameObject.SetActive(true);
				}
				MeshRenderer[] componentsInChildren7 = val.GetComponentsInChildren<MeshRenderer>();
				foreach (MeshRenderer val9 in componentsInChildren7)
				{
					if (!((Object)(object)((Renderer)val9).sharedMaterial == (Object)null))
					{
						Material[] sharedMaterials = ((Renderer)val9).sharedMaterials;
						for (int num2 = 0; num2 < sharedMaterials.Length; num2++)
						{
							Material val10 = new Material(sharedMaterials[num2]);
							val10.SetFloat("_RippleDistance", 0f);
							val10.SetFloat("_ValueNoise", 0f);
							sharedMaterials[num2] = val10;
						}
						((Renderer)val9).sharedMaterials = sharedMaterials;
						((Renderer)val9).shadowCastingMode = (ShadowCastingMode)0;
					}
				}
				return val;
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "UpdateRecipe")]
		private static class InventoryGui_UpdateRecipe_MultiCraft_Patch
		{
			private static void Prefix(InventoryGui __instance, ref bool ___m_touchMultiCrafting)
			{
				if (MultiCraftEnabled.Value)
				{
					MultiCraft_HandleScroll(__instance);
					___m_touchMultiCrafting = multiCraftDesiredAmount > 1;
					if (multiCraftDesiredAmount > 1)
					{
						__instance.m_multiCraftAmount = multiCraftDesiredAmount;
					}
				}
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "OnCraftPressed")]
		private static class InventoryGui_OnCraftPressed_MultiCraft_Patch
		{
			private static void Prefix(InventoryGui __instance, ref bool ___m_touchMultiCrafting)
			{
				if (MultiCraftEnabled.Value)
				{
					___m_touchMultiCrafting = multiCraftDesiredAmount > 1;
					if (multiCraftDesiredAmount > 1)
					{
						__instance.m_multiCraftAmount = multiCraftDesiredAmount;
					}
				}
			}
		}

		private static class ExtraSlotsCompat
		{
			private static bool resolved;

			private static readonly List<Func<IEnumerable>> Getters = new List<Func<IEnumerable>>();

			private static void Resolve()
			{
				resolved = true;
				Type type = AccessTools.TypeByName("ExtraSlots.API");
				if (type == null)
				{
					return;
				}
				string[] array = new string[5] { "GetQuickSlotsItems", "GetMiscSlotsItems", "GetAmmoSlotsItems", "GetFoodSlotsItems", "GetEquipmentSlotsItems" };
				foreach (string text in array)
				{
					MethodInfo method = AccessTools.Method(type, text, Type.EmptyTypes, (Type[])null);
					if (method != null)
					{
						Getters.Add(() => method.Invoke(null, null) as IEnumerable);
					}
				}
			}

			internal static HashSet<ItemData> GetProtectedItems()
			{
				if (!resolved)
				{
					Resolve();
				}
				HashSet<ItemData> hashSet = new HashSet<ItemData>();
				foreach (Func<IEnumerable> getter in Getters)
				{
					IEnumerable enumerable;
					try
					{
						enumerable = getter();
					}
					catch
					{
						continue;
					}
					if (enumerable == null)
					{
						continue;
					}
					foreach (object item in enumerable)
					{
						ItemData val = (ItemData)((item is ItemData) ? item : null);
						if (val != null)
						{
							hashSet.Add(val);
						}
					}
				}
				return hashSet;
			}
		}

		[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
		{
			typeof(Recipe),
			typeof(bool),
			typeof(int),
			typeof(int)
		})]
		private static class Player_HaveRequirements_Recipe_NearbyCrafting_Patch
		{
			private static void Prefix()
			{
				if (NearbyCraftingEnabled.Value)
				{
					nearbyCraftingCheckActive = true;
				}
			}

			private static void Postfix()
			{
				nearbyCraftingCheckActive = false;
			}
		}

		[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
		{
			typeof(Piece),
			typeof(RequirementMode)
		})]
		private static class Player_HaveRequirements_Piece_NearbyCrafting_Patch
		{
			private static void Prefix()
			{
				if (NearbyBuildingEnabled.Value)
				{
					nearbyCraftingCheckActive = true;
				}
			}

			private static void Postfix()
			{
				nearbyCraftingCheckActive = false;
			}
		}

		[HarmonyPatch(typeof(Inventory), "CountItems")]
		private static class Inventory_CountItems_NearbyCrafting_Patch
		{
			private static void Postfix(Inventory __instance, string name, int quality, bool matchWorldLevel, ref int __result)
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				if (!nearbyCraftingCheckActive || name == null)
				{
					return;
				}
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null || __instance != ((Humanoid)localPlayer).GetInventory())
				{
					return;
				}
				foreach (Container nearbyContainer in GetNearbyContainers(((Component)localPlayer).transform.position))
				{
					__result += nearbyContainer.GetInventory().CountItems(name, quality, matchWorldLevel);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "ConsumeResources")]
		private static class Player_ConsumeResources_NearbyCrafting_Patch
		{
			private static Dictionary<string, int> preCounts;

			private static bool RequirementApplies(Player player, Requirement requirement)
			{
				if ((Object)(object)requirement.m_resItem == (Object)null)
				{
					return false;
				}
				CraftingStation currentCraftingStation = player.GetCurrentCraftingStation();
				if ((Object)(object)currentCraftingStation != (Object)null && currentCraftingStation.m_upgrader != requirement.m_upgraderResource)
				{
					return false;
				}
				if ((Object)(object)currentCraftingStation == (Object)null && requirement.m_upgraderResource)
				{
					return false;
				}
				return true;
			}

			private static void Prefix(Player __instance, Requirement[] requirements, int itemQuality)
			{
				preCounts = null;
				if (!NearbyCraftingEnabled.Value && !NearbyBuildingEnabled.Value)
				{
					return;
				}
				preCounts = new Dictionary<string, int>();
				foreach (Requirement val in requirements)
				{
					if (RequirementApplies(__instance, val))
					{
						string name = val.m_resItem.m_itemData.m_shared.m_name;
						if (!preCounts.ContainsKey(name))
						{
							preCounts[name] = ((Humanoid)__instance).GetInventory().CountItems(name, itemQuality, true);
						}
					}
				}
			}

			private static void Postfix(Player __instance, Requirement[] requirements, int qualityLevel, int itemQuality, int multiplier)
			{
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				if (preCounts == null)
				{
					return;
				}
				List<Container> list = null;
				foreach (Requirement val in requirements)
				{
					if (!RequirementApplies(__instance, val))
					{
						continue;
					}
					int num = val.GetAmount(qualityLevel) * multiplier;
					if (num <= 0)
					{
						continue;
					}
					string name = val.m_resItem.m_itemData.m_shared.m_name;
					int value;
					int num2 = (preCounts.TryGetValue(name, out value) ? value : 0);
					int num3 = num - Mathf.Min(num, num2);
					if (num3 <= 0)
					{
						continue;
					}
					if (list == null)
					{
						list = GetNearbyContainers(((Component)__instance).transform.position);
					}
					foreach (Container item in list)
					{
						if (num3 <= 0)
						{
							break;
						}
						Inventory inventory = item.GetInventory();
						int num4 = inventory.CountItems(name, itemQuality, true);
						if (num4 > 0)
						{
							int num5 = Mathf.Min(num4, num3);
							inventory.RemoveItem(name, num5, itemQuality, true);
							num3 -= num5;
						}
					}
				}
				preCounts = null;
			}
		}

		[HarmonyPatch(typeof(EnvMan), "SetEnv")]
		private static class EnvMan_SetEnv_NightBrightness_Patch
		{
			private static void Postfix(EnvMan __instance, EnvSetup env, float nightInt)
			{
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				if (NightBrightnessEnabled.Value && !(nightInt <= 0f))
				{
					float num = (MoonlightIntensityMultiplier.Value - 1f) * nightInt;
					if (num != 0f)
					{
						Light dirLight = __instance.m_dirLight;
						dirLight.intensity += env.m_lightIntensityNight * num;
						Light dirLight2 = __instance.m_dirLight;
						dirLight2.color += env.m_sunColorNight * num;
					}
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class ZNetScene_Awake_PlantEverything_Patch
		{
			private static void Postfix()
			{
				if (!PlantEverythingEnabled.Value)
				{
					return;
				}
				GameObject prefab = ZNetScene.instance.GetPrefab("Cultivator");
				PieceTable val = ((prefab == null) ? null : prefab.GetComponent<ItemDrop>()?.m_itemData?.m_shared?.m_buildPieces);
				if ((Object)(object)val == (Object)null)
				{
					ZenoxPlugin instance = Instance;
					if (instance != null)
					{
						((BaseUnityPlugin)instance).Logger.LogWarning((object)"[Zenox] PlantEverything: couldn't find the Cultivator's piece table, feature disabled this session.");
					}
					return;
				}
				int num = 0;
				foreach (GameObject item in FindLootablePrefabs())
				{
					GameObject val2 = BuildPlantableClone(item);
					if (!((Object)(object)val2 == (Object)null))
					{
						RegisterPrefab(val2);
						val.m_pieces.Add(val2);
						num++;
						ZenoxPlugin instance2 = Instance;
						if (instance2 != null)
						{
							((BaseUnityPlugin)instance2).Logger.LogInfo((object)("[Zenox] PlantEverything: made '" + ((Object)item).name + "' plantable."));
						}
					}
				}
				AddHiddenSaplings(val);
				GameObject prefab2 = ZNetScene.instance.GetPrefab("Wood");
				ItemDrop val3 = ((prefab2 != null) ? prefab2.GetComponent<ItemDrop>() : null);
				GameObject prefab3 = ZNetScene.instance.GetPrefab("Dandelion");
				ItemDrop val4 = ((prefab3 != null) ? prefab3.GetComponent<ItemDrop>() : null);
				Sprite val5 = ((val3 != null) ? val3.m_itemData.GetIcon() : null);
				Sprite val6 = (((Object)(object)val4 != (Object)null) ? val4.m_itemData.GetIcon() : val5);
				if ((Object)(object)val3 != (Object)null)
				{
					string[] decorativeFloraNames = DecorativeFloraNames;
					foreach (string text in decorativeFloraNames)
					{
						GameObject prefab4 = ZNetScene.instance.GetPrefab(text);
						if ((Object)(object)prefab4 == (Object)null)
						{
							ZenoxPlugin instance3 = Instance;
							if (instance3 != null)
							{
								((BaseUnityPlugin)instance3).Logger.LogWarning((object)("[Zenox] PlantEverything: decorative prefab '" + text + "' not found, skipping."));
							}
							continue;
						}
						bool flag = text.Contains("Tree") || text.StartsWith("Ygga") || text.StartsWith("Yggdrasil");
						GameObject val7 = BuildDecorationClone(prefab4, val3, flag ? 5 : 2, flag ? val5 : val6);
						RegisterPrefab(val7);
						val.m_pieces.Add(val7);
						num++;
						ZenoxPlugin instance4 = Instance;
						if (instance4 != null)
						{
							((BaseUnityPlugin)instance4).Logger.LogInfo((object)("[Zenox] PlantEverything: made decorative '" + text + "' plantable."));
						}
					}
					string[] existingFloraPieces = ExistingFloraPieces;
					foreach (string text2 in existingFloraPieces)
					{
						GameObject prefab5 = ZNetScene.instance.GetPrefab(text2);
						if (!((Object)(object)prefab5 == (Object)null) && !val.m_pieces.Contains(prefab5))
						{
							val.m_pieces.Add(prefab5);
							num++;
							ZenoxPlugin instance5 = Instance;
							if (instance5 != null)
							{
								((BaseUnityPlugin)instance5).Logger.LogInfo((object)("[Zenox] PlantEverything: exposed existing piece '" + text2 + "' in the Cultivator."));
							}
						}
					}
				}
				ZenoxPlugin instance6 = Instance;
				if (instance6 != null)
				{
					((BaseUnityPlugin)instance6).Logger.LogInfo((object)$"[Zenox] PlantEverything: added {num} plantable resource(s) to the Cultivator.");
				}
			}
		}

		[HarmonyPatch(typeof(Plant), "GetHoverText")]
		private static class Plant_GetHoverText_GrowTime_Patch
		{
			private static void Postfix(Plant __instance, ZNetView ___m_nview, int ___m_seed, ref string __result)
			{
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				if (ShowPlantGrowTime.Value && !string.IsNullOrEmpty(__result) && !((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid())
				{
					ZDO zDO = ___m_nview.GetZDO();
					DateTime dateTime = new DateTime(zDO.GetLong(ZDOVars.s_plantTime, ZNet.instance.GetTime().Ticks));
					double totalSeconds = (ZNet.instance.GetTime() - dateTime).TotalSeconds;
					State state = Random.state;
					Random.InitState(___m_seed);
					float value = Random.value;
					Random.state = state;
					float num = Mathf.Lerp(__instance.m_growTime, __instance.m_growTimeMax, value);
					double num2 = (double)num - totalSeconds;
					__result += ((num2 > 0.0) ? ("\n" + FormatDuration(num2) + " remaining") : "\nReady to grow");
				}
			}
		}

		[HarmonyPatch(typeof(Pickable), "GetHoverText")]
		private static class Pickable_GetHoverText_RespawnTime_Patch
		{
			private static void Postfix(Pickable __instance, ZNetView ___m_nview, bool ___m_picked, ref string __result)
			{
				if (ShowPlantGrowTime.Value && ___m_picked && !(__instance.m_respawnTimeMinutes <= 0f) && !((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid())
				{
					long num = ___m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L);
					if (num > 1)
					{
						double totalMinutes = (ZNet.instance.GetTime() - new DateTime(num)).TotalMinutes;
						double num2 = ((double)__instance.m_respawnTimeMinutes - totalMinutes) * 60.0;
						__result = __instance.GetHoverName() + ((num2 > 0.0) ? ("\n( Regrowing, " + FormatDuration(num2) + " remaining )") : "\n( Ready )");
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "TeleportTo")]
		private static class Player_TeleportTo_PortalCompanions_Patch
		{
			private static void Postfix(Player __instance, Vector3 pos, Quaternion rot, bool __result)
			{
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0207: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0253: Unknown result type (might be due to invalid IL or missing references)
				if (!__result)
				{
					return;
				}
				if (!PortalTeleportFollowersEnabled.Value)
				{
					ZenoxPlugin instance = Instance;
					if (instance != null)
					{
						((BaseUnityPlugin)instance).Logger.LogInfo((object)"[Zenox PortalCompanions] Teleport triggered, but PortalTeleportFollowersEnabled is false.");
					}
					return;
				}
				Vector3 position = ((Component)__instance).transform.position;
				ZenoxPlugin instance2 = Instance;
				if (instance2 != null)
				{
					((BaseUnityPlugin)instance2).Logger.LogInfo((object)$"[Zenox PortalCompanions] Teleport triggered for '{((Character)__instance).GetHoverName()}', from={position}, target={pos}, range={PortalTeleportRange.Value}.");
				}
				List<Character> followingAllies = GetFollowingAllies(position, PortalTeleportRange.Value, ((Component)__instance).gameObject);
				ZenoxPlugin instance3 = Instance;
				if (instance3 != null)
				{
					((BaseUnityPlugin)instance3).Logger.LogInfo((object)$"[Zenox PortalCompanions] {followingAllies.Count} following ally/allies found near teleport-from position.");
				}
				for (int i = 0; i < followingAllies.Count; i++)
				{
					Character val = followingAllies[i];
					ZNetView component = ((Component)val).GetComponent<ZNetView>();
					if ((Object)(object)component == (Object)null || !component.IsValid())
					{
						ZenoxPlugin instance4 = Instance;
						if (instance4 != null)
						{
							((BaseUnityPlugin)instance4).Logger.LogInfo((object)("[Zenox PortalCompanions] '" + ((Object)val).name + "' skipped: no valid ZNetView."));
						}
						continue;
					}
					if (!component.IsOwner())
					{
						component.ClaimOwnership();
					}
					Vector3 val2 = new Vector3(Random.Range(-1f, 1f), 0f, Random.Range(-1f, 1f)) * (1f + (float)i * 0.5f);
					Vector3 val3 = pos + val2;
					Rigidbody component2 = ((Component)val).GetComponent<Rigidbody>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.position = val3;
						component2.linearVelocity = Vector3.zero;
						component2.angularVelocity = Vector3.zero;
					}
					((Component)val).transform.position = val3;
					((Component)val).transform.rotation = rot;
					if ((Object)(object)component2 != (Object)null)
					{
						Physics.SyncTransforms();
					}
					ZDO zDO = component.GetZDO();
					if (zDO != null)
					{
						zDO.SetPosition(val3);
					}
					ZenoxPlugin instance5 = Instance;
					if (instance5 != null)
					{
						((BaseUnityPlugin)instance5).Logger.LogInfo((object)$"[Zenox PortalCompanions] Teleported '{((Object)val).name}' to {val3}.");
					}
				}
			}
		}

		[HarmonyPatch(typeof(TeleportWorld), "GetHoverText")]
		private static class TeleportWorld_GetHoverText_AllyCount_Patch
		{
			private static void Postfix(TeleportWorld __instance, ref string __result)
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				if (ShowPortalAllyCount.Value && !string.IsNullOrEmpty(__result) && !((Object)(object)Player.m_localPlayer == (Object)null))
				{
					int count = GetFollowingAllies(((Component)__instance).transform.position, PortalTeleportRange.Value, ((Component)Player.m_localPlayer).gameObject).Count;
					if (count > 0)
					{
						__result += $"\n{count} companion(s) nearby would teleport with you";
					}
				}
			}
		}

		[HarmonyPatch(typeof(TeleportWorld), "Awake")]
		private static class TeleportWorld_Awake_Patch
		{
			private static void Postfix(TeleportWorld __instance)
			{
				if ((Object)(object)Instance != (Object)null)
				{
					Instance.RegisterPortal(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "SetParticleArrayEnabled")]
		private static class EnvMan_SetParticleArrayEnabled_RainFog_Patch
		{
			private static void Postfix(GameObject[] psystems, bool enabled)
			{
				if (!enabled || psystems == null || !DisableWeatherFog.Value)
				{
					return;
				}
				foreach (GameObject val in psystems)
				{
					if (!((Object)(object)val == (Object)null))
					{
						string text = ((Object)val).name.ToLowerInvariant();
						bool flag = text.Contains("mist") || text.Contains("fog");
						if (flag)
						{
							val.SetActive(false);
						}
						ZenoxPlugin instance = Instance;
						if (instance != null)
						{
							((BaseUnityPlugin)instance).Logger.LogInfo((object)$"[Zenox RainFogDiag] psystem '{((Object)val).name}' isFogMatch={flag} activeSelf(after)={val.activeSelf}");
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnvMan), "SetEnv")]
		private static class EnvMan_SetEnv_RainFogDiag_Patch
		{
			private static void Postfix()
			{
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				if (DisableWeatherFog.Value && !(Time.time - lastFogDensityLogTime < 2f))
				{
					lastFogDensityLogTime = Time.time;
					ZenoxPlugin instance = Instance;
					if (instance != null)
					{
						((BaseUnityPlugin)instance).Logger.LogInfo((object)$"[Zenox RainFogDiag] RenderSettings.fogDensity={RenderSettings.fogDensity}, fogColor={RenderSettings.fogColor}, fog(enabled)={RenderSettings.fog}");
					}
				}
			}
		}

		[HarmonyPatch(typeof(Ship), "GetWindAngleFactor")]
		[HarmonyPriority(0)]
		private static class Ship_GetWindAngleFactor_Patch
		{
			private static void Postfix(Ship __instance, ref float __result)
			{
				if (TailwindEnabled.Value && __instance.IsOwner())
				{
					__result = 1f;
				}
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		private static class FejdStartup_Awake_Patch
		{
			private static void Postfix(FejdStartup __instance)
			{
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Expected O, but got Unknown
				if (!ServerButtonEnabled.Value)
				{
					return;
				}
				Button[] componentsInChildren = __instance.m_menuList.GetComponentsInChildren<Button>(true);
				if (componentsInChildren.Length != 0)
				{
					Button val = componentsInChildren[0];
					Button val2 = Object.Instantiate<Button>(val, ((Component)val).transform.parent);
					((Object)val2).name = "ZenoxServerButton";
					TMP_Text componentInChildren = ((Component)val2).GetComponentInChildren<TMP_Text>(true);
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.text = ServerButtonLabel.Value;
					}
					((UnityEventBase)val2.onClick).RemoveAllListeners();
					((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
					{
						ConnectToConfiguredServer(__instance);
					});
					((Component)val2).transform.SetSiblingIndex(0);
				}
			}
		}

		[HarmonyPatch(typeof(CinematicsManager), "Play", new Type[]
		{
			typeof(Settings),
			typeof(VideoCompleteAction)
		})]
		private static class CinematicsManager_Play_Patch
		{
			private static bool Prefix(Settings firstWithSetting, ref bool __result)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Invalid comparison between Unknown and I4
				if (!SkipIntroVideo.Value)
				{
					return true;
				}
				if ((int)firstWithSetting != 2)
				{
					return true;
				}
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateTeleport")]
		private static class Player_UpdateTeleport_Speedup_Patch
		{
			private static void Prefix(ref float dt, bool ___m_teleporting)
			{
				if (TeleportSpeedupEnabled.Value && ___m_teleporting)
				{
					dt *= TeleportSpeedMultiplier.Value;
				}
			}
		}

		[HarmonyPatch(typeof(TreeBase), "RPC_Damage")]
		private static class TreeBase_RPC_Damage_Replant_Patch
		{
			private static bool hasSnapshot;

			private static GameObject sapling;

			private static int stubHash;

			private static Vector3 position;

			private static Quaternion rotation;

			private static void Prefix(TreeBase __instance)
			{
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				hasSnapshot = false;
				if (!AutoReplantTrees.Value)
				{
					return;
				}
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid())
				{
					return;
				}
				GameObject prefab = ZNetScene.instance.GetPrefab(component.GetZDO().GetPrefab());
				if (!((Object)(object)prefab == (Object)null))
				{
					sapling = FindSaplingFor(prefab);
					if (!((Object)(object)sapling == (Object)null))
					{
						stubHash = (((Object)(object)__instance.m_stubPrefab != (Object)null) ? StringExtensionMethods.GetStableHashCode(((Object)__instance.m_stubPrefab).name) : 0);
						position = ((Component)__instance).transform.position;
						rotation = ((Component)__instance).transform.rotation;
						hasSnapshot = true;
					}
				}
			}

			private static void Postfix(TreeBase __instance)
			{
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				if (hasSnapshot && AutoReplantTrees.Value && !((Component)__instance).gameObject.activeSelf)
				{
					Instance?.pendingReplants.Add((Time.time + 3f, sapling, position, rotation, stubHash));
				}
			}
		}

		[HarmonyPatch(typeof(Achievements), "IsCheatedAtAll")]
		private static class Achievements_IsCheatedAtAll_Patch
		{
			private static void Postfix(ref bool __result)
			{
			}
		}

		[HarmonyPatch(typeof(Inventory), "Changed")]
		private static class Inventory_Changed_SuppressCheatPopup_Patch
		{
			private static void Prefix(ref bool cheatedStateChanged)
			{
				cheatedStateChanged = false;
			}
		}

		[HarmonyPatch(typeof(RandEventSystem), "StartRandomEvent")]
		private static class RandEventSystem_StartRandomEvent_Patch
		{
			private static bool Prefix()
			{
				if (!DisableRandomEvents.Value)
				{
					return true;
				}
				ZenoxPlugin instance = Instance;
				if (instance != null)
				{
					((BaseUnityPlugin)instance).Logger.LogInfo((object)"[Zenox] Blocked a random event/raid from starting (DisableRandomEvents is enabled).");
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(EnvMan), "SetEnv")]
		private static class EnvMan_SetEnv_Patch
		{
			private static void Postfix()
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Invalid comparison between Unknown and I4
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Invalid comparison between Unknown and I4
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null))
				{
					Biome currentBiome = localPlayer.GetCurrentBiome();
					if (DisableWeatherFog.Value)
					{
						RenderSettings.fogDensity = 0f;
					}
					else if ((int)currentBiome == 32 && DisableAshlandsFog.Value)
					{
						RenderSettings.fogDensity = 0f;
					}
					else if ((int)currentBiome == 512 && DisableMistlandsFog.Value)
					{
						RenderSettings.fogDensity = 0f;
					}
					SetActiveIfFound("_LocationList_Mistlands(Clone)/environment_effects/FollowPlayer/Mistlands_Globalmist", !DisableMistlandsFog.Value);
					SetActiveIfFound("_LocationList_Mistlands/environment_effects/FollowPlayer/Mistlands_Globalmist", !DisableMistlandsFog.Value);
					SetActiveIfFound("_LocationList_Ashlands(Clone)/environment_effects/FollowPlayer/Ashlands_Misty", !DisableAshlandsFog.Value);
					SetActiveIfFound("_LocationList_Ashlands(Clone)/environment_effects/FollowPlayer/Ashlands_FaderFX", !DisableAshlandsFog.Value);
				}
			}

			private static void SetActiveIfFound(string path, bool active)
			{
				GameObject val = GameObject.Find(path);
				if ((Object)(object)val != (Object)null)
				{
					val.SetActive(active);
				}
			}
		}

		[HarmonyPatch(typeof(DistantFogEmitter), "Update")]
		private static class DistantFogEmitter_Update_Patch
		{
			private static bool Prefix()
			{
				return !DisableDistantFogHaze.Value;
			}
		}

		[HarmonyPatch(typeof(MistEmitter), "Update")]
		private static class MistEmitter_Update_Patch
		{
			private static bool Prefix()
			{
				return !DisableGroundMist.Value;
			}
		}

		[HarmonyPatch(typeof(Ragdoll), "Awake")]
		private static class Ragdoll_Awake_Patch
		{
			private static void Prefix(Ragdoll __instance)
			{
				if (InstantMonsterLootDrop.Value)
				{
					__instance.m_ttl = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		[HarmonyPriority(0)]
		private static class ObjectDB_Awake_DeluxeParticles_Patch
		{
			private static void Postfix()
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				if (!DeluxeItemParticles.Value)
				{
					return;
				}
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name != "main")
				{
					return;
				}
				foreach (GameObject item in ObjectDB.instance.m_items)
				{
					ParticleSystem component = item.GetComponent<ParticleSystem>();
					if (!((Object)(object)component == (Object)null))
					{
						MainModule main = component.main;
						((MainModule)(ref main)).startLifetime = new MinMaxCurve(3f);
						((MainModule)(ref main)).startSize = new MinMaxCurve(0.5f, 0.7f);
						((MainModule)(ref main)).maxParticles = 3;
						EmissionModule emission = component.emission;
						((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(1f);
					}
				}
				ZenoxPlugin instance = Instance;
				if (instance != null)
				{
					((BaseUnityPlugin)instance).Logger.LogInfo((object)"[Zenox] Deluxified item particles.");
				}
			}
		}

		private static float lastDeathTime = float.NegativeInfinity;

		private static float lastBackUseTime = float.NegativeInfinity;

		private static readonly (string GlobalKey, string LocationName, string DisplayName)[] BossProgression = new(string, string, string)[7]
		{
			("defeated_eikthyr", "Eikthyrnir", "Eikthyr"),
			("defeated_gdking", "GDKing", "Der Elite"),
			("defeated_bonemass", "Bonemass", "Bonemass"),
			("defeated_dragon", "Dragonqueen", "Moder"),
			("defeated_goblinking", "GoblinKing", "Yagluth"),
			("defeated_queen", "Mistlands_DvergrBossEntrance1", "Die Königin"),
			("defeated_fader", "FaderLocation", "Fader")
		};

		private string currentBossTarget;

		private PinData bossFinderPin;

		private float bossFinderTimer;

		private bool loggedMissingBossLocation;

		public static ConfigEntry<bool> CharacterXPEnabled;

		private static Player xpPlayer;

		private static double xpUsed;

		private static float xpCurrent;

		public static int CharacterLevel;

		private static GuiBar xpBar;

		public static ConfigEntry<bool> ShowCharacterSelectStats;

		public static ConfigEntry<int> CharacterSelectStatsFontSize;

		public static ConfigEntry<float> CharacterSelectStatsYOffset;

		private static float csNameBaseY = float.NaN;

		public static ConfigEntry<bool> ShowCombinedItemStats;

		private static GameObject combinedStatsOverlay;

		private static UITooltip combinedStatsTooltip;

		private static readonly StringBuilder statsBuilder = new StringBuilder(256);

		public const string PluginGUID = "zenox.zenox";

		public const string PluginName = "Zenox";

		public const string PluginVersion = "1.0.31";

		public static ZenoxPlugin Instance;

		public static ConfigEntry<bool> ModEnabled;

		public static ConfigEntry<float> RangeMultiplier;

		public static ConfigEntry<float> UpdateInterval;

		public static ConfigEntry<bool> IgnoreLockedDoors;

		public static ConfigEntry<float> CloseDelaySeconds;

		public static SyncedValue<bool> TailwindEnabled;

		public static SyncedValue<bool> ClaimShipOwnershipForTailwind;

		public static ConfigEntry<KeyboardShortcut> HideSailKey;

		public static ConfigEntry<float> SailHiddenAlpha;

		public static SyncedValue<bool> PermanentGuardianPower;

		public static ConfigEntry<bool> HideGuardianPowerHUD;

		public static SyncedValue<bool> BossFinderEnabled;

		public static ConfigEntry<float> BossFinderUpdateInterval;

		public static ConfigEntry<bool> ServerButtonEnabled;

		public static ConfigEntry<string> ServerButtonLabel;

		public static ConfigEntry<string> ServerButtonAddress;

		public static ConfigEntry<string> ServerButtonPassword;

		public static ConfigEntry<bool> SkipIntroVideo;

		public static SyncedValue<bool> DisableRandomEvents;

		public static SyncedValue<bool> DisableAshlandsFog;

		public static SyncedValue<bool> DisableMistlandsFog;

		public static SyncedValue<bool> DisableWeatherFog;

		public static SyncedValue<bool> DisableDistantFogHaze;

		public static SyncedValue<bool> DisableGroundMist;

		public static SyncedValue<bool> InstantMonsterLootDrop;

		public static ConfigEntry<bool> DeluxeItemParticles;

		public static SyncedValue<bool> MassFarmingEnabled;

		public static ConfigEntry<KeyboardShortcut> MassFarmingKey;

		public static SyncedValue<float> MassFarmingRange;

		public static SyncedValue<int> MassPlantGridWidth;

		public static SyncedValue<int> MassPlantGridLength;

		public static SyncedValue<bool> NearbyCraftingEnabled;

		public static SyncedValue<bool> NearbyBuildingEnabled;

		public static SyncedValue<float> NearbyContainerRange;

		public static SyncedValue<bool> IgnoreMovingContainers;

		public static SyncedValue<bool> RequirePlayerBuiltContainers;

		public static SyncedValue<bool> QuickDepositEnabled;

		public static ConfigEntry<KeyboardShortcut> QuickDepositKey;

		public static SyncedValue<bool> AutoReplantTrees;

		public static ConfigEntry<bool> BackCommandEnabled;

		public static ConfigEntry<float> BackCommandExpirySeconds;

		public static ConfigEntry<float> BackCommandCooldownSeconds;

		public static SyncedValue<bool> AnimalFeedingEnabled;

		public static ConfigEntry<bool> MultiCraftEnabled;

		public static ConfigEntry<int> MultiCraftMaxAmount;

		public static ConfigEntry<bool> TeleportSpeedupEnabled;

		public static ConfigEntry<float> TeleportSpeedMultiplier;

		public static SyncedValue<bool> NightBrightnessEnabled;

		public static SyncedValue<float> MoonlightIntensityMultiplier;

		public static SyncedValue<bool> PlantEverythingEnabled;

		public static ConfigEntry<string> PlantEverythingExcludedPrefabs;

		public static SyncedValue<bool> ShowPlantGrowTime;

		public static SyncedValue<bool> PortalTeleportFollowersEnabled;

		public static SyncedValue<float> PortalTeleportRange;

		public static SyncedValue<bool> ShowPortalAllyCount;

		private readonly Harmony harmony = new Harmony("zenox.zenox");

		private readonly Dictionary<Door, DoorTracking> trackedDoors = new Dictionary<Door, DoorTracking>();

		private float timeSinceLastCheck;

		public static ConfigEntry<bool> DurabilityColorEnabled;

		private static readonly Color[] DurabilityColors = (Color[])(object)new Color[4]
		{
			new Color(0.11765f, 0.72941f, 0.03529f, 1f),
			new Color(0.72941f, 0.72941f, 0.03529f, 1f),
			new Color(0.72941f, 0.34902f, 0.03529f, 1f),
			new Color(0.72941f, 0.03529f, 0.03529f, 1f)
		};

		private static FieldInfo hotkeyDurabilityField;

		public static ConfigEntry<int> EnemyLevelStyle;

		public static ConfigEntry<bool> ShowEnemyHpText;

		public static ConfigEntry<int> EnemyHpTextFontSize;

		public static ConfigEntry<int> BossHpTextFontSize;

		public static ConfigEntry<float> EnemyHudDistanceMultiplier;

		public static ConfigEntry<bool> ColorEnemyNameByAlertState;

		public static ConfigEntry<float> EnemyHealthBarScale;

		public static ConfigEntry<float> EnemyHealthBarHeightScale;

		public static ConfigEntry<float> EnemyNameYOffset;

		public static ConfigEntry<float> EnemyHpTextGap;

		public static ConfigEntry<float> EnemyUIAlwaysShowDistance;

		public static ConfigEntry<bool> HideEnemyBarBackground;

		private static readonly FieldInfo HudsField = AccessTools.Field(typeof(EnemyHud), "m_huds");

		private static FieldInfo hudDataNameField;

		private static FieldInfo hudDataCharacterField;

		private static FieldInfo hudDataLevel2Field;

		private static FieldInfo hudDataLevel3Field;

		private static FieldInfo hudDataHealthFastField;

		private static FieldInfo hudDataHoverTimerField;

		private static readonly Dictionary<object, TMP_Text> enemyHpLabels = new Dictionary<object, TMP_Text>();

		private static readonly Dictionary<object, float> enemyNameBaseY = new Dictionary<object, float>();

		private static bool loggedAlwaysShowOnce;

		private const string GlobalKeyPrefix = "zenox_gp_";

		private static readonly string[] GuardianPowerNames = new string[8] { "GP_Eikthyr", "GP_TheElder", "GP_Bonemass", "GP_Moder", "GP_Yagluth", "GP_Queen", "GP_Ashlands", "GP_DeepNorth" };

		private float guardianPowerGrantTimer;

		public static ConfigEntry<bool> HoverTextExtensionsEnabled;

		public static ConfigEntry<int> ContainerHoverStyle;

		public static ConfigEntry<int> FermenterHoverStyle;

		public static ConfigEntry<int> CookingStationHoverStyle;

		private static FieldInfo cookingStationNviewField;

		private static MethodInfo cookingStationGetSlotMethod;

		private static MethodInfo cookingStationGetItemConversionMethod;

		private static MethodInfo cookingStationIsFireLitMethod;

		public static ConfigEntry<KeyboardShortcut> EditModeKey;

		private readonly Dictionary<string, BarOffset> barOffsets = new Dictionary<string, BarOffset>();

		private readonly Dictionary<string, RectTransform> editProxies = new Dictionary<string, RectTransform>();

		private bool editModeActive;

		private string draggingBar;

		private Vector2 dragStartMouse;

		private Vector2 dragStartOffset;

		private static HotkeyBar cachedHotkeyBar;

		private const float MinProxySize = 48f;

		private static float lastProxyDiagnosticTime;

		public static ConfigEntry<bool> ItemLevelStarsEnabled;

		public static ConfigEntry<int> InventoryStarFontSize;

		public static ConfigEntry<int> HotbarStarFontSize;

		private static readonly Color StarColor = new Color(1f, 0.85882f, 0.23137f, 1f);

		private static FieldInfo hotkeyGoField;

		private static readonly Dictionary<object, TMP_Text> hotkeyStarLabels = new Dictionary<object, TMP_Text>();

		private static bool? lastInventoryVisible;

		private static int multiCraftDesiredAmount = 1;

		private static bool nearbyCraftingCheckActive;

		private static readonly FieldInfo ZNetSceneNamedPrefabsField = AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs");

		private static Transform templateContainer;

		private static readonly string[] DecorativeFloraNames = new string[27]
		{
			"FirTree", "FirTree_big", "PineTree", "SnowFirTree", "SwampTree1", "SwampTree2", "AshlandsTree1", "AshlandsTree3", "AshlandsTree4", "AshlandsTree5",
			"AshlandsTree6", "AshlandsTree6_big", "Bush01", "Bush01_heath", "Bush01_deepnorth", "Bush02_en", "shrub_2", "shrub_2_heath", "AshlandsBush1", "AshlandsBush2",
			"FernAshlands", "FernFiddleHeadAshlands", "YggaShoot1", "YggaShoot2", "YggaShoot3", "YggdrasilRoot", "YggdrasilWood"
		};

		private static readonly string