Decompiled source of BetterUI ForeverMaintained v2.5.5

plugins/BetterUI.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterUI.GameClasses;
using BetterUI.Patches;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BetterUI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterUI")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f09b8e3c-e099-46e0-b8a7-b36a4a6626a6")]
[assembly: AssemblyFileVersion("2.5.5")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.5.5.0")]
[module: UnverifiableCode]
namespace BetterUI
{
	[BepInPlugin("MK_BetterUI", "BetterUI", "2.5.5")]
	public class Main : BaseUnityPlugin
	{
		public enum CustomBarState
		{
			off = -1,
			on0Degrees = 0,
			on90Degrees = 90,
			on180Degrees = 180,
			on270Degrees = 270
		}

		public enum DurabilityBarStyle
		{
			Disabled = -1,
			GreenYellowOrangeRed,
			WhiteLightYellowLightCyanBlue
		}

		public enum TimeLeftStyle
		{
			Disabled,
			PercentageDone,
			MinutesSecondsLeft
		}

		public enum ChestHasRoomStyle
		{
			Disabled,
			Percentage,
			ItemsSlashMaxRoom,
			AmountOfFreeSlots
		}

		public enum EnemyLevelStyle
		{
			DefaultStars,
			PrefixLevelNumber,
			Both
		}

		public const string MODNAME = "BetterUI";

		public const string AUTHOR = "MK";

		public const string GUID = "MK_BetterUI";

		public const string VERSION = "2.5.5";

		internal static ManualLogSource log;

		internal readonly Harmony harmony;

		internal readonly Assembly assembly;

		public static ConfigEntry<bool> enablePlayerHudEditing;

		public static ConfigEntry<KeyCode> togglePlayerHudEditModeKey;

		public static ConfigEntry<KeyCode> modKeyPrimary;

		public static ConfigEntry<KeyCode> modKeySecondary;

		public static ConfigEntry<CustomBarState> customHealthBar;

		public static ConfigEntry<CustomBarState> customStaminaBar;

		public static ConfigEntry<CustomBarState> customEitrBar;

		public static ConfigEntry<CustomBarState> customFoodBar;

		public static ConfigEntry<int> customBarTextSize;

		public static ConfigEntry<int> customFoodBarTextSize;

		public static ConfigEntry<DurabilityBarStyle> durabilityBarColorPalette;

		public static ConfigEntry<bool> showItemStars;

		public static ConfigEntry<bool> showCustomCharInfo;

		public static ConfigEntry<bool> showCustomTooltips;

		public static ConfigEntry<bool> showCombinedItemStats;

		public static ConfigEntry<float> iconScaleSize;

		public static ConfigEntry<bool> customSkillUI;

		public static ConfigEntry<int> skillUITextSize;

		public static ConfigEntry<TimeLeftStyle> timeLeftHoverTextFermenter;

		public static ConfigEntry<TimeLeftStyle> timeLeftHoverTextPlant;

		public static ConfigEntry<TimeLeftStyle> timeLeftHoverTextCookingStation;

		public static ConfigEntry<TimeLeftStyle> timeLeftHoverTextBeeHive;

		public static ConfigEntry<ChestHasRoomStyle> chestHasRoomHoverText;

		public static ConfigEntry<bool> showCharacterXP;

		public static ConfigEntry<bool> showCharacterXpBar;

		public static ConfigEntry<bool> showXPNotifications;

		public static ConfigEntry<bool> extendedXPNotification;

		public static ConfigEntry<bool> skipRunningSkillNotifications;

		public static ConfigEntry<int> notificationTextSizeXP;

		public static ConfigEntry<bool> customEnemyHud;

		public static ConfigEntry<bool> showEnemyHPText;

		public static ConfigEntry<EnemyLevelStyle> enemyLevelStyle;

		public static ConfigEntry<int> enemyNameTextSize;

		public static ConfigEntry<int> enemyHPTextSize;

		public static ConfigEntry<int> playerHPTextSize;

		public static ConfigEntry<bool> showPlayerHPText;

		public static ConfigEntry<bool> showLocalPlayerEnemyHud;

		public static ConfigEntry<int> bossHPTextSize;

		public static ConfigEntry<bool> makeTamedHPGreen;

		public static ConfigEntry<float> maxShowDistance;

		public static ConfigEntry<bool> useCustomAlertedStatus;

		public static ConfigEntry<float> mapPinScaleSize;

		public static ConfigEntry<string> uiData;

		public static ConfigEntry<bool> isDebug;

		public Main()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			log = ((BaseUnityPlugin)this).Logger;
			harmony = new Harmony("MK_BetterUI");
			assembly = Assembly.GetExecutingAssembly();
		}

		public void Awake()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Expected O, but got Unknown
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Expected O, but got Unknown
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Expected O, but got Unknown
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Expected O, but got Unknown
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Expected O, but got Unknown
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Expected O, but got Unknown
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Expected O, but got Unknown
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Expected O, but got Unknown
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Expected O, but got Unknown
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Expected O, but got Unknown
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Expected O, but got Unknown
			//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Expected O, but got Unknown
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_0660: Expected O, but got Unknown
			string text = "1 - Player HUD";
			togglePlayerHudEditModeKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(text, "togglePlayerHudEditModeKey", (KeyCode)288, "Key used to toggle Player HUD editing mode. Accepted values: https://docs.unity3d.com/ScriptReference/KeyCode.html");
			modKeyPrimary = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(text, "modKeyPrimary", (KeyCode)323, "Key needed to be held down to change an elements position by moving the mouse, as well as its rotation with the mouse wheel if supported. Accepted values: https://docs.unity3d.com/ScriptReference/KeyCode.html");
			modKeySecondary = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(text, "modKeySecondary", (KeyCode)306, "Key needed to be held down to change an elements scale with the mouse wheel, as well as its X and Y dimensions by moving the mouse. Accepted Values: https://docs.unity3d.com/ScriptReference/KeyCode.html");
			customBarTextSize = ((BaseUnityPlugin)this).Config.Bind<int>(text, "customBarTextSize", 15, "Font size of the text on the custom bars.");
			customFoodBarTextSize = ((BaseUnityPlugin)this).Config.Bind<int>(text, "customFoodBarTextSize", 15, "Font size of the duration text of food items in the custom food bar.");
			text = "1 - Player HUD (Requires Logout)";
			bool oldOrDefaultConfigValue = GetOldOrDefaultConfigValue(new ConfigDefinition("1 - Player HUD", "enablePlayerHudEditing"), defaultValue: true);
			enablePlayerHudEditing = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "enablePlayerHudEditing", oldOrDefaultConfigValue, "Enable the ability to edit the player HUD by pressing a hotkey.");
			bool oldOrDefaultConfigValue2 = GetOldOrDefaultConfigValue(new ConfigDefinition("1 - Player HUD", "useCustomHealthBar"), defaultValue: false);
			oldOrDefaultConfigValue2 |= GetOldOrDefaultConfigValue(new ConfigDefinition("1 - Player HUD (Requires Logout)", "useCustomHealthBar"), defaultValue: false);
			customHealthBar = ((BaseUnityPlugin)this).Config.Bind<CustomBarState>(text, "customHealthBar", (!oldOrDefaultConfigValue2) ? CustomBarState.off : CustomBarState.on0Degrees, "Resizable, rotatable HP bar. This bar will always be the same size and will not get longer when you eat. Will also disable the default food bar, so customFoodBar will be enabled automatically.");
			customHealthBar.SettingChanged += delegate
			{
				CustomHealthBar_SettingChanged();
			};
			RemoveOldConfigValue<int>(new ConfigDefinition("1 - Player HUD", "healthBarRotation"));
			RemoveOldConfigValue<int>(new ConfigDefinition(text, "customHealthBarRotation"));
			bool oldOrDefaultConfigValue3 = GetOldOrDefaultConfigValue(new ConfigDefinition("1 - Player HUD", "useCustomStaminaBar"), defaultValue: false);
			oldOrDefaultConfigValue3 |= GetOldOrDefaultConfigValue(new ConfigDefinition(text, "useCustomStaminaBar"), defaultValue: false);
			customStaminaBar = ((BaseUnityPlugin)this).Config.Bind<CustomBarState>(text, "customStaminaBar", (!oldOrDefaultConfigValue3) ? CustomBarState.off : CustomBarState.on0Degrees, "Resizable, rotatable stamina bar. This bar will always be visible and will not get longer when you eat.");
			customStaminaBar.SettingChanged += delegate
			{
				CustomStaminaBar_SettingChanged();
			};
			RemoveOldConfigValue<int>(new ConfigDefinition("1 - Player HUD", "staminaBarRotation"));
			RemoveOldConfigValue<int>(new ConfigDefinition(text, "customStaminaBarRotation"));
			bool oldOrDefaultConfigValue4 = GetOldOrDefaultConfigValue(new ConfigDefinition("1 - Player HUD", "useCustomFoodBar"), defaultValue: false);
			oldOrDefaultConfigValue4 |= GetOldOrDefaultConfigValue(new ConfigDefinition(text, "useCustomFoodBar"), defaultValue: false);
			customFoodBar = ((BaseUnityPlugin)this).Config.Bind<CustomBarState>(text, "customFoodBar", (!oldOrDefaultConfigValue4) ? CustomBarState.off : CustomBarState.on0Degrees, "Resizable, rotatable food bar. Requires customHealthBar.");
			if (customHealthBar.Value != CustomBarState.off && customFoodBar.Value == CustomBarState.off)
			{
				customFoodBar.Value = CustomBarState.on0Degrees;
			}
			customFoodBar.SettingChanged += delegate
			{
				CustomFoodBar_SettingChanged();
			};
			RemoveOldConfigValue<int>(new ConfigDefinition("1 - Player HUD", "foodBarRotation"));
			RemoveOldConfigValue<int>(new ConfigDefinition(text, "customFoodBarRotation"));
			bool oldOrDefaultConfigValue5 = GetOldOrDefaultConfigValue(new ConfigDefinition("1 - Player HUD", "useCustomEitrBar"), defaultValue: false);
			customEitrBar = ((BaseUnityPlugin)this).Config.Bind<CustomBarState>(text, "customEitrBar", (!oldOrDefaultConfigValue5) ? CustomBarState.off : CustomBarState.on0Degrees, "Resizable, rotatable eitr bar. If you don't know what this is yet, just keep it disabled. This bar will always be visible and will not get longer when you eat.");
			customEitrBar.SettingChanged += delegate
			{
				CustomEitrBar_SettingChanged();
			};
			RemoveOldConfigValue<int>(new ConfigDefinition(text, "customSpoilerBarRotation"));
			text = "2 - Character Inventory";
			bool oldOrDefaultConfigValue6 = GetOldOrDefaultConfigValue(new ConfigDefinition(text, "showDurabilityColor"), defaultValue: true);
			int oldOrDefaultConfigValue7 = GetOldOrDefaultConfigValue(new ConfigDefinition(text, "durabilityColorPalette"), 0);
			durabilityBarColorPalette = ((BaseUnityPlugin)this).Config.Bind<DurabilityBarStyle>(text, "durabilityBarColorPalette", IntToDurabilityBarStyle(oldOrDefaultConfigValue6, oldOrDefaultConfigValue7), "Change durability bar colors. Options: 0 = Green, Yellow, Orange, Red, 1 = White, Light Yellow, Light Cyan, Blue.");
			showItemStars = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showItemStars", true, "Show item quality as stars.");
			showCustomCharInfo = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showCustomCharInfo", true, "Show Deaths, Builds, and Crafts stats on character selection screen. Also shows the Kills stat if something increases it (the base game doesn't).");
			showCustomTooltips = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showCustomTooltips", true, "Show more info on inventory item tooltips. Disable this if using Epic Loot.");
			showCombinedItemStats = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showCombinedItemStats", true, "Show all item stats when mouse is hovered over armor amount.");
			iconScaleSize = ((BaseUnityPlugin)this).Config.Bind<float>(text, "iconScaleSize", 1f, "Scale item icon by this factor. Ex. 0.75 makes them 75% of their original size.");
			text = "3 - Character Skills";
			customSkillUI = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "customSkillUI", false, "Toggle the use of the custom skills UI.");
			skillUITextSize = ((BaseUnityPlugin)this).Config.Bind<int>(text, "skillUITextSize", 14, "Select text size of the skills UI.");
			text = "4 - Hover Text";
			int oldOrDefaultConfigValue8 = GetOldOrDefaultConfigValue(new ConfigDefinition(text, "timeLeftStyleFermenter"), 2);
			timeLeftHoverTextFermenter = ((BaseUnityPlugin)this).Config.Bind<TimeLeftStyle>(text, "timeLeftHoverTextFermenter", IntToTimeLeftStyle(oldOrDefaultConfigValue8), "Select duration display. Disabled = Default, PercentageDone = % Done, MinutesSecondsLeft = min:sec left.");
			oldOrDefaultConfigValue8 = GetOldOrDefaultConfigValue(new ConfigDefinition(text, "timeLeftStylePlant"), 2);
			timeLeftHoverTextPlant = ((BaseUnityPlugin)this).Config.Bind<TimeLeftStyle>(text, "timeLeftHoverTextPlant", IntToTimeLeftStyle(oldOrDefaultConfigValue8), "Select duration display. Disabled = Default, PercentageDone = % Done, MinutesSecondsLeft = min:sec left.");
			oldOrDefaultConfigValue8 = GetOldOrDefaultConfigValue(new ConfigDefinition(text, "timeLeftStyleCookingStation"), 2);
			timeLeftHoverTextCookingStation = ((BaseUnityPlugin)this).Config.Bind<TimeLeftStyle>(text, "timeLeftHoverTextCookingStation", IntToTimeLeftStyle(oldOrDefaultConfigValue8), "Select duration display. Disabled = Default, PercentageDone = % Done, MinutesSecondsLeft = min:sec left.");
			timeLeftHoverTextBeeHive = ((BaseUnityPlugin)this).Config.Bind<TimeLeftStyle>(text, "timeLeftHoverTextBeeHive", TimeLeftStyle.MinutesSecondsLeft, "Select duration display. Disabled = Default, PercentageDone = % Done, MinutesSecondsLeft = min:sec left.");
			int oldOrDefaultConfigValue9 = GetOldOrDefaultConfigValue(new ConfigDefinition(text, "chestHasRoomStyle"), 2);
			chestHasRoomHoverText = ((BaseUnityPlugin)this).Config.Bind<ChestHasRoomStyle>(text, "chestHasRoomHoverText", IntToChestHasRoomStyle(oldOrDefaultConfigValue9), "Select how chest emptiness is displayed. Disabled = Default | Percentage = % | ItemsSlashMaxRoom= used / total slots. | AmountOfFreeSlots = count of free slots.");
			text = "5 - Character XP";
			showCharacterXP = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showCharacterXP", true, "Enable character XP. This combines all skill levels to show overall character progress.");
			showXPNotifications = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showXPNotifications", true, "Show whenever you gain xp from actions.");
			notificationTextSizeXP = ((BaseUnityPlugin)this).Config.Bind<int>(text, "notificationTextSizeXP", 14, "XP notification font size.");
			extendedXPNotification = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "extendedXPNotification", false, "Extend notification with: (xp gained) [current/overall xp].");
			skipRunningSkillNotifications = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "skipRunningSkillNotifications", true, "Whether to ignore xp gain notifications for the running skill.");
			text = "5 - Character XP (Requires Logout)";
			bool oldOrDefaultConfigValue10 = GetOldOrDefaultConfigValue(new ConfigDefinition("5 - Character XP", "showCharacterXpBar"), defaultValue: true);
			showCharacterXpBar = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showCharacterXpBar", oldOrDefaultConfigValue10, "Show Character XP bar on the bottom of the screen. Character XP must be enabled.");
			text = "6 - Enemy HUD";
			customEnemyHud = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "customEnemyHud", true, "Enable custom enemy HUD changes. If this is set to false, all options in this section will be disabled.");
			useCustomAlertedStatus = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "useCustomAlertedStatus", true, "Hide the vanilla alerted icons above the enemy health bar and instead change the color of the name based on the alerted status.");
			showEnemyHPText = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showEnemyHPText", true, "Show the text with HP amount on enemy health bars.");
			int oldOrDefaultConfigValue11 = GetOldOrDefaultConfigValue(new ConfigDefinition(text, "enemyLvlStyle"), 0);
			enemyLevelStyle = ((BaseUnityPlugin)this).Config.Bind<EnemyLevelStyle>(text, "enemyLevelStyle", IntToEnemyLevelStyle(oldOrDefaultConfigValue11), "Choose how enemy level is shown.");
			enemyNameTextSize = ((BaseUnityPlugin)this).Config.Bind<int>(text, "enemyNameTextSize", 14, "Font size of the name on the enemy.");
			enemyHPTextSize = ((BaseUnityPlugin)this).Config.Bind<int>(text, "enemyHPTextSize", 10, "Font size of the HP text on the enemy health bar.");
			showPlayerHPText = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showPlayerHPText", true, "Show the health numbers on other player's health bar in multiplayer.");
			showLocalPlayerEnemyHud = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "showLocalPlayerEnemyHud", false, "Show the enemy HUD/ health Bar for your player.");
			showLocalPlayerEnemyHud.SettingChanged += delegate
			{
				BetterEnemyHud.ShowLocalPlayerEnemyHudConfigChanged();
			};
			playerHPTextSize = ((BaseUnityPlugin)this).Config.Bind<int>(text, "playerHPTextSize", 10, "The size of the font to display on other player's health bar in multiplayer.");
			bossHPTextSize = ((BaseUnityPlugin)this).Config.Bind<int>(text, "bossHPTextSize", 14, "The size of the font to display on the boss's health bar.");
			makeTamedHPGreen = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "makeTamedHPGreen", true, "Make the health bar for tamed creatures green instead of red.");
			maxShowDistance = ((BaseUnityPlugin)this).Config.Bind<float>(text, "maxShowDistance", 1f, "How far you will see enemy HP Bar. This is a multiplier, 1 is game default, 2 is twice as far (valid range: 0 to 3).");
			text = "7 - Map";
			mapPinScaleSize = ((BaseUnityPlugin)this).Config.Bind<float>(text, "mapPinScaleSize", 1f, "Scale map pins by this factor. Ex. 1.5 makes them 150% of their original size.");
			text = "8 - Debug";
			isDebug = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "isDebug", false, "Enable debug logging.");
			text = "9 - xDataUI";
			uiData = ((BaseUnityPlugin)this).Config.Bind<string>(text, "uiData", "none", "This is your customized UI info. Edit to none, if having issues or wanting to reset positions.");
			if (isDebug.Value)
			{
				PrintOrphanedEntries();
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"BetterUI (Forever Maintained Version) loaded");
		}

		private DurabilityBarStyle IntToDurabilityBarStyle(bool wasColorPaletteOn, int selectedColorPalette)
		{
			if (!wasColorPaletteOn)
			{
				return DurabilityBarStyle.Disabled;
			}
			if (selectedColorPalette != 0)
			{
				return DurabilityBarStyle.WhiteLightYellowLightCyanBlue;
			}
			return DurabilityBarStyle.GreenYellowOrangeRed;
		}

		private ChestHasRoomStyle IntToChestHasRoomStyle(int value)
		{
			if (value > 0 && value <= 3)
			{
				return (ChestHasRoomStyle)value;
			}
			return ChestHasRoomStyle.Disabled;
		}

		private TimeLeftStyle IntToTimeLeftStyle(int value)
		{
			return value switch
			{
				1 => TimeLeftStyle.PercentageDone, 
				2 => TimeLeftStyle.MinutesSecondsLeft, 
				_ => TimeLeftStyle.Disabled, 
			};
		}

		private EnemyLevelStyle IntToEnemyLevelStyle(int value)
		{
			return value switch
			{
				1 => EnemyLevelStyle.PrefixLevelNumber, 
				2 => EnemyLevelStyle.Both, 
				_ => EnemyLevelStyle.DefaultStars, 
			};
		}

		private void CustomFoodBar_SettingChanged()
		{
			CustomBars.FoodBar.UpdateRotation();
		}

		private void CustomStaminaBar_SettingChanged()
		{
			CustomBars.StaminaBar.UpdateRotation();
		}

		private void CustomHealthBar_SettingChanged()
		{
			CustomBars.HealthBar.UpdateRotation();
		}

		private void CustomEitrBar_SettingChanged()
		{
			CustomBars.EitrBar.UpdateRotation();
		}

		public void Start()
		{
			harmony.PatchAll(assembly);
		}

		public void RemoveOldConfigValue<T>(ConfigDefinition configDefinition)
		{
			GetOldOrDefaultConfigValue(configDefinition, default(T));
		}

		public T GetOldOrDefaultConfigValue<T>(ConfigDefinition configDefinition, T defaultValue)
		{
			T value = ((BaseUnityPlugin)this).Config.Bind<T>(configDefinition, defaultValue, (ConfigDescription)null).Value;
			((BaseUnityPlugin)this).Config.Remove(configDefinition);
			if (((BaseUnityPlugin)this).Config.SaveOnConfigSet)
			{
				((BaseUnityPlugin)this).Config.Save();
			}
			return value;
		}

		public bool TryGetOldConfigValue<T>(ConfigDefinition configDefinition, ref T oldValue, bool removeIfFound = true)
		{
			if (!TomlTypeConverter.CanConvert(typeof(T)))
			{
				throw new ArgumentException(string.Format("Type {0} is not supported by the config system. Supported types: {1}", typeof(T), string.Join(", ", (from x in TomlTypeConverter.GetSupportedTypes()
					select x.Name).ToArray())));
			}
			try
			{
				object obj = AccessTools.FieldRefAccess<ConfigFile, object>("_ioLock").Invoke(((BaseUnityPlugin)this).Config);
				Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)AccessTools.PropertyGetter(typeof(ConfigFile), "OrphanedEntries").Invoke(((BaseUnityPlugin)this).Config, new object[0]);
				lock (obj)
				{
					if (dictionary.TryGetValue(configDefinition, out var value))
					{
						oldValue = (T)TomlTypeConverter.ConvertToValue(value, typeof(T));
						if (removeIfFound)
						{
							dictionary.Remove(configDefinition);
						}
						return true;
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("Error getting orphaned entry: " + ex.StackTrace));
			}
			return false;
		}

		public void PrintOrphanedEntries()
		{
			try
			{
				object obj = AccessTools.FieldRefAccess<ConfigFile, object>("_ioLock").Invoke(((BaseUnityPlugin)this).Config);
				Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)AccessTools.PropertyGetter(typeof(ConfigFile), "OrphanedEntries").Invoke(((BaseUnityPlugin)this).Config, new object[0]);
				if (dictionary.Count == 0)
				{
					return;
				}
				lock (obj)
				{
					Debug.Log((object)"printing orphaned config values");
					foreach (KeyValuePair<ConfigDefinition, string> item in dictionary)
					{
						Debug.Log((object)(item.Key.Section + "," + item.Key.Key + ": " + item.Value));
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("Error logging orphaned entries: " + ex.StackTrace));
			}
		}
	}
}
namespace BetterUI.Patches
{
	internal static class Compatibility
	{
		public static class QuickSlotsHotkeyBar
		{
			private static readonly string originalPath = "QuickSlotsHotkeyBar";

			private static readonly string parent = "hudroot";

			public static bool isUsing = false;

			public static void Unanchor(Hud hud)
			{
				Transform val = ((Component)Hud.instance).transform.Find(parent).Find(originalPath);
				if (Object.op_Implicit((Object)(object)val))
				{
					isUsing = true;
					Object.Destroy((Object)(object)((Component)val).GetComponent("ConfigPositionedElement"));
				}
			}
		}
	}
	internal class CustomBars
	{
		public static class BarHelper
		{
			public const float scalingFactor = 0.6f;

			public const int padding = 0;

			public static float StepSize => Hud.instance.m_healthPanel.sizeDelta.x;

			public static void BaseCreate(string objectName, string origBarName, ref RectTransform root, ref GuiBar slowBar, ref GuiBar fastBar, ref TMP_Text barText)
			{
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_013f: 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)
				if (!((Object)(object)root != (Object)null))
				{
					((Component)((Component)Hud.instance).transform.Find("hudroot").Find(origBarName)).gameObject.SetActive(false);
					root = Object.Instantiate<RectTransform>(Hud.instance.m_healthBarRoot, ((Component)Hud.instance).transform.Find("hudroot"));
					((Object)((Component)root).gameObject).name = objectName;
					fastBar = ((Component)((Transform)root).Find("fast")).GetComponent<GuiBar>();
					slowBar = ((Component)((Transform)root).Find("slow")).GetComponent<GuiBar>();
					Transform val = ((Component)fastBar).transform.Find("bar").Find("HealthText");
					((Component)val).gameObject.SetActive(false);
					barText = Object.Instantiate<TMP_Text>(((Component)val).GetComponent<TMP_Text>(), (Transform)(object)root);
					((Component)barText).gameObject.AddComponent<TextScaler>();
					((Component)barText).gameObject.SetActive(true);
					((Transform)root).Find("border").localScale = new Vector3(1f, 0.6f, 1f);
					((Transform)root).Find("bkg").localScale = new Vector3(1f, 0.6f, 1f);
					((Component)fastBar).transform.localScale = new Vector3(1f, 0.6f, 1f);
					((Component)slowBar).transform.localScale = new Vector3(1f, 0.6f, 1f);
				}
			}

			public static void UpdateRotation(int configRotation, ref RectTransform root, ref TMP_Text barText)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				((Transform)root).localEulerAngles = new Vector3(0f, 0f, (float)configRotation);
				barText.transform.localEulerAngles = new Vector3(0f, 0f, (float)(-configRotation));
			}

			public static void HealthStyleUpdate(float max, float current, ref GuiBar slowBar, ref GuiBar fastBar, ref TMP_Text barText)
			{
				fastBar.SetMaxValue(max);
				fastBar.SetValue(current);
				slowBar.SetMaxValue(max);
				slowBar.SetValue(current);
				barText.fontSize = Main.customBarTextSize.Value;
				barText.text = $"{Mathf.CeilToInt(current)}/{Mathf.CeilToInt(max)}";
			}

			public static void StaminaStyleUpdate(float max, float current, ref GuiBar slowBar, ref GuiBar fastBar, ref TMP_Text barText)
			{
				fastBar.SetValue(current / max);
				slowBar.SetValue(current / max);
				barText.fontSize = Main.customBarTextSize.Value;
				barText.text = $"{Mathf.CeilToInt(current)}/{Mathf.CeilToInt(max)}";
			}

			public static Main.CustomBarState IncrementRotation(Main.CustomBarState state)
			{
				return state switch
				{
					Main.CustomBarState.on0Degrees => Main.CustomBarState.on90Degrees, 
					Main.CustomBarState.on90Degrees => Main.CustomBarState.on180Degrees, 
					Main.CustomBarState.on180Degrees => Main.CustomBarState.on270Degrees, 
					Main.CustomBarState.on270Degrees => Main.CustomBarState.on0Degrees, 
					_ => state, 
				};
			}

			public static Main.CustomBarState DecrementRotation(Main.CustomBarState state)
			{
				return state switch
				{
					Main.CustomBarState.on0Degrees => Main.CustomBarState.on270Degrees, 
					Main.CustomBarState.on90Degrees => Main.CustomBarState.on0Degrees, 
					Main.CustomBarState.on180Degrees => Main.CustomBarState.on0Degrees, 
					Main.CustomBarState.on270Degrees => Main.CustomBarState.on180Degrees, 
					_ => state, 
				};
			}
		}

		public static class HealthBar
		{
			public const string objectName = "BetterUI_HPBar";

			internal static RectTransform root;

			internal static GuiBar slowBar;

			internal static GuiBar fastBar;

			internal static TMP_Text barText;

			public static void UpdateRotation()
			{
				if (!((Object)(object)root == (Object)null) && Main.customHealthBar.Value != Main.CustomBarState.off)
				{
					BarHelper.UpdateRotation((int)Main.customHealthBar.Value, ref root, ref barText);
				}
			}

			public static void Create()
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					BarHelper.BaseCreate("BetterUI_HPBar", "healthpanel", ref root, ref slowBar, ref fastBar, ref barText);
					UpdateRotation();
					RectTransform obj = root;
					((Transform)obj).position = ((Transform)obj).position + new Vector3((0f - BarHelper.StepSize) / 4f, BarHelper.StepSize / 4f);
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("HealthBar.Create() " + ex.Message + " " + ex.StackTrace));
				}
			}

			public static void Update(float max, float current)
			{
				try
				{
					if ((Object)(object)root != (Object)null)
					{
						BarHelper.HealthStyleUpdate(max, current, ref slowBar, ref fastBar, ref barText);
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("HealthBar.Update() " + ex.Message + " " + ex.StackTrace));
				}
			}
		}

		public static class StaminaBar
		{
			public const string objectName = "BetterUI_StaminaBar";

			internal static RectTransform root;

			internal static GuiBar slowBar;

			internal static GuiBar fastBar;

			internal static TMP_Text barText;

			public static void UpdateRotation()
			{
				if (!((Object)(object)root == (Object)null) && Main.customStaminaBar.Value != Main.CustomBarState.off)
				{
					BarHelper.UpdateRotation((int)Main.customStaminaBar.Value, ref root, ref barText);
				}
			}

			public static void Create()
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_010a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					BarHelper.BaseCreate("BetterUI_StaminaBar", "staminapanel", ref root, ref slowBar, ref fastBar, ref barText);
					UpdateRotation();
					fastBar.m_originalColor = ((Graphic)((Component)Hud.instance.m_staminaBar2Fast.m_bar).GetComponent<Image>()).color;
					slowBar.m_originalColor = ((Graphic)((Component)Hud.instance.m_staminaBar2Slow.m_bar).GetComponent<Image>()).color;
					fastBar.ResetColor();
					slowBar.ResetColor();
					fastBar.m_smoothDrain = Hud.instance.m_staminaBar2Fast.m_smoothDrain;
					fastBar.m_changeDelay = Hud.instance.m_staminaBar2Fast.m_changeDelay;
					fastBar.m_smoothSpeed = Hud.instance.m_staminaBar2Fast.m_smoothSpeed;
					RectTransform obj = root;
					((Transform)obj).position = ((Transform)obj).position - new Vector3(BarHelper.StepSize / 4f, 0f);
					if (Main.customHealthBar.Value != Main.CustomBarState.off)
					{
						RectTransform obj2 = root;
						((Transform)obj2).position = ((Transform)obj2).position - new Vector3(0f, 0f);
					}
					else
					{
						RectTransform obj3 = root;
						((Transform)obj3).position = ((Transform)obj3).position + new Vector3(0f, BarHelper.StepSize / 4f);
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("StaminaBar.Create() " + ex.Message + " " + ex.StackTrace));
				}
			}

			public static void Update(float max, float current)
			{
				try
				{
					if ((Object)(object)root != (Object)null)
					{
						BarHelper.StaminaStyleUpdate(max, current, ref slowBar, ref fastBar, ref barText);
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("StaminaBar.Update() " + ex.Message + " " + ex.StackTrace));
				}
			}
		}

		public static class EitrBar
		{
			public const string objectName = "BetterUI_EitrBar";

			internal static RectTransform root;

			internal static GuiBar slowBar;

			internal static GuiBar fastBar;

			internal static TMP_Text barText;

			public static void UpdateRotation()
			{
				if (!((Object)(object)root == (Object)null) && Main.customEitrBar.Value != Main.CustomBarState.off)
				{
					BarHelper.UpdateRotation((int)Main.customEitrBar.Value, ref root, ref barText);
				}
			}

			public static void Create()
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_016d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_010a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0156: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					BarHelper.BaseCreate("BetterUI_EitrBar", "eitrpanel", ref root, ref slowBar, ref fastBar, ref barText);
					UpdateRotation();
					fastBar.m_originalColor = ((Graphic)((Component)Hud.instance.m_eitrBarFast.m_bar).GetComponent<Image>()).color;
					slowBar.m_originalColor = ((Graphic)((Component)Hud.instance.m_eitrBarSlow.m_bar).GetComponent<Image>()).color;
					fastBar.ResetColor();
					slowBar.ResetColor();
					fastBar.m_smoothDrain = Hud.instance.m_eitrBarFast.m_smoothDrain;
					fastBar.m_changeDelay = Hud.instance.m_eitrBarFast.m_changeDelay;
					fastBar.m_smoothSpeed = Hud.instance.m_eitrBarFast.m_smoothSpeed;
					RectTransform obj = root;
					((Transform)obj).position = ((Transform)obj).position - new Vector3(BarHelper.StepSize / 4f, 0f);
					if (Main.customHealthBar.Value != Main.CustomBarState.off)
					{
						RectTransform obj2 = root;
						((Transform)obj2).position = ((Transform)obj2).position - new Vector3(0f, 0f);
						if (Main.customStaminaBar.Value != Main.CustomBarState.off)
						{
							RectTransform obj3 = root;
							((Transform)obj3).position = ((Transform)obj3).position - new Vector3(0f, BarHelper.StepSize / 4f + 0f);
						}
					}
					else
					{
						RectTransform obj4 = root;
						((Transform)obj4).position = ((Transform)obj4).position + new Vector3(0f, BarHelper.StepSize / 4f);
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("EitrBar.Create() " + ex.Message + " " + ex.StackTrace));
				}
			}

			public static void Update(float max, float current)
			{
				try
				{
					if ((Object)(object)root != (Object)null)
					{
						BarHelper.StaminaStyleUpdate(max, current, ref slowBar, ref fastBar, ref barText);
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("EitrBar.Update() " + ex.Message + " " + ex.StackTrace));
				}
			}
		}

		public static class FoodBar
		{
			public const string objectName = "BetterUI_FoodBar";

			private static RectTransform foodPanel;

			private static RectTransform foodBarRoot;

			private static RectTransform foodBaseBar;

			private static Image[] foodBars;

			private static Image[] foodIcons;

			private static TMP_Text[] foodTimes;

			private static Transform[] foodTransforms;

			public static void UpdateRotation()
			{
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)foodPanel == (Object)null) && Main.customFoodBar.Value != Main.CustomBarState.off)
				{
					int num = (int)(Main.customFoodBar.Value + 270) % 360;
					((Transform)foodPanel).localEulerAngles = new Vector3(0f, 0f, (float)num);
					Transform[] array = foodTransforms;
					for (int i = 0; i < array.Length; i++)
					{
						array[i].localEulerAngles = new Vector3(0f, 0f, (float)(-num));
					}
				}
			}

			public static void Create()
			{
				//IL_022a: Unknown result type (might be due to invalid IL or missing references)
				//IL_023a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0244: Unknown result type (might be due to invalid IL or missing references)
				//IL_025a: Unknown result type (might be due to invalid IL or missing references)
				//IL_026a: Unknown result type (might be due to invalid IL or missing references)
				//IL_026f: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if ((Object)(object)foodPanel != (Object)null)
					{
						return;
					}
					if (Main.customHealthBar.Value == Main.CustomBarState.off)
					{
						Debug.LogWarning((object)"customFoodBar requires customHealthBar. No custom food bar will be created. Activate customHealthBar and log out and back in to use customFoodBar.");
						return;
					}
					foodPanel = Object.Instantiate<RectTransform>(Hud.instance.m_healthPanel, ((Component)Hud.instance).transform.Find("hudroot"));
					((Object)((Component)foodPanel).gameObject).name = "BetterUI_FoodBar";
					((Component)foodPanel).gameObject.SetActive(true);
					foodBarRoot = ((Component)((Transform)foodPanel).Find("Food")).GetComponent<RectTransform>();
					foodBaseBar = ((Component)((Transform)foodBarRoot).Find("baseBar")).GetComponent<RectTransform>();
					foodBars = (Image[])(object)new Image[Hud.instance.m_foodBars.Length];
					foodIcons = (Image[])(object)new Image[Hud.instance.m_foodIcons.Length];
					foodTimes = (TMP_Text[])(object)new TMP_Text[Hud.instance.m_foodTime.Length];
					foodTransforms = (Transform[])(object)new Transform[Hud.instance.m_foodTime.Length];
					for (int i = 0; i < Hud.instance.m_foodBars.Length; i++)
					{
						foodBars[i] = ((Component)((Transform)foodBarRoot).Find(((Object)Hud.instance.m_foodBars[i]).name)).GetComponent<Image>();
						foodTransforms[i] = ((Transform)foodPanel).Find($"food{i}");
						foodIcons[i] = ((Component)foodTransforms[i].Find($"foodicon{i}")).GetComponent<Image>();
						foodTimes[i] = ((Component)foodTransforms[i].Find("time")).GetComponent<TMP_Text>();
					}
					UpdateRotation();
					((Component)((Transform)foodPanel).Find("Health")).gameObject.SetActive(false);
					((Component)((Transform)foodPanel).Find("darken")).gameObject.SetActive(false);
					((Component)((Transform)foodPanel).Find("healthicon")).gameObject.SetActive(false);
					((Component)((Transform)foodPanel).Find("foodicon (1)")).gameObject.SetActive(false);
					((Transform)foodPanel).position = ((Transform)Hud.instance.m_gpRoot).position;
					RectTransform obj = foodPanel;
					((Transform)obj).position = ((Transform)obj).position + new Vector3((0f - foodPanel.sizeDelta.x) / 4f, foodPanel.sizeDelta.x / 2f);
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("FoodBar.Create() " + ex.Message + " " + ex.StackTrace));
				}
			}

			public static void Update(Player player)
			{
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: 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_0143: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (!((Object)(object)foodPanel != (Object)null))
					{
						return;
					}
					List<Food> foods = player.GetFoods();
					float num = player.GetBaseFoodHP() / 25f * 32f;
					foodBaseBar.SetSizeWithCurrentAnchors((Axis)0, num);
					for (int i = 0; i < Hud.instance.m_foodBars.Length; i++)
					{
						Image val = foodBars[i];
						Image val2 = foodIcons[i];
						TMP_Text val3 = foodTimes[i];
						if (i < foods.Count)
						{
							((Component)val).gameObject.SetActive(true);
							Food val4 = foods[i];
							((Component)val2).gameObject.SetActive(true);
							val2.sprite = val4.m_item.GetIcon();
							if (val4.CanEatAgain())
							{
								((Graphic)val2).color = new Color(1f, 1f, 1f, 0.7f + Mathf.Sin(Time.time * 5f) * 0.3f);
							}
							else
							{
								((Graphic)val2).color = Color.white;
							}
							((Component)val3).gameObject.SetActive(true);
							val3.fontSize = Main.customFoodBarTextSize.Value;
							if (val4.m_time >= 60f)
							{
								val3.text = Mathf.CeilToInt(val4.m_time / 60f) + "m";
								((Graphic)val3).color = Color.white;
							}
							else
							{
								val3.text = Mathf.FloorToInt(val4.m_time) + "s";
								((Graphic)val3).color = new Color(1f, 1f, 1f, 0.4f + Mathf.Sin(Time.time * 10f) * 0.6f);
							}
						}
						else
						{
							((Component)val).gameObject.SetActive(false);
							((Component)val2).gameObject.SetActive(false);
							((Component)val3).gameObject.SetActive(false);
						}
					}
					float num2 = Mathf.Ceil(((Character)player).GetMaxHealth() / 25f * 32f);
					foodBarRoot.SetSizeWithCurrentAnchors((Axis)0, num2);
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("FoodBar.Update() " + ex.Message + " " + ex.StackTrace));
				}
			}
		}
	}
	internal static class CustomHud
	{
		public static List<HudElement> elements;

		public static Dictionary<Groups, Transform> roots = new Dictionary<Groups, Transform>();

		public static Dictionary<Groups, Transform> templates = new Dictionary<Groups, Transform>();

		private static Transform hudRoot;

		private static Transform invRoot;

		private static Transform baseRoot;

		public static readonly string templateSuffix = "_template";

		private static readonly Element[] supportedElements = new Element[18]
		{
			new Element("HotKeyBar", Groups.HudRoot),
			new Element("BuildHud", Groups.HudRoot, "BuildHud/SelectedInfo"),
			new Element("MiniMap", Groups.HudRoot, "MiniMap/small"),
			new Element("GuardianPower", Groups.HudRoot),
			new Element("StatusEffects", Groups.HudRoot),
			new Element("SaveIcon", Groups.HudRoot),
			new Element("BadConnectionIcon", Groups.HudRoot),
			new Element("BuildHints", Groups.HudRoot, "KeyHints/BuildHints"),
			new Element("CombatHints", Groups.HudRoot, "KeyHints/CombatHints"),
			new Element("Player", Groups.Inventory, "Player", "PlayerInventory"),
			new Element("Container", Groups.Inventory, "Container", "ChestContainer"),
			new Element("Info", Groups.Inventory, "Info", "UITab"),
			new Element("Crafting", Groups.Inventory, "Crafting", "CraftingWindow"),
			new Element("BetterUI_HPBar", Groups.HudRoot, "BetterUI_HPBar", "HP Bar"),
			new Element("BetterUI_FoodBar", Groups.HudRoot, "BetterUI_FoodBar", "Food Bar"),
			new Element("BetterUI_StaminaBar", Groups.HudRoot, "BetterUI_StaminaBar", "Stamina Bar"),
			new Element("BetterUI_EitrBar", Groups.HudRoot, "BetterUI_EitrBar", "Eitr Bar"),
			new Element("QuickSlots", Groups.HudRoot, "QuickSlotsHotkeyBar", "QuickSlots")
		};

		public static void Load(Hud hud)
		{
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				hudRoot = ((Component)hud).transform.Find("hudroot");
				invRoot = ((Component)InventoryGui.instance).transform.Find("root");
				baseRoot = ((Component)MessageHud.instance).transform;
				roots[Groups.HudRoot] = hudRoot;
				roots[Groups.Inventory] = invRoot;
				if (Main.uiData.Value == "none" || Main.uiData.Value == "")
				{
					Helpers.DebugLine("User has no uiData. Creating basic template.");
					elements = new List<HudElement>();
				}
				else
				{
					try
					{
						elements = (List<HudElement>)Convert.FromBase64String(Main.uiData.Value).DeSerialize();
						Helpers.DebugLine($"User has {elements.Count} ui elements set.");
					}
					catch
					{
						Helpers.DebugLine("FAILED to DeSerialize uiData: " + Main.uiData.Value);
					}
					foreach (HudElement element in elements)
					{
						element.OnAfterDeserialize();
					}
				}
				if (elements.Count < supportedElements.Length)
				{
					Element[] array = supportedElements;
					for (int i = 0; i < array.Length; i++)
					{
						Element e = array[i];
						if (!elements.Exists((HudElement he) => he.Name == e.Name))
						{
							Helpers.DebugLine("Adding to elements: " + e.Name);
							elements.Add(new HudElement(e.Name, e.DisplayName, e.Group, e.LocationPath, Vector2.zero));
							if (elements.Count == supportedElements.Length)
							{
								break;
							}
						}
					}
				}
				else if (elements.Count > supportedElements.Length)
				{
					Helpers.DebugLine("Seems that your UI might be corrupted!", pref: true, warn: true);
				}
				CreateTemplates();
			}
			catch (Exception ex)
			{
				Helpers.DebugLine("Issue while CustomHud Load. " + ex.Message, pref: true, warn: true);
			}
		}

		public static void Save()
		{
			try
			{
				elements.RemoveAll((HudElement e) => e.Position == Vector2.zero);
				byte[] array = elements.Serialize();
				Helpers.DebugLine($"uiData bytes: {array.Length}");
				string value = Convert.ToBase64String(array);
				Main.uiData.Value = value;
			}
			catch (Exception ex)
			{
				Helpers.DebugLine("FAILED to Save: " + ex.Message);
			}
		}

		public static void ShowTemplates(bool show, int activeLayer)
		{
			foreach (HudElement element in elements)
			{
				if (activeLayer == (int)element.Group)
				{
					RectTransform val = LocateTemplateRect(element.Name);
					if (Object.op_Implicit((Object)(object)val))
					{
						((Component)val).gameObject.SetActive(show);
					}
				}
				else
				{
					RectTransform val2 = LocateTemplateRect(element.Name);
					if (Object.op_Implicit((Object)(object)val2))
					{
						((Component)val2).gameObject.SetActive(false);
					}
				}
			}
			if (!show)
			{
				Save();
			}
		}

		public static void UpdatePosition(string name, Vector2 posChange)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_006f: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			HudElement hudElement = elements.Find((HudElement e) => e.Name == name);
			if (hudElement.Name == name)
			{
				hudElement.Position += posChange;
				if (hudElement.Group == Groups.Inventory)
				{
					Vector2 val = Vector2.op_Implicit(Camera.main.ScreenToViewportPoint(Vector2.op_Implicit(posChange)));
					hudElement.AnchorMin += val;
					hudElement.AnchorMax += val;
				}
				PositionTemplate(hudElement);
			}
		}

		public static void UpdateScaleAndDimensions(string name, Vector2 dimensionChanges, float scaleChange)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			HudElement hudElement = elements.Find((HudElement e) => e.Name == name);
			if (hudElement.Name == name)
			{
				if (scaleChange != 0f)
				{
					hudElement.ChangeScale(scaleChange);
					((Character)Player.m_localPlayer).Message((MessageType)2, $"{hudElement.DisplayName} size: {hudElement.Scale}", 0, (Sprite)null);
				}
				if (dimensionChanges != Vector2.zero)
				{
					hudElement.ChangeXDims(dimensionChanges.x);
					hudElement.ChangeYDims(dimensionChanges.y);
					((Character)Player.m_localPlayer).Message((MessageType)2, $"{hudElement.DisplayName} dimensions: ({hudElement.XDimensions},{hudElement.YDimensions})", 0, (Sprite)null);
					PositionTemplate(hudElement);
				}
			}
			else
			{
				Helpers.DebugLine("Invalid call when updating element: " + name, pref: true, warn: true);
			}
		}

		private static void PositionTemplate(HudElement e)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0072: 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_0084: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				RectTransform val = LocateRectTransform(e.Group, e.Path);
				RectTransform val2 = LocateTemplateRect(e.Name);
				if (Object.op_Implicit((Object)(object)val))
				{
					if (e.Group == Groups.Inventory)
					{
						float scaleFactor = GameObject.Find("LoadingGUI").GetComponent<CanvasScaler>().scaleFactor;
						Camera.main.ViewportToScreenPoint(Vector2.op_Implicit(e.AnchorMax));
						_ = e.Position;
						val.anchorMin = e.AnchorMin;
						val.anchorMax = e.AnchorMax;
						val2.anchoredPosition = e.Position / scaleFactor;
					}
					else
					{
						val.anchoredPosition = e.Position;
						val2.anchoredPosition = e.Position;
					}
					((Transform)val).localScale = new Vector3(e.Scale * e.XDimensions, e.Scale * e.YDimensions);
					((Transform)val2).localScale = ((Transform)val).localScale;
				}
			}
			catch
			{
				Helpers.DebugLine("PositionTemplate Catch: " + e.Name);
			}
		}

		public static RectTransform LocateRectTransform(Groups group, string path)
		{
			try
			{
				roots.TryGetValue(group, out var value);
				if (group == Groups.Inventory)
				{
					value = ((Component)InventoryGui.instance).transform.Find("root");
				}
				return ((Component)value.Find(path)).GetComponent<RectTransform>();
			}
			catch
			{
				return null;
			}
		}

		public static RectTransform LocateTemplateRect(string name)
		{
			try
			{
				return ((Component)baseRoot.Find(name + templateSuffix)).GetComponent<RectTransform>();
			}
			catch
			{
				Helpers.DebugLine("Unable to find template for " + name, pref: true, warn: true);
				return null;
			}
		}

		public static void PositionTemplates()
		{
			foreach (HudElement element in elements)
			{
				PositionTemplate(element);
			}
		}

		private static void CreateTemplates()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			List<HudElement> list = new List<HudElement>();
			foreach (HudElement element in elements)
			{
				try
				{
					RectTransform val = LocateRectTransform(element.Group, element.Path);
					if (element.Position == Vector2.zero)
					{
						if (element.Group == Groups.Inventory)
						{
							element.Position = val.anchoredPosition;
							element.AnchorMin = val.anchorMin;
							element.AnchorMax = val.anchorMax;
						}
						else
						{
							element.Position = val.anchoredPosition;
						}
					}
					AddTemplateToHud(element, val);
				}
				catch
				{
					list.Add(element);
				}
			}
			if (list.Count <= 0)
			{
				return;
			}
			Helpers.DebugLine($"Removing {list.Count} unused elements.");
			foreach (HudElement item in list)
			{
				Helpers.DebugLine("Remove " + item.DisplayName + " as not used.");
				elements.Remove(item);
			}
		}

		private static void AddTemplateToHud(HudElement element, RectTransform rt)
		{
			//IL_00bf: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			Transform obj = Object.Instantiate<Transform>(hudRoot.Find("BuildHud/SelectedInfo"), baseRoot);
			((Object)((Component)obj).gameObject).name = element.Name + templateSuffix;
			((Component)obj.Find("selected_piece")).gameObject.SetActive(false);
			((Component)obj.Find("requirements")).gameObject.SetActive(false);
			TextMeshProUGUI val = ((Component)obj).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val).text = element.DisplayName ?? "";
			((TMP_Text)val).font = Hud.instance.m_pieceDescription.font;
			((TMP_Text)val).fontSize = 20f;
			((TMP_Text)val).alignment = (TextAlignmentOptions)544;
			((Component)obj).gameObject.SetActive(false);
			RectTransform component = ((Component)obj).GetComponent<RectTransform>();
			component.pivot = rt.pivot;
			component.anchorMin = rt.anchorMin;
			component.anchorMax = rt.anchorMax;
			component.offsetMin = rt.offsetMin;
			component.offsetMax = rt.offsetMax;
			component.sizeDelta = rt.sizeDelta;
			component.anchoredPosition = rt.anchoredPosition;
			((Transform)component).position = ((Transform)rt).position;
			((Transform)component).localEulerAngles = ((Transform)rt).localEulerAngles;
			((TMP_Text)val).enableAutoSizing = true;
		}
	}
	public static class ObjectSerialize
	{
		public static byte[] Serialize(this object obj)
		{
			if (obj == null)
			{
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			new BinaryFormatter().Serialize(memoryStream, obj);
			return Compress(memoryStream.ToArray());
		}

		public static object DeSerialize(this byte[] arrBytes)
		{
			using MemoryStream memoryStream = new MemoryStream();
			BinaryFormatter binaryFormatter = new BinaryFormatter();
			byte[] array = Decompress(arrBytes);
			memoryStream.Write(array, 0, array.Length);
			memoryStream.Seek(0L, SeekOrigin.Begin);
			return binaryFormatter.Deserialize(memoryStream);
		}

		public static byte[] Compress(byte[] input)
		{
			using MemoryStream memoryStream = new MemoryStream();
			using (GZipStream gZipStream = new GZipStream(memoryStream, CompressionMode.Compress))
			{
				gZipStream.Write(input, 0, input.Length);
			}
			return memoryStream.ToArray();
		}

		public static byte[] Decompress(byte[] input)
		{
			using MemoryStream memoryStream = new MemoryStream();
			using (MemoryStream stream = new MemoryStream(input))
			{
				using GZipStream gZipStream = new GZipStream(stream, CompressionMode.Decompress);
				gZipStream.CopyTo(memoryStream);
			}
			return memoryStream.ToArray();
		}
	}
	internal class Helpers
	{
		public static string Repeat(string value, int count)
		{
			return new StringBuilder(value.Length * count).Insert(0, value, count).ToString();
		}

		public static string TimeString(double val1, double val2)
		{
			TimeSpan timeSpan = TimeSpan.FromSeconds(val1 - val2);
			if (timeSpan.Hours <= 0)
			{
				if (timeSpan.Minutes <= 0)
				{
					return $"{timeSpan.Seconds:D2}s";
				}
				return $"{timeSpan.Minutes:D2}m {timeSpan.Seconds:D2}s";
			}
			return $"{timeSpan.Hours:D2}h {timeSpan.Minutes:D2}m {timeSpan.Seconds:D2}s";
		}

		public static string TimeString(double seconds)
		{
			TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
			if (timeSpan.Hours <= 0)
			{
				if (timeSpan.Minutes <= 0)
				{
					return $"{timeSpan.Seconds:D2}s";
				}
				return $"{timeSpan.Minutes:D2}m {timeSpan.Seconds:D2}s";
			}
			return $"{timeSpan.Hours:D2}h {timeSpan.Minutes:D2}m {timeSpan.Seconds:D2}s";
		}

		public static void DebugLine(string str = "", bool pref = true, bool warn = false)
		{
			if (Main.isDebug.Value)
			{
				if (warn)
				{
					Main.log.LogWarning((object)((pref ? ("[" + typeof(Main).Namespace + "] ") : "") + str));
				}
				else
				{
					Main.log.LogInfo((object)((pref ? ("[" + typeof(Main).Namespace + "] ") : "") + str));
				}
			}
		}

		public static bool CheckHeldKey(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return Input.GetKey(key);
			}
			catch
			{
				return false;
			}
		}
	}
	internal static class HoverText
	{
		private static readonly string useKey = "[<color=#ffff00ff><b>$KEY_Use</b></color>]";

		private static readonly string _containerBase = "[<color=#ffff00ff><b>$KEY_Use</b></color>] $piece_container_open";

		private static readonly string _cookItem = "[<color=#ffff00ff><b>$KEY_Use</b></color>] $piece_cstand_cook";

		private static readonly string _selectItem = "[<color=#ffff00ff><b>1-8</b></color>] $piece_cstand_cook";

		private static readonly string overCookColor = "red";

		private static readonly string smelterRoof = "<color=#ffff00ff>$piece_smelter_reqroof</color>";

		public static bool PatchFermenter(Fermenter fermenter, ref string hoverText)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			Status status = fermenter.GetStatus();
			if ((int)status != 1)
			{
				if ((int)status == 3)
				{
					string contentName = fermenter.GetContentName();
					hoverText = Localization.instance.Localize(fermenter.m_name + ", $piece_fermenter_ready \n" + contentName + "\n[<color=#ffff00ff><b>$KEY_Use</b></color>] $piece_fermenter_tap");
					return false;
				}
				return true;
			}
			string contentName2 = fermenter.GetContentName();
			if (fermenter.m_exposed)
			{
				hoverText = Localization.instance.Localize(fermenter.m_name + " ( " + contentName2 + ", $piece_fermenter_exposed )");
				return false;
			}
			string text = ((Main.timeLeftHoverTextFermenter.Value == Main.TimeLeftStyle.PercentageDone) ? $"{fermenter.GetFermentationTime() / (double)fermenter.m_fermentationDuration:P0}" : Helpers.TimeString((double)fermenter.m_fermentationDuration - fermenter.GetFermentationTime()));
			hoverText = Localization.instance.Localize(contentName2 + "\n$piece_fermenter_fermenting: " + text);
			return false;
		}

		public static void PatchBeeHive(Beehive beeHive, ref string hoverText)
		{
			int honeyLevel = beeHive.GetHoneyLevel();
			string text = string.Empty;
			if (honeyLevel < beeHive.m_maxHoney)
			{
				float @float = beeHive.m_nview.GetZDO().GetFloat("product", 0f);
				float num = beeHive.m_secPerUnit - @float;
				text = ((Main.timeLeftHoverTextBeeHive.Value != Main.TimeLeftStyle.PercentageDone) ? (Helpers.TimeString(num) + ", ") : $"{@float / beeHive.m_secPerUnit:P0}, ");
			}
			if (honeyLevel > 0)
			{
				hoverText = Localization.instance.Localize($"{beeHive.m_name} ( {text}{beeHive.m_honeyItem.m_itemData.m_shared.m_name} x {honeyLevel} ) \n[<color=#ffff00ff><b>$KEY_Use</b></color>] $piece_beehive_extract");
			}
			else
			{
				hoverText = Localization.instance.Localize(beeHive.m_name + " ( " + text + "$piece_container_empty ) \n[<color=#ffff00ff><b>$KEY_Use</b></color>] $piece_beehive_check");
			}
		}

		public static bool PatchPlant(Plant plant, ref string hoverText)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if ((int)plant.m_status == 0)
			{
				string text = ((Main.timeLeftHoverTextPlant.Value == Main.TimeLeftStyle.PercentageDone) ? $"{plant.TimeSincePlanted() / (double)plant.GetGrowTime():P0}" : Helpers.TimeString((double)plant.GetGrowTime() - plant.TimeSincePlanted()));
				hoverText = Localization.instance.Localize(plant.m_name + "\n" + text);
				return false;
			}
			return true;
		}

		public static string PatchContainer(Container container)
		{
			string text = Main.chestHasRoomHoverText.Value switch
			{
				Main.ChestHasRoomStyle.Percentage => $"{container.m_inventory.SlotsUsedPercentage():F0}%", 
				Main.ChestHasRoomStyle.ItemsSlashMaxRoom => $"{container.m_inventory.NrOfItems()}/{container.m_inventory.GetWidth() * container.m_inventory.GetHeight()}", 
				Main.ChestHasRoomStyle.AmountOfFreeSlots => $"{container.m_inventory.GetEmptySlots()}", 
				_ => $"{container.m_inventory.SlotsUsedPercentage():F0}%", 
			};
			return Localization.instance.Localize(container.m_name + " ( " + text + " )\n" + _containerBase);
		}

		public static bool PatchCookingStation(CookingStation cookingStation, ref string hoverText)
		{
			if (cookingStation.m_nview.IsOwner())
			{
				string text = "";
				int num = 0;
				string text2 = default(string);
				float num2 = default(float);
				Status val = default(Status);
				for (int i = 0; i < cookingStation.m_slots.Length; i++)
				{
					cookingStation.GetSlot(i, ref text2, ref num2, ref val);
					if (!(text2 != "") || !(text2 != ((Object)cookingStation.m_overCookedItem).name))
					{
						continue;
					}
					ItemConversion itemConversion = cookingStation.GetItemConversion(text2);
					if (text2 != null)
					{
						num++;
						if (num2 > itemConversion.m_cookTime)
						{
							string text3 = ((Main.timeLeftHoverTextCookingStation.Value == Main.TimeLeftStyle.PercentageDone) ? $"{num2 / (itemConversion.m_cookTime * 2f):P0}" : Helpers.TimeString(itemConversion.m_cookTime * 2f - num2));
							text = text + "\n" + cookingStation.m_overCookedItem.GetHoverName() + ": <color=" + overCookColor + ">" + text3 + "</color>";
						}
						else
						{
							string text4 = ((Main.timeLeftHoverTextCookingStation.Value == Main.TimeLeftStyle.PercentageDone) ? $"{num2 / itemConversion.m_cookTime:P0}" : Helpers.TimeString(itemConversion.m_cookTime - num2));
							text = text + "\n" + itemConversion.m_to.GetHoverName() + ": " + text4;
						}
					}
				}
				if (num > 0)
				{
					hoverText = ((num >= cookingStation.m_slots.Length) ? Localization.instance.Localize(cookingStation.m_name + text) : Localization.instance.Localize(cookingStation.m_name + "\n" + _cookItem + "\n" + _selectItem + text));
					return false;
				}
			}
			return true;
		}

		public static void PatchSmelter(Smelter smelter)
		{
			if (Object.op_Implicit((Object)(object)smelter.m_emptyOreSwitch) && smelter.m_spawnStack)
			{
				int processedQueueSize = smelter.GetProcessedQueueSize();
				smelter.m_emptyOreSwitch.m_hoverText = $"{smelter.m_name} {processedQueueSize} $piece_smelter_ready \n{useKey} {smelter.m_emptyOreTooltip}";
			}
			int queueSize = smelter.GetQueueSize();
			smelter.m_addOreSwitch.m_hoverText = $"{smelter.m_name} ({queueSize}/{smelter.m_maxOre}) ";
			if (queueSize > 0)
			{
				Debug.Log((object)$"{smelter.GetBakeTimer()}, {smelter.m_secPerProduct}, {queueSize}");
				Switch addOreSwitch = smelter.m_addOreSwitch;
				addOreSwitch.m_hoverText += Helpers.TimeString(smelter.m_secPerProduct * (float)queueSize - smelter.GetBakeTimer());
			}
			if (smelter.m_requiresRoof && !smelter.m_haveRoof && Mathf.Sin(Time.time * 10f) > 0f)
			{
				Switch addOreSwitch2 = smelter.m_addOreSwitch;
				addOreSwitch2.m_hoverText = addOreSwitch2.m_hoverText + " " + smelterRoof;
			}
			Switch addOreSwitch3 = smelter.m_addOreSwitch;
			addOreSwitch3.m_hoverText = addOreSwitch3.m_hoverText + " \n" + useKey + " " + smelter.m_addOreTooltip;
		}

		private static void CalculateSmelterBakeTime(Smelter smelter)
		{
			double deltaTime = smelter.GetDeltaTime();
			float accumulator = smelter.GetAccumulator();
			accumulator += (float)deltaTime;
			float num = (Object.op_Implicit((Object)(object)smelter.m_windmill) ? smelter.m_windmill.GetPowerOutput() : 1f);
			while (accumulator >= 1f)
			{
				accumulator -= 1f;
				float fuel = smelter.GetFuel();
				string queuedOre = smelter.GetQueuedOre();
				if ((smelter.m_maxFuel != 0 && !(fuel > 0f)) || !(queuedOre != "") || !(smelter.m_secPerProduct > 0f) || (smelter.m_requiresRoof && !smelter.m_haveRoof))
				{
					continue;
				}
				float num2 = 1f * num;
				if (smelter.m_maxFuel > 0)
				{
					float num3 = smelter.m_secPerProduct / (float)smelter.m_fuelPerProduct;
					fuel -= num2 / num3;
					if (fuel < 0f)
					{
						fuel = 0f;
					}
					smelter.SetFuel(fuel);
				}
				float bakeTimer = smelter.GetBakeTimer();
				bakeTimer += num2;
				smelter.SetBakeTimer(bakeTimer);
				if (bakeTimer > smelter.m_secPerProduct)
				{
					smelter.SetBakeTimer(0f);
					smelter.RemoveOneOre();
					smelter.QueueProcessed(queuedOre);
				}
			}
			if (smelter.GetQueuedOre() == "" || ((float)smelter.m_maxFuel > 0f && smelter.GetFuel() == 0f))
			{
				smelter.SpawnProcessed();
			}
			smelter.SetAccumulator(accumulator);
		}
	}
	[Serializable]
	public class HudElement
	{
		private readonly string name;

		private readonly string displayName;

		private readonly string path;

		private readonly Groups group;

		private float x;

		private float y;

		private float scale;

		private float dimensions;

		private float xDimensions;

		private float anchorMinX;

		private float anchorMinY;

		private float anchorMaxX;

		private float anchorMaxY;

		public string Name => name;

		public string DisplayName => displayName;

		public string Path => path;

		public Groups Group => group;

		public Vector2 Position
		{
			get
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				return new Vector2(x, y);
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				x = value.x;
				y = value.y;
			}
		}

		public Vector2 AnchorMin
		{
			get
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				return new Vector2(anchorMinX, anchorMinY);
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				anchorMinX = value.x;
				anchorMinY = value.y;
			}
		}

		public Vector2 AnchorMax
		{
			get
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				return new Vector2(anchorMaxX, anchorMaxY);
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				anchorMaxX = value.x;
				anchorMaxY = value.y;
			}
		}

		public float Scale => scale;

		public float XDimensions => xDimensions;

		public float YDimensions => dimensions;

		public HudElement(string name, string displayName, Groups group, string path, Vector2 position, float scale = 1f, float xDimensions = 1f, float yDimensions = 1f)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			this.name = name;
			this.displayName = displayName;
			this.path = path;
			this.group = group;
			x = position.x;
			y = position.y;
			this.scale = scale;
			this.xDimensions = xDimensions;
			dimensions = yDimensions;
		}

		public void ChangeScale(float change)
		{
			scale = (float)Math.Round(Mathf.Abs(scale + change), 1);
		}

		public void ChangeXDims(float change)
		{
			xDimensions = Mathf.Max(0.1f, (float)Math.Round(Mathf.Abs(xDimensions + change), 2));
		}

		public void ChangeYDims(float change)
		{
			dimensions = Mathf.Max(0.1f, (float)Math.Round(Mathf.Abs(dimensions + change), 2));
		}

		public void OnAfterDeserialize()
		{
			if (xDimensions < 0.1f)
			{
				xDimensions = 1f;
			}
			if (dimensions < 0.1f)
			{
				dimensions = 1f;
			}
		}
	}
	public readonly struct Element
	{
		private readonly string name;

		private readonly string displayName;

		private readonly Groups group;

		private readonly string locationPath;

		public string Name => name;

		public string DisplayName => displayName;

		public Groups Group => group;

		public string LocationPath => locationPath;

		public Element(string name, Groups group, string locationPath = "", string displayName = "")
		{
			this.name = name;
			this.group = group;
			this.locationPath = ((locationPath == "") ? name : locationPath);
			this.displayName = ((displayName == "") ? name : displayName);
		}
	}
	public enum Groups
	{
		HudRoot,
		Inventory,
		Other
	}
	public enum ParentRoot
	{
		Hud,
		Inventory,
		HudMessage,
		TopLeftMessage,
		Chat,
		EnemyHud,
		Store,
		Menu
	}
	public static class ElementHelper
	{
		public static void UpdateElement(GuiBar durabilityBar, Image icon, ItemData item)
		{
			if (Main.durabilityBarColorPalette.Value != Main.DurabilityBarStyle.Disabled && item.m_shared.m_useDurability && !(item.m_durability <= 0f))
			{
				DurabilityBar.UpdateColor(durabilityBar, item.GetDurabilityPercentage());
			}
		}
	}
	internal static class DurabilityBar
	{
		private static readonly Color[] normal = (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 readonly Color[] protanopia = (Color[])(object)new Color[4]
		{
			new Color(1f, 1f, 1f, 1f),
			new Color(0.878f, 1f, 0f, 1f),
			new Color(0.192f, 0.859f, 0.573f, 1f),
			new Color(0.11f, 0.435f, 0.973f, 1f)
		};

		private static readonly Array[] colorArray = new Array[2] { normal, protanopia };

		private static readonly Color[] activeColor = colorArray[(int)Main.durabilityBarColorPalette.Value] as Color[];

		public static void UpdateColor(GuiBar durabilityBar, float durability)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			durabilityBar.SetValue(durability);
			durabilityBar.ResetColor();
			if (durability >= 0.75f)
			{
				durabilityBar.SetColor(activeColor[0]);
			}
			else if (durability >= 0.5f)
			{
				durabilityBar.SetColor(activeColor[1]);
			}
			else if (durability >= 0.25f)
			{
				durabilityBar.SetColor(activeColor[2]);
			}
			else if (durability >= 0f)
			{
				durabilityBar.SetColor(activeColor[3]);
			}
		}
	}
	internal static class Stars
	{
		private static Color starColor = new Color(1f, 0.85882f, 0.23137f, 1f);

		public static void Draw(Element element, int quality_lvl)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			element.m_quality.textWrappingMode = (TextWrappingModes)3;
			string text;
			if (quality_lvl >= 5)
			{
				text = $"<color=#ffffffff><size=10>{quality_lvl}</size>x </color>★";
				element.m_quality.alignment = (TextAlignmentOptions)4100;
				element.m_quality.rectTransform.sizeDelta = new Vector2(60f, 20f);
				if (quality_lvl > 99998)
				{
					text = "<color=#ffffffff><size=10>MODDED</size> </color>★";
				}
			}
			else
			{
				text = Helpers.Repeat("★", quality_lvl);
				element.m_quality.rectTransform.sizeDelta = new Vector2((float)quality_lvl * 10f, 20f);
			}
			Object.Destroy((Object)(object)((Component)element.m_quality).GetComponent<Outline>());
			element.m_quality.text = "<size=10>" + text + "</size>";
			((Graphic)element.m_quality).color = starColor;
			element.m_quality.rectTransform.anchoredPosition = new Vector2(-4f, -6f);
		}

		public static string HoverText(int quality_lvl)
		{
			if (quality_lvl >= 5)
			{
				return $"{quality_lvl}x★";
			}
			if (quality_lvl > 99999)
			{
				return "Modded";
			}
			return Helpers.Repeat("★", quality_lvl);
		}
	}
	internal static class InventoryArmorTooltip
	{
		public static UITooltip tooltip;

		public static TMP_Text m_armor;

		public static void Awake(InventoryGui ig)
		{
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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)
			Transform parent = ig.m_armor.transform.parent;
			Transform val = Utils.FindChild(parent, "bkg", (IterativeSearchType)0);
			Transform val2 = Utils.FindChild(parent, "armor_icon", (IterativeSearchType)0);
			Transform val3 = Utils.FindChild(parent, "ac_text", (IterativeSearchType)0);
			GameObject elementPrefab = ig.m_containerGrid.m_elementPrefab;
			if (!((Object)(object)elementPrefab == (Object)null))
			{
				GameObject val4 = Object.Instantiate<GameObject>(elementPrefab, parent);
				((Behaviour)((Component)val4.transform.Find("equiped")).GetComponent<Image>()).enabled = false;
				((Behaviour)((Component)val4.transform.Find("queued")).GetComponent<Image>()).enabled = false;
				((Behaviour)((Component)val4.transform.Find("icon")).GetComponent<Image>()).enabled = false;
				((Behaviour)((Component)val4.transform.Find("amount")).GetComponent<TMP_Text>()).enabled = false;
				((Component)val4.transform.Find("durability")).gameObject.SetActive(false);
				((Behaviour)((Component)val4.transform.Find("binding")).GetComponent<TMP_Text>()).enabled = false;
				((Behaviour)((Component)val4.transform.Find("quality")).GetComponent<TMP_Text>()).enabled = false;
				((Component)val4.transform.Find("selected")).gameObject.SetActive(false);
				((Behaviour)((Component)val4.transform.Find("noteleport")).GetComponent<Image>()).enabled = false;
				((Behaviour)((Component)val4.transform.Find("foodicon")).GetComponent<Image>()).enabled = false;
				Object.Destroy((Object)(object)val4.GetComponent<UIInputHandler>());
				Object.Destroy((Object)(object)val4.GetComponent<Button>());
				val4.GetComponent<Image>().sprite = ((Component)val).GetComponent<Image>().sprite;
				((Graphic)val4.GetComponent<Image>()).color = ((Graphic)((Component)val).GetComponent<Image>()).color;
				((Graphic)val4.GetComponent<Image>()).material = ((Graphic)((Component)val).GetComponent<Image>()).material;
				RectTransform val5 = (RectTransform)(object)((val is RectTransform) ? val : null);
				Transform transform = val4.transform;
				Transform obj = ((transform is RectTransform) ? transform : null);
				((RectTransform)obj).anchoredPosition = val5.anchoredPosition;
				((RectTransform)obj).sizeDelta = val5.sizeDelta;
				val2.SetParent(val4.transform);
				val3.SetParent(val4.transform);
				((Behaviour)((Component)val).GetComponent<Image>()).enabled = false;
				UITooltip component = val4.GetComponent<UITooltip>();
				component.m_topic = DisplayXpLevel() + Player.m_localPlayer.GetPlayerName();
				tooltip = component;
				m_armor = ig.m_armor;
			}
		}

		public static void Update(Player player)
		{
			StringBuilder stringBuilder = new StringBuilder(256);
			WeaponStats(player, stringBuilder);
			BlockStats(player, stringBuilder);
			stringBuilder.AppendFormat("\n$item_armor: <color=#ffa500ff>{0}</color>", Convert.ToInt32(((Character)player).GetBodyArmor()));
			stringBuilder.Append("\n" + new string('─', 10) + "  Buffs  " + new string('─', 10));
			if (player.m_equipmentMovementModifier != 0f)
			{
				string arg = ((player.m_equipmentMovementModifier >= 0f) ? "green" : "red");
				stringBuilder.AppendFormat("\nMovement: <color={0}>{1}%</color>", arg, player.m_equipmentMovementModifier * 100f);
			}
			stringBuilder.Append("\n");
			tooltip.m_text = stringBuilder.ToString();
			tooltip.m_topic = DisplayXpLevel() + player.GetPlayerName();
		}

		private static string DisplayXpLevel()
		{
			if (!Main.showCharacterXP.Value)
			{
				return string.Empty;
			}
			return $"Lv.{XP.level} ";
		}

		private static void BlockStats(Player player, StringBuilder sb)
		{
			ItemData currentBlocker = ((Humanoid)player).GetCurrentBlocker();
			if (currentBlocker != null)
			{
				float skillFactor = ((Character)player).GetSkillFactor((SkillType)6);
				sb.AppendFormat("\n\n$item_blockpower: <color=#ffa500ff>{0}</color>", Convert.ToInt32(currentBlocker.GetBlockPower(skillFactor)));
				if (currentBlocker.m_shared.m_timedBlockBonus > 1f)
				{
					sb.AppendFormat("\n$item_deflection: <color=#ffa500ff>{0}</color>", currentBlocker.GetDeflectionForce(currentBlocker.m_quality));
					sb.AppendFormat("\n$item_parrybonus: <color=#ffa500ff>{0}x</color>", currentBlocker.m_shared.m_timedBlockBonus);
				}
			}
		}

		private static void WeaponStats(Player player, StringBuilder sb)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Invalid comparison between Unknown and I4
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			ItemData hand = GetHand(player, left: true);
			ItemData hand2 = GetHand(player, left: false);
			ItemData ammoItem = ((Humanoid)player).GetAmmoItem();
			if (hand != null && (int)hand.m_shared.m_itemType != 5)
			{
				DamageTypes damage = hand.GetDamage(hand.m_quality, (float)Game.m_worldLevel);
				if ((int)hand.m_shared.m_skillType == 8 && ammoItem != null)
				{
					((DamageTypes)(ref damage)).Add(ammoItem.GetDamage(), 1);
				}
				sb.AppendFormat("{0}", ((DamageTypes)(ref damage)).GetTooltipString(hand.m_shared.m_skillType));
				sb.AppendFormat("\n\n$item_knockback: <color=#ffa500ff>{0}</color>", hand.m_shared.m_attackForce);
				sb.AppendFormat("\n$item_backstab: <color=#ffa500ff>{0}x</color>", hand.m_shared.m_backstabBonus);
			}
			if (hand2 != null)
			{
				DamageTypes damage2 = hand2.GetDamage(hand2.m_quality, (float)Game.m_worldLevel);
				sb.AppendFormat("{0}", ((DamageTypes)(ref damage2)).GetTooltipString(hand2.m_shared.m_skillType));
				sb.AppendFormat("\n\n$item_knockback: <color=#ffa500ff>{0}</color>", hand2.m_shared.m_attackForce);
				sb.AppendFormat("\n$item_backstab: <color=#ffa500ff>{0}x</color>", hand2.m_shared.m_backstabBonus);
			}
		}

		private static ItemData GetHand(Player player, bool left)
		{
			if (left)
			{
				return ((Humanoid)player).m_leftItem ?? ((Humanoid)player).m_hiddenLeftItem;
			}
			return ((Humanoid)player).m_rightItem ?? ((Humanoid)player).m_hiddenRightItem;
		}
	}
	internal static class BetterTooltip
	{
		private static readonly int starsSize = 22;

		private static readonly char arrow = '→';

		private static StringBuilder _sb;

		private static ItemData _item;

		private static bool _crafting;

		private static int _quality;

		private static void Crafted()
		{
			_sb.AppendFormat("\n$item_crafter: <color=#ffa500ff>{0}</color>", _item.m_crafterName);
		}

		private static void CustomDamageCalculations(int newLvl, int oldLvl)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_00a0: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			DamageTypes damage = _item.GetDamage(oldLvl, (float)Game.m_worldLevel);
			DamageTypes damage2 = _item.GetDamage(newLvl, (float)Game.m_worldLevel);
			if (damage2.m_damage > damage.m_damage)
			{
				_sb.AppendFormat("\n$inventory_damage: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", damage.m_damage, arrow, damage2.m_damage);
			}
			if (damage2.m_blunt > damage.m_blunt)
			{
				_sb.AppendFormat("\n$inventory_blunt: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", damage.m_blunt, arrow, damage2.m_blunt);
			}
			if (damage2.m_slash > damage.m_slash)
			{
				_sb.AppendFormat("\n$inventory_slash: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", damage.m_slash, arrow, damage2.m_slash);
			}
			if (damage2.m_pierce > damage.m_pierce)
			{
				_sb.AppendFormat("\n$inventory_pierce: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", damage.m_pierce, arrow, damage2.m_pierce);
			}
			if (damage2.m_fire > damage.m_fire)
			{
				_sb.AppendFormat("\n$inventory_fire: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", damage.m_fire, arrow, damage2.m_fire);
			}
			if (damage2.m_frost > damage.m_frost)
			{
				_sb.AppendFormat("\n$inventory_frost: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", damage.m_frost, arrow, damage2.m_frost);
			}
			if (damage2.m_lightning > damage.m_lightning)
			{
				_sb.AppendFormat("\n$inventory_lightning: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", damage.m_lightning, arrow, damage2.m_lightning);
			}
			if (damage2.m_poison > damage.m_poison)
			{
				_sb.AppendFormat("\n$inventory_poison: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", damage.m_poison, arrow, damage2.m_poison);
			}
			if (damage2.m_spirit > damage.m_spirit)
			{
				_sb.AppendFormat("\n$inventory_spirit: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", damage.m_spirit, arrow, damage2.m_spirit);
			}
		}

		private static void Description()
		{
			_sb.Append(_item.m_shared.m_description + "\n");
		}

		private static void DamageModifiers()
		{
			string damageModifiersTooltipString = SE_Stats.GetDamageModifiersTooltipString(_item.m_shared.m_damageModifiers);
			if (damageModifiersTooltipString.Length > 0)
			{
				_sb.Append(damageModifiersTooltipString);
			}
		}

		private static void DLC()
		{
			_sb.Append("\n<color=#00ffffff>$item_dlc</color>");
		}

		private static void Durability(int qualityLevel, bool crafting)
		{
			if (crafting)
			{
				float maxDurability = _item.GetMaxDurability(qualityLevel);
				if (qualityLevel <= 1)
				{
					_sb.AppendFormat("\n$item_durability: <color=#ffa500ff>{0}</color>", maxDurability);
				}
				else if (qualityLevel > _item.m_shared.m_maxQuality)
				{
					float maxDurability2 = _item.GetMaxDurability(qualityLevel - 1);
					_sb.AppendFormat("\n$item_durability: <color=#ffa500ff>{0}</color>", maxDurability2);
				}
				else
				{
					float maxDurability3 = _item.GetMaxDurability(qualityLevel - 1);
					_sb.AppendFormat("\n$item_durability: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", maxDurability3, arrow, maxDurability);
				}
			}
			else
			{
				float maxDurability4 = _item.GetMaxDurability(qualityLevel);
				float durability = _item.m_durability;
				_sb.AppendFormat("\n$item_durability: {0} / {1}", durability.ToString("0"), maxDurability4.ToString("0"));
			}
		}

		private static void ItemType(int qualityLevel, float skillLevel)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected I4, but got Unknown
			//IL_019d: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: 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)
			ItemType itemType = _item.m_shared.m_itemType;
			DamageTypes damage;
			switch (itemType - 2)
			{
			case 0:
			{
				if (_item.m_shared.m_food > 0f)
				{
					_sb.AppendFormat("\n$item_food_health: <color=#ff0000ff>{0}</color>", _item.m_shared.m_food);
					_sb.AppendFormat("\n$item_food_stamina: <color=#ffff00ff>{0}</color>", _item.m_shared.m_foodStamina);
					if (_item.m_shared.m_foodEitr > 0f)
					{
						_sb.AppendFormat("\n$item_food_eitr: <color=#00ffffff>{0}</color>", _item.m_shared.m_foodEitr);
					}
					_sb.AppendFormat("\n$item_food_duration: <color=#ffa500ff>{0}s ({1}m)</color>", _item.m_shared.m_foodBurnTime, _item.m_shared.m_foodBurnTime / 60f);
					_sb.AppendFormat("\n$item_food_regen: <color=#ffa500ff>{0} hp/tick</color>", _item.m_shared.m_foodRegen);
				}
				string statusEffectTooltip3 = _item.GetStatusEffectTooltip(qualityLevel, skillLevel);
				if (statusEffectTooltip3.Length > 0)
				{
					_sb.Append("\n\n");
					_sb.Append(statusEffectTooltip3);
				}
				break;
			}
			case 1:
			case 2:
			case 12:
			case 13:
			{
				StringBuilder sb2 = _sb;
				damage = _item.GetDamage(qualityLevel, (float)Game.m_worldLevel);
				sb2.Append(((DamageTypes)(ref damage)).GetTooltipString(_item.m_shared.m_skillType));
				_sb.AppendFormat("\n$item_knockback: <color=#ffa500ff>{0}</color>", _item.m_shared.m_attackForce);
				_sb.AppendFormat("\n$item_backstab: <color=#ffa500ff>{0}x</color>", _item.m_shared.m_backstabBonus);
				_sb.AppendFormat("\n\n$item_blockpower: <color=#ffa500ff>{0}</color> <color=#ffff00ff>({1})</color>", _item.GetBaseBlockPower(qualityLevel), _item.GetBlockPowerTooltip(qualityLevel).ToString("0"));
				if (_item.m_shared.m_timedBlockBonus > 1f)
				{
					_sb.AppendFormat("\n$item_deflection: <color=#ffa500ff>{0}</color>", _item.GetDeflectionForce(qualityLevel));
					_sb.AppendFormat("\n$item_parrybonus: <color=#ffa500ff>{0}x</color>", _item.m_shared.m_timedBlockBonus);
				}
				string projectileTooltip = _item.GetProjectileTooltip(qualityLevel);
				if (projectileTooltip.Length > 0)
				{
					_sb.Append("\n\n");
					_sb.Append(projectileTooltip);
				}
				string statusEffectTooltip2 = _item.GetStatusEffectTooltip(qualityLevel, skillLevel);
				if (statusEffectTooltip2.Length > 0)
				{
					_sb.Append("\n\n");
					_sb.Append(statusEffectTooltip2);
				}
				_sb.Append("\n");
				break;
			}
			case 3:
				_sb.AppendFormat("\n$item_blockpower: <color=#ffa500ff>{0}</color> <color=#ffff00ff>({1})</color>", _item.GetBaseBlockPower(qualityLevel), _item.GetBlockPowerTooltip(qualityLevel).ToString("0"));
				if (_item.m_shared.m_timedBlockBonus > 1f)
				{
					_sb.AppendFormat("\n$item_deflection: <color=#ffa500ff>{0}</color>", _item.GetDeflectionForce(qualityLevel));
					_sb.AppendFormat("\n$item_parrybonus: <color=#ffa500ff>{0}x</color>", _item.m_shared.m_timedBlockBonus);
					_sb.Append("\n");
				}
				break;
			case 4:
			case 5:
			case 9:
			case 15:
			{
				_sb.AppendFormat("\n$item_armor: <color=#ffa500ff>{0}</color>", _item.GetArmor(qualityLevel, (float)Game.m_worldLevel));
				string statusEffectTooltip = _item.GetStatusEffectTooltip(qualityLevel, skillLevel);
				if (statusEffectTooltip.Length > 0)
				{
					_sb.Append("\n\n");
					_sb.Append(statusEffectTooltip);
				}
				break;
			}
			case 7:
			{
				StringBuilder sb = _sb;
				damage = _item.GetDamage(qualityLevel, (float)Game.m_worldLevel);
				sb.Append(((DamageTypes)(ref damage)).GetTooltipString(_item.m_shared.m_skillType));
				_sb.AppendFormat("\n$item_knockback: <color=#ffa500ff>{0}</color>", _item.m_shared.m_attackForce);
				break;
			}
			case 6:
			case 8:
			case 10:
			case 11:
			case 14:
				break;
			}
		}

		private static void Movement()
		{
			string arg = ((_item.m_shared.m_movementModifier >= 0f) ? "green" : "red");
			_sb.AppendFormat("\n$item_movement_modifier: <color={0}>{1}%</color>", arg, (_item.m_shared.m_movementModifier * 100f).ToString("+0;-0"));
		}

		private static void Quality(int qualityLevel)
		{
			_sb.AppendFormat("\n$item_quality: <color=#ffa500ff>{0}</color>", qualityLevel);
		}

		private static void RepairStation()
		{
			Recipe recipe = ObjectDB.instance.GetRecipe(_item);
			if ((Object)(object)recipe != (Object)null)
			{
				int minStationLevel = recipe.m_minStationLevel;
				_sb.AppendFormat("\n$item_repairlevel: <color=#ffa500ff>{0}</color>", minStationLevel.ToString());
			}
		}

		private static void Stars(int qualityLevel)
		{
			string arg = Helpers.Repeat("★", qualityLevel);
			_sb.AppendFormat("\n<size={0}><color=#ffff00ff>{1}</color></size>", starsSize, arg);
		}

		private static void StatusEffect(string effectText)
		{
			string arg = $"$item_seteffect ({_item.m_shared.m_setSize})";
			_sb.AppendFormat("\n\n<color=#c0c0c0ff>{0}</color>", arg);
			_sb.AppendFormat("\n<color=#ffa500ff>{0}</color>", effectText);
		}

		private static void Teleport()
		{
			_sb.Append("\n<color=#ff0000ff>$item_noteleport</color>");
		}

		private static void UpgradeStats(Player localPlayer)
		{
			//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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected I4, but got Unknown
			//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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			int quality = _quality;
			int num = _quality - 1;
			ItemType itemType = _item.m_shared.m_itemType;
			DamageTypes damage;
			switch (itemType - 3)
			{
			case 0:
			case 1:
			case 11:
			case 12:
			{
				damage = _item.GetDamage(quality, (float)Game.m_worldLevel);
				float totalDamage = ((DamageTypes)(ref damage)).GetTotalDamage();
				damage = _item.GetDamage(num, (float)Game.m_worldLevel);
				if (totalDamage > ((DamageTypes)(ref damage)).GetTotalDamage())
				{
					CustomDamageCalculations(quality, num);
				}
				else
				{
					StringBuilder sb2 = _sb;
					damage = _item.GetDamage(quality, (float)Game.m_worldLevel);
					sb2.Append(((DamageTypes)(ref damage)).GetTooltipString(_item.m_shared.m_skillType));
				}
				_sb.AppendFormat("\n$item_knockback: <color=#ffa500ff>{0}</color>", _item.m_shared.m_attackForce);
				_sb.AppendFormat("\n$item_backstab: <color=#ffa500ff>{0}x</color>", _item.m_shared.m_backstabBonus);
				if (_item.GetBaseBlockPower(quality) > _item.GetBaseBlockPower(num))
				{
					_sb.AppendFormat("\n\n$item_blockpower: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", _item.GetBaseBlockPower(num), arrow, _item.GetBaseBlockPower(quality));
				}
				else
				{
					_sb.AppendFormat("\n\n$item_blockpower: <color=#ffa500ff>{0}</color> <color=#ffff00ff>({1})</color>", _item.GetBaseBlockPower(quality), _item.GetBlockPowerTooltip(quality).ToString("0"));
				}
				if (_item.m_shared.m_timedBlockBonus > 1f)
				{
					if (_item.GetDeflectionForce(quality) > _item.GetDeflectionForce(num))
					{
						_sb.AppendFormat("\n$item_deflection: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", _item.GetDeflectionForce(num), arrow, _item.GetDeflectionForce(quality));
					}
					else
					{
						_sb.AppendFormat("\n$item_deflection: <color=#ffa500ff>{0}</color>", _item.GetDeflectionForce(quality));
					}
					_sb.AppendFormat("\n$item_parrybonus: <color=#ffa500ff>{0}x</color>", _item.m_shared.m_timedBlockBonus);
				}
				string projectileTooltip = _item.GetProjectileTooltip(quality);
				if (projectileTooltip.Length > 0)
				{
					_sb.Append("\n\n");
					_sb.Append(projectileTooltip);
				}
				string statusEffectTooltip2 = _item.GetStatusEffectTooltip(quality, ((Character)localPlayer).GetSkillLevel(_item.m_shared.m_skillType));
				if (statusEffectTooltip2.Length > 0)
				{
					_sb.Append("\n\n");
					_sb.Append(statusEffectTooltip2);
				}
				_sb.Append("\n");
				break;
			}
			case 2:
				if (_item.GetBaseBlockPower(quality) > _item.GetBaseBlockPower(num))
				{
					_sb.AppendFormat("\n$item_blockpower: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", _item.GetBaseBlockPower(num), arrow, _item.GetBaseBlockPower(quality));
				}
				else
				{
					_sb.AppendFormat("\n$item_blockpower: <color=#ffa500ff>{0}</color> <color=#ffff00ff>({1})</color>", _item.GetBaseBlockPower(quality), _item.GetBlockPowerTooltip(quality).ToString("0"));
				}
				if (_item.m_shared.m_timedBlockBonus > 1f)
				{
					if (_item.GetDeflectionForce(quality) > _item.GetDeflectionForce(num))
					{
						_sb.AppendFormat("\n$item_deflection: <color=#c0c0c0ff>{0}</color> {1} <color=#ffa500ff>{2}</color>", _item.GetDeflectionForce(num), arrow, _item.GetDeflectionForce(quality));
					}
					else
					{
						_sb.AppendFormat("\n$item_deflection: <color=#ffa500ff>{0}</color>", _item.GetDeflectionForce(quality));
					}
					_sb.A