Decompiled source of BetterUI v1.0.5

BetterUI.dll

Decompiled a day 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
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("BetterUI")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterUI")]
[assembly: AssemblyTitle("BetterUI")]
[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 BetterUI
{
	[BepInPlugin("zenox.betterui", "BetterUI", "1.0.4")]
	public class BetterUIPlugin : BaseUnityPlugin
	{
		[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 = BetterUIPlugin.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.m_playerStats[0][(PlayerStatType)6];
					int num2 = (int)val.m_playerStats[0][(PlayerStatType)0];
					int num3 = (int)val.m_playerStats[0][(PlayerStatType)1];
					int num4 = (int)val.m_playerStats[0][(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()}";
				}
			}
		}

		[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;
					BetterUIPlugin 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_053a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0549: Unknown result type (might be due to invalid IL or missing references)
				//IL_0558: Unknown result type (might be due to invalid IL or missing references)
				//IL_0567: Unknown result type (might be due to invalid IL or missing references)
				//IL_044e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0447: Unknown result type (might be due to invalid IL or missing references)
				//IL_0440: 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())
					{
						int num3 = Mathf.Max(0, val2.GetLevel() - 1);
						((TMP_Text)val).text = ((value4 == 0 || num3 == 0) ? val2.GetHoverName() : ("<color=#ffdb3c>" + StarText(num3) + "</color> " + val2.GetHoverName()));
						if (value4 == 1)
						{
							object? obj3 = hudDataLevel2Field?.GetValue(value);
							SetActiveIfPresent((RectTransform)((obj3 is RectTransform) ? obj3 : null), active: false);
							object? obj4 = hudDataLevel3Field?.GetValue(value);
							SetActiveIfPresent((RectTransform)((obj4 is RectTransform) ? obj4 : null), active: false);
						}
						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 num4 = (val2.IsBoss() ? BossHpTextFontSize.Value : EnemyHpTextFontSize.Value);
						orCreateHpLabel.text = $"<size={num4}>{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(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);
					}
				}
			}
		}

		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.betterui";

		public const string PluginName = "BetterUI";

		public const string PluginVersion = "1.0.4";

		public static BetterUIPlugin Instance;

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

		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;

		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;

		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 void BindCharacterLevelConfig()
		{
			CharacterXPEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("CharacterLevel", "Enabled", true, "If true, shows a combined character level (sum of all skill XP) as an XP bar at the bottom of the HUD, with a level-up message.");
		}

		private static void XP_Awake(Player player)
		{
			xpPlayer = player;
			XP_UpdatePlayerXP();
			XP_UpdatePlayerLevel();
			XP_UpdateUsedXP();
		}

		private static void XP_RaiseXP()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			XP_UpdatePlayerXP();
			float num = (float)((double)xpCurrent - xpUsed);
			if (num >= XP_NextLevelRequirement(CharacterLevel))
			{
				XP_UpdatePlayerLevel();
				XP_UpdateUsedXP();
				Vector3 headPoint = ((Character)xpPlayer).GetHeadPoint();
				xpPlayer.m_skillLevelupEffects.Create(headPoint, ((Component)xpPlayer).transform.rotation, ((Component)xpPlayer).transform, 1.5f, -1, default(ZDOID));
				((Character)xpPlayer).Message((MessageType)2, $"<size=60><color=white>LEVEL UP</color></size>\n<size=30>You are now Lv. {CharacterLevel}</size>", 0, (Sprite)null, false);
			}
		}

		public static float XP_GetLevelPercentage()
		{
			return (float)((double)xpCurrent - xpUsed) / XP_NextLevelRequirement(CharacterLevel);
		}

		private static void XP_UpdatePlayerXP()
		{
			if ((Object)(object)xpPlayer == (Object)null)
			{
				return;
			}
			float num = 0f;
			foreach (Skill skill in ((Character)xpPlayer).GetSkills().GetSkillList())
			{
				num += (float)XP_CalculateGainedXP(skill.m_level);
				num += (float)(int)skill.m_level * skill.GetLevelPercentage();
			}
			xpCurrent = num;
		}

		private static void XP_UpdateUsedXP()
		{
			xpUsed = 12.5 * (double)(CharacterLevel * CharacterLevel) + 62.5 * (double)CharacterLevel - 75.0;
		}

		private static void XP_UpdatePlayerLevel()
		{
			CharacterLevel = Mathf.FloorToInt(-2.5f + Mathf.Sqrt(8f * xpCurrent + 1225f) / 10f);
		}

		private static float XP_NextLevelRequirement(int lvl)
		{
			return (lvl + 3) * 25;
		}

		private static int XP_CalculateGainedXP(float lvl)
		{
			return (int)lvl * ((int)lvl + 1) / 2;
		}

		private void BindCharacterSelectStatsConfig()
		{
			ShowCharacterSelectStats = ((BaseUnityPlugin)this).Config.Bind<bool>("CharacterSelectStats", "Enabled", true, "If true, shows kills/deaths/crafts/builds under the character name on the character-select screen.");
			CharacterSelectStatsFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("CharacterSelectStats", "FontSize", 22, "Font size of the kills/deaths/crafts/builds line.");
			CharacterSelectStatsYOffset = ((BaseUnityPlugin)this).Config.Bind<float>("CharacterSelectStats", "YOffset", 22f, "Moves the character name (and the stats line under it) up by this many UI pixels, to avoid the stats line hanging into the cloud-save indicator below it.");
		}

		private void BindCombinedStatsTooltipConfig()
		{
			ShowCombinedItemStats = ((BaseUnityPlugin)this).Config.Bind<bool>("CombinedStatsTooltip", "Enabled", true, "If true, hovering the armor value in the character panel shows a combined weapon/block/armor/movement stat summary instead of nothing.");
		}

		private static bool TryCreateOverlay(InventoryGui ig)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			InventoryElement val = (((Object)(object)ig.m_playerGrid == (Object)null) ? null : ((Component)ig.m_playerGrid).GetComponentInChildren<InventoryElement>(true));
			GameObject val2 = (((Object)(object)val != (Object)null && (Object)(object)val.m_tooltip != (Object)null) ? val.m_tooltip.m_tooltipPrefab : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return false;
			}
			RectTransform rectTransform = ig.m_armor.rectTransform;
			GameObject val3 = new GameObject("ZenoxArmorStatsOverlay", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(UITooltip)
			});
			val3.transform.SetParent(((Transform)rectTransform).parent, false);
			RectTransform component = val3.GetComponent<RectTransform>();
			component.anchorMin = rectTransform.anchorMin;
			component.anchorMax = rectTransform.anchorMax;
			component.pivot = rectTransform.pivot;
			component.anchoredPosition = rectTransform.anchoredPosition;
			component.sizeDelta = new Vector2(Mathf.Max(rectTransform.sizeDelta.x, 40f), Mathf.Max(rectTransform.sizeDelta.y, 24f));
			Image component2 = val3.GetComponent<Image>();
			((Graphic)component2).color = new Color(0f, 0f, 0f, 0f);
			((Graphic)component2).raycastTarget = true;
			UITooltip component3 = val3.GetComponent<UITooltip>();
			component3.m_tooltipPrefab = val2;
			combinedStatsOverlay = val3;
			combinedStatsTooltip = component3;
			BetterUIPlugin instance = Instance;
			if (instance != null)
			{
				((BaseUnityPlugin)instance).Logger.LogInfo((object)"[BetterUI] Combined armor/weapon stats tooltip overlay created.");
			}
			return true;
		}

		private static void AppendWeaponStats(Player player, StringBuilder sb)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_00c8: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Invalid comparison between Unknown and I4
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			ItemData leftItem = ((Humanoid)player).LeftItem;
			ItemData rightItem = ((Humanoid)player).RightItem;
			ItemData ammoItem = ((Humanoid)player).GetAmmoItem();
			if (leftItem != null && (int)leftItem.m_shared.m_itemType != 5)
			{
				DamageTypes damage = leftItem.GetDamage();
				if ((int)leftItem.m_shared.m_skillType == 8 && ammoItem != null)
				{
					((DamageTypes)(ref damage)).Add(ammoItem.GetDamage(), 1);
				}
				sb.Append(((DamageTypes)(ref damage)).GetTooltipString(leftItem.m_shared.m_skillType));
				sb.AppendFormat("\n\n$item_knockback: <color=orange>{0}</color>", leftItem.m_shared.m_attackForce);
				sb.AppendFormat("\n$item_backstab: <color=orange>{0}x</color>", leftItem.m_shared.m_backstabBonus);
			}
			if (rightItem != null)
			{
				DamageTypes damage2 = rightItem.GetDamage();
				if ((int)rightItem.m_shared.m_skillType == 8 && ammoItem != null)
				{
					((DamageTypes)(ref damage2)).Add(ammoItem.GetDamage(), 1);
				}
				sb.Append(((DamageTypes)(ref damage2)).GetTooltipString(rightItem.m_shared.m_skillType));
				sb.AppendFormat("\n\n$item_knockback: <color=orange>{0}</color>", rightItem.m_shared.m_attackForce);
				sb.AppendFormat("\n$item_backstab: <color=orange>{0}x</color>", rightItem.m_shared.m_backstabBonus);
			}
		}

		private static void AppendBlockStats(Player player, StringBuilder sb)
		{
			ItemData val = ((Humanoid)player).LeftItem ?? ((Humanoid)player).RightItem;
			if (val != null)
			{
				float skillFactor = ((Character)player).GetSkillFactor((SkillType)6);
				sb.AppendFormat("\n\n$item_blockpower: <color=orange>{0}</color>", Mathf.RoundToInt(val.GetBlockPower(skillFactor)));
				if (val.m_shared.m_timedBlockBonus > 1f)
				{
					sb.AppendFormat("\n$item_deflection: <color=orange>{0}</color>", Mathf.RoundToInt(val.GetDeflectionForce()));
					sb.AppendFormat("\n$item_parrybonus: <color=orange>{0}x</color>", val.m_shared.m_timedBlockBonus);
				}
			}
		}

		private void Awake()
		{
			Instance = this;
			BindHudEditorConfig();
			BindEnemyLevelDisplayConfig();
			BindHoverTextExtensionsConfig();
			BindItemLevelStarsConfig();
			BindDurabilityColorConfig();
			BindCharacterLevelConfig();
			BindCharacterSelectStatsConfig();
			BindCombinedStatsTooltipConfig();
			harmony.PatchAll(Assembly.GetExecutingAssembly());
			((BaseUnityPlugin)this).Logger.LogInfo((object)"BetterUI v1.0.4 loaded.");
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		private void Update()
		{
			UpdateHudEditor();
		}

		private void BindDurabilityColorConfig()
		{
			DurabilityColorEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("DurabilityColor", "Enabled", true, "If true, colors the item durability bar green/yellow/orange/red by remaining percentage instead of vanilla's single color.");
		}

		private static void ApplyDurabilityColor(GuiBar durabilityBar, float percentage)
		{
			//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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			durabilityBar.ResetColor();
			Color color = ((percentage >= 0.75f) ? DurabilityColors[0] : ((percentage >= 0.5f) ? DurabilityColors[1] : ((percentage >= 0.25f) ? DurabilityColors[2] : DurabilityColors[3])));
			durabilityBar.SetColor(color);
		}

		private void BindEnemyLevelDisplayConfig()
		{
			EnemyLevelStyle = ((BaseUnityPlugin)this).Config.Bind<int>("EnemyLevelDisplay", "Style", 1, "How enemy level is shown. 0 = vanilla's own star icons only, 1 = text star prefix (same style as item quality stars) instead of vanilla's icons, 2 = both.");
			ShowEnemyHpText = ((BaseUnityPlugin)this).Config.Bind<bool>("EnemyLevelDisplay", "ShowHpText", true, "If true, shows a 'current/max' HP number under enemy nameplates.");
			EnemyHpTextFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("EnemyLevelDisplay", "HpTextFontSize", 11, "Font size of the HP number on regular enemy health bars.");
			BossHpTextFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("EnemyLevelDisplay", "BossHpTextFontSize", 18, "Font size of the HP number on the (larger) boss health bar.");
			EnemyHudDistanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("EnemyLevelDisplay", "DistanceMultiplier", 1f, "Multiplies how far away enemy HUDs (health bar/nameplate) become visible. 1 = vanilla default.");
			ColorEnemyNameByAlertState = ((BaseUnityPlugin)this).Config.Bind<bool>("EnemyLevelDisplay", "ColorNameByAlertState", true, "If true, tints the enemy name white/yellow/red depending on whether it's aware of or alerted to the player.");
			EnemyHealthBarScale = ((BaseUnityPlugin)this).Config.Bind<float>("EnemyLevelDisplay", "HealthBarScale", 1.1f, "Scale multiplier for the enemy health bar (width and height). 1 = vanilla size.");
			EnemyHealthBarHeightScale = ((BaseUnityPlugin)this).Config.Bind<float>("EnemyLevelDisplay", "HealthBarHeightScale", 1.5f, "Extra scale multiplier applied to the bar's HEIGHT only, on top of HealthBarScale - makes the bar taller/thicker without also widening it further.");
			EnemyNameYOffset = ((BaseUnityPlugin)this).Config.Bind<float>("EnemyLevelDisplay", "NameYOffset", 2f, "Moves the enemy name up by this many UI pixels, to make room for the bigger bar/HP text below it.");
			EnemyHpTextGap = ((BaseUnityPlugin)this).Config.Bind<float>("EnemyLevelDisplay", "HpTextGap", 11f, "Vertical gap between the enemy name and the HP text below it.");
			HideEnemyBarBackground = ((BaseUnityPlugin)this).Config.Bind<bool>("EnemyLevelDisplay", "HideBarBackground", true, "If true, hides the dark background panel behind the enemy health bar.");
			EnemyUIAlwaysShowDistance = ((BaseUnityPlugin)this).Config.Bind<float>("EnemyLevelDisplay", "AlwaysShowDistance", 30f, "Enemy HUD (bar/nameplate) is always shown for any enemy within this distance, instead of only appearing while the crosshair is aimed at it. 0 = disabled (vanilla hover-only behavior).");
		}

		private static void SetActiveIfPresent(RectTransform rt, bool active)
		{
			if ((Object)(object)rt != (Object)null)
			{
				((Component)rt).gameObject.SetActive(active);
			}
		}

		private static TMP_Text GetOrCreateHpLabel(object hudData, TextMeshProUGUI nameTemplate)
		{
			//IL_005c: 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)
			if (enemyHpLabels.TryGetValue(hudData, out var value) && (Object)(object)value != (Object)null)
			{
				((Component)value).gameObject.SetActive(true);
				return value;
			}
			TMP_Text val = (TMP_Text)(object)Object.Instantiate<TextMeshProUGUI>(nameTemplate, ((TMP_Text)nameTemplate).transform.parent);
			((Object)val).name = "ZenoxEnemyHpText";
			((Component)val).gameObject.SetActive(true);
			((Graphic)val).color = Color.white;
			val.alignment = (TextAlignmentOptions)514;
			val.rectTransform.pivot = new Vector2(0.5f, 0.5f);
			enemyHpLabels[hudData] = val;
			return val;
		}

		private void BindHoverTextExtensionsConfig()
		{
			HoverTextExtensionsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("HoverText", "Enabled", true, "If true, adds extra info lines to container/fermenter/cooking station hover text.");
			ContainerHoverStyle = ((BaseUnityPlugin)this).Config.Bind<int>("HoverText", "ContainerStyle", 3, "How chest fullness is shown. 0 = off, 1 = % used, 2 = items/max, 3 = free slots.");
			FermenterHoverStyle = ((BaseUnityPlugin)this).Config.Bind<int>("HoverText", "FermenterStyle", 2, "How fermenter progress is shown while brewing. 0 = off, 1 = % done, 2 = mm:ss remaining.");
			CookingStationHoverStyle = ((BaseUnityPlugin)this).Config.Bind<int>("HoverText", "CookingStationStyle", 2, "How cooking progress is shown per slot. 0 = off, 1 = % done, 2 = mm:ss remaining.");
		}

		private static string FormatDuration(double seconds)
		{
			if (seconds < 0.0)
			{
				seconds = 0.0;
			}
			TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
			if (timeSpan.TotalHours >= 1.0)
			{
				return $"{(int)timeSpan.TotalHours}h {timeSpan.Minutes}m";
			}
			if (timeSpan.TotalMinutes >= 1.0)
			{
				return $"{timeSpan.Minutes}m {timeSpan.Seconds}s";
			}
			return $"{timeSpan.Seconds}s";
		}

		private void BindHudEditorConfig()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			EditModeKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("HudEditor", "EditModeKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Toggle HUD edit mode: while active, drag a bar's proxy box with the left mouse button to move it, scroll while hovering it to resize it.");
			BindBarOffset("HealthBar");
			BindBarOffset("StaminaBar");
			BindBarOffset("FoodBar");
			BindBarOffset("EitrBar");
			BindBarOffset("AdrenalineBar");
			BindBarOffset("GuardianPower");
			BindBarOffset("StatusEffects");
			BindBarOffset("Hotbar");
			BindBarOffset("Minimap");
			BindBarOffset("XPBar");
		}

		private void BindBarOffset(string barName)
		{
			BarOffset value = new BarOffset
			{
				OffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("HudEditor", barName + ".OffsetX", 0f, "Horizontal offset for the " + barName + ", in UI pixels."),
				OffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("HudEditor", barName + ".OffsetY", 0f, "Vertical offset for the " + barName + ", in UI pixels."),
				Scale = ((BaseUnityPlugin)this).Config.Bind<float>("HudEditor", barName + ".Scale", 1f, "Scale multiplier for the " + barName + ". 1 = vanilla size.")
			};
			barOffsets[barName] = value;
		}

		private static RectTransform GetBarRoot(string barName)
		{
			Hud instance = Hud.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			return (RectTransform)(barName switch
			{
				"HealthBar" => instance.m_healthBarRoot, 
				"StaminaBar" => instance.m_staminaBar2Root, 
				"FoodBar" => (object)((instance.m_foodIcons != null && instance.m_foodIcons.Length != 0 && (Object)(object)instance.m_foodIcons[0] != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null), 
				"EitrBar" => instance.m_eitrBarRoot, 
				"AdrenalineBar" => instance.m_adrenalineBarRoot, 
				"GuardianPower" => instance.m_gpRoot, 
				"StatusEffects" => instance.m_statusEffectListRoot, 
				"Hotbar" => ((Object)(object)cachedHotkeyBar != (Object)null) ? ((Component)cachedHotkeyBar).GetComponent<RectTransform>() : null, 
				"Minimap" => ((Object)(object)Minimap.instance != (Object)null && (Object)(object)Minimap.instance.m_smallRoot != (Object)null) ? Minimap.instance.m_smallRoot.GetComponent<RectTransform>() : null, 
				"XPBar" => (object)(((Object)(object)xpBar != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null), 
				_ => null, 
			});
		}

		private static RectTransform[] GetBarRoots(string barName)
		{
			if (barName == "FoodBar")
			{
				Hud instance = Hud.instance;
				if ((Object)(object)instance == (Object)null || instance.m_foodIcons == null || instance.m_foodIcons.Length == 0)
				{
					return Array.Empty<RectTransform>();
				}
				int num = (((Object)(object)instance.m_foodIcon != (Object)null) ? 1 : 0);
				RectTransform[] array = (RectTransform[])(object)new RectTransform[instance.m_foodIcons.Length + num];
				for (int i = 0; i < instance.m_foodIcons.Length; i++)
				{
					if ((Object)(object)instance.m_foodIcons[i] == (Object)null)
					{
						return Array.Empty<RectTransform>();
					}
					ref RectTransform reference = ref array[i];
					Transform parent = ((Component)instance.m_foodIcons[i]).transform.parent;
					reference = (RectTransform)(object)((parent is RectTransform) ? parent : null);
					if ((Object)(object)array[i] == (Object)null)
					{
						return Array.Empty<RectTransform>();
					}
				}
				if (num == 1)
				{
					ref RectTransform reference2 = ref array[^1];
					Transform transform = ((Component)instance.m_foodIcon).transform;
					reference2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				}
				return array;
			}
			RectTransform barRoot = GetBarRoot(barName);
			return (RectTransform[])((!((Object)(object)barRoot != (Object)null)) ? ((Array)Array.Empty<RectTransform>()) : ((Array)new RectTransform[1] { barRoot }));
		}

		private RectTransform GetOrCreateProxy(string barName)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (editProxies.TryGetValue(barName, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Hud instance = Hud.instance;
			Canvas val = (((Object)(object)instance != (Object)null) ? ((Component)instance).GetComponentInParent<Canvas>() : null);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			GameObject val2 = new GameObject("BetterUIHudEditProxy_" + barName, new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val2.transform.SetParent(((Component)val).transform, false);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(130f, 30f);
			Image component2 = val2.GetComponent<Image>();
			((Graphic)component2).color = new Color(0.1f, 0.55f, 1f, 0f);
			editProxies[barName] = component;
			return component;
		}

		private void DestroyAllProxies()
		{
			foreach (KeyValuePair<string, RectTransform> editProxy in editProxies)
			{
				if ((Object)(object)editProxy.Value != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)editProxy.Value).gameObject);
				}
			}
			editProxies.Clear();
		}

		private void UpdateHudEditor()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = EditModeKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				editModeActive = !editModeActive;
				((BaseUnityPlugin)this).Logger.LogInfo((object)(editModeActive ? "BetterUI: HUD edit mode ON (drag a bar's blue proxy box to move it, scroll while hovering it to resize)." : "BetterUI: HUD edit mode OFF."));
				if (editModeActive)
				{
					LogBarRootDiagnosticsOnce();
				}
				else
				{
					DestroyAllProxies();
					draggingBar = null;
					Hud_Update_ForceBarsVisible_HudEditor_Patch.RestoreForcedActiveStates();
				}
			}
			Vector2 val = default(Vector2);
			foreach (KeyValuePair<string, BarOffset> barOffset in barOffsets)
			{
				string key = barOffset.Key;
				BarOffset value2 = barOffset.Value;
				RectTransform[] barRoots = GetBarRoots(key);
				if (barRoots.Length == 0)
				{
					continue;
				}
				if (!value2.Captured)
				{
					value2.BaseAnchoredPositions = (Vector2[])(object)new Vector2[barRoots.Length];
					value2.BaseScales = (Vector3[])(object)new Vector3[barRoots.Length];
					for (int i = 0; i < barRoots.Length; i++)
					{
						value2.BaseAnchoredPositions[i] = barRoots[i].anchoredPosition;
						value2.BaseScales[i] = ((Transform)barRoots[i]).localScale;
					}
					value2.Captured = true;
				}
				((Vector2)(ref val))..ctor(value2.OffsetX.Value, value2.OffsetY.Value);
				for (int j = 0; j < barRoots.Length; j++)
				{
					barRoots[j].anchoredPosition = value2.BaseAnchoredPositions[j] + val;
					((Transform)barRoots[j]).localScale = value2.BaseScales[j] * value2.Scale.Value;
				}
				if (editModeActive)
				{
					RectTransform orCreateProxy = GetOrCreateProxy(key);
					if ((Object)(object)orCreateProxy != (Object)null)
					{
						SyncProxyToTargets(orCreateProxy, barRoots);
						HandleBarEditInput(key, value2, orCreateProxy);
					}
				}
			}
		}

		private static void SyncProxyToTargets(RectTransform proxy, RectTransform[] targets)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00b4: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_0073: 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_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_007c: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(float.MaxValue, float.MaxValue, 0f);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(float.MinValue, float.MinValue, 0f);
			Vector3[] array = (Vector3[])(object)new Vector3[4];
			foreach (RectTransform val3 in targets)
			{
				if (!((Object)(object)val3 == (Object)null))
				{
					val3.GetWorldCorners(array);
					Vector3[] array2 = array;
					foreach (Vector3 val4 in array2)
					{
						val = Vector3.Min(val, val4);
						val2 = Vector3.Max(val2, val4);
					}
				}
			}
			Vector3 position = (val + val2) * 0.5f;
			float num = Mathf.Max(val2.x - val.x, 48f);
			float num2 = Mathf.Max(val2.y - val.y, 48f);
			proxy.sizeDelta = new Vector2(num, num2);
			((Transform)proxy).position = position;
		}

		private void LogBarRootDiagnosticsOnce()
		{
			//IL_0085: 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)
			foreach (string key in barOffsets.Keys)
			{
				RectTransform barRoot = GetBarRoot(key);
				if ((Object)(object)barRoot == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[BetterUI HudEditor] GetBarRoot('" + key + "') = null (no proxy possible)."));
					continue;
				}
				Vector3[] array = (Vector3[])(object)new Vector3[4];
				barRoot.GetWorldCorners(array);
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"[BetterUI HudEditor] GetBarRoot('{key}') = '{((Object)barRoot).name}', worldCorners=[{array[0]},{array[2]}], active={((Component)barRoot).gameObject.activeInHierarchy}");
			}
		}

		private void HandleBarEditInput(string barName, BarOffset offset, RectTransform proxyRt)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: 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)
			bool flag = RectTransformUtility.RectangleContainsScreenPoint(proxyRt, Vector2.op_Implicit(Input.mousePosition));
			if (flag)
			{
				float y = Input.mouseScrollDelta.y;
				if (y != 0f)
				{
					offset.Scale.Value = Mathf.Clamp(offset.Scale.Value + y * 0.05f, 0.3f, 3f);
				}
			}
			if (draggingBar == null && flag && Input.GetMouseButtonDown(0))
			{
				draggingBar = barName;
				dragStartMouse = Vector2.op_Implicit(Input.mousePosition);
				dragStartOffset = new Vector2(offset.OffsetX.Value, offset.OffsetY.Value);
			}
			else if (draggingBar == barName)
			{
				if (Input.GetMouseButton(0))
				{
					Vector2 val = Vector2.op_Implicit(Input.mousePosition) - dragStartMouse;
					offset.OffsetX.Value = dragStartOffset.x + val.x;
					offset.OffsetY.Value = dragStartOffset.y + val.y;
				}
				else
				{
					draggingBar = null;
				}
			}
		}

		private void BindItemLevelStarsConfig()
		{
			ItemLevelStarsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("ItemLevelStars", "Enabled", true, "If true, shows item quality as yellow star icons directly on the item icon (inventory + hotbar) instead of vanilla's plain number.");
			InventoryStarFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("ItemLevelStars", "InventoryFontSize", 11, "Font size of the quality stars in the inventory grid.");
			HotbarStarFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("ItemLevelStars", "HotbarFontSize", 11, "Font size of the quality stars on the hotbar (slots 1-8) - matches the inventory size by default.");
		}

		private static string StarText(int quality)
		{
			if (quality >= 5)
			{
				return $"<size=10>{quality}</size>x★";
			}
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < quality; i++)
			{
				stringBuilder.Append('★');
			}
			return stringBuilder.ToString();
		}

		private static TMP_Text GetOrCreateHotkeyStarLabel(object elementData, TMP_Text bindingTemplate)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (hotkeyStarLabels.TryGetValue(elementData, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			TMP_Text val = Object.Instantiate<TMP_Text>(bindingTemplate, bindingTemplate.transform.parent);
			((Object)val).name = "ZenoxItemStars";
			((Component)val).gameObject.SetActive(true);
			val.alignment = (TextAlignmentOptions)260;
			val.enableWordWrapping = false;
			val.enableAutoSizing = false;
			RectTransform rectTransform = val.rectTransform;
			rectTransform.anchorMin = new Vector2(1f, 1f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.pivot = new Vector2(1f, 1f);
			rectTransform.anchoredPosition = new Vector2(-2f, -2f);
			rectTransform.sizeDelta = new Vector2(40f, 14f);
			hotkeyStarLabels[elementData] = val;
			return val;
		}

		private static void LogVisibilityChangeDiagnostic(TMP_Text label)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			bool flag = InventoryGui.IsVisible();
			if (lastInventoryVisible != flag)
			{
				lastInventoryVisible = flag;
				Canvas canvas = ((Graphic)label).canvas;
				RectTransform rectTransform = label.rectTransform;
				BetterUIPlugin instance = Instance;
				if (instance != null)
				{
					((BaseUnityPlugin)instance).Logger.LogInfo((object)($"[BetterUI] Hotbar star state change: inventoryVisible={flag}, " + $"fontSize={label.fontSize}, enableAutoSizing={label.enableAutoSizing}, " + $"labelLossyScale={((Transform)rectTransform).lossyScale}, labelLocalScale={((Transform)rectTransform).localScale}, " + "parentLossyScale=" + (((Object)(object)((Transform)rectTransform).parent == (Object)null) ? "n/a" : ((object)((Transform)rectTransform).parent.lossyScale/*cast due to .constrained prefix*/).ToString()) + ", " + string.Format("canvas={0}, canvasScaleFactor={1}, ", ((Object)(object)canvas == (Object)null) ? "null" : ((Object)canvas).name, ((Object)(object)canvas == (Object)null) ? (-1f) : canvas.scaleFactor) + "canvasRenderMode=" + (((Object)(object)canvas == (Object)null) ? "n/a" : ((object)canvas.renderMode/*cast due to .constrained prefix*/).ToString())));
				}
			}
		}
	}
}