Decompiled source of HeldItemNameHud v1.0.1

BepInEx/plugins/HeldItemNameHud/HeldItemNameHud.dll

Decompiled 6 hours ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FishNet.Connection;
using FishNet.Object;
using HarmonyLib;
using HeldItemNameHud.Configuration;
using HeldItemNameHud.Localization;
using HeldItemNameHud.UI;
using HowtoFishLocalizationAPI.Api;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HeldItemNameHud")]
[assembly: AssemblyDescription("Held item name HUD for How to Fish by Ice Box Studio")]
[assembly: AssemblyCompany("Ice Box Studio")]
[assembly: AssemblyProduct("HeldItemNameHud")]
[assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")]
[assembly: ComVisible(false)]
[assembly: Guid("b0f98ff7-385a-47b4-8c22-1c4e6eaeda20")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.1.0")]
namespace HeldItemNameHud
{
	[BepInPlugin("IceBoxStudio.HowToFish.HeldItemNameHud", "HeldItemNameHud", "1.0.1")]
	[BepInDependency("IceBoxStudio.HowToFish.LocalizationAPI", "1.0.0")]
	public sealed class HeldItemNameHudPlugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				Log.LogInfo((object)"=============================================");
				Log.LogInfo((object)("HeldItemNameHud " + I18n.Text("plugin.initializing")));
				Log.LogInfo((object)(I18n.Text("plugin.author_prefix") + "Ice Box Studio(https://steamcommunity.com/id/ibox666/)"));
				ConfigManager.Init(((BaseUnityPlugin)this).Config);
				_harmony = new Harmony("IceBoxStudio.HowToFish.HeldItemNameHud");
				_harmony.PatchAll(Assembly.GetExecutingAssembly());
				Log.LogInfo((object)("HeldItemNameHud " + I18n.Text("plugin.initialized")));
				Log.LogInfo((object)"=============================================");
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Failed to initialize HeldItemNameHud: {arg}");
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "IceBoxStudio.HowToFish.HeldItemNameHud";

		public const string PLUGIN_NAME = "HeldItemNameHud";

		public const string PLUGIN_VERSION = "1.0.1";
	}
	internal static class HeldItemNameRuntime
	{
		internal static void PlayerStarted(Player player)
		{
			if (!((Object)(object)player == (Object)null) && !(((NetworkBehaviour)player).Owner == (NetworkConnection)null) && ((NetworkBehaviour)player).Owner.IsLocalClient)
			{
				HeldItemNameUi.Attach();
				BaitNameUi.Attach();
				HeldItemNameUi.HeldChanged(player.Holding.HeldItem);
			}
		}

		internal static void PlayerStopped(Player player)
		{
			if (!((Object)(object)player == (Object)null) && !(((NetworkBehaviour)player).Owner == (NetworkConnection)null) && ((NetworkBehaviour)player).Owner.IsLocalClient)
			{
				HeldItemNameUi.DestroyCurrent();
				BaitNameUi.DestroyCurrent();
			}
		}

		internal static void HeldChanged(Item item)
		{
			HeldItemNameUi.HeldChanged(item);
		}

		internal static void BaitChanged()
		{
			BaitNameUi.BaitChanged();
		}

		internal static void Tick()
		{
			HeldItemNameUi.Tick();
			BaitNameUi.Tick();
		}
	}
}
namespace HeldItemNameHud.UI
{
	internal sealed class BaitNameUi : MonoBehaviour
	{
		private const float MaxWidth = 420f;

		private const float ScreenPadding = 40f;

		private const float Height = 64f;

		private const float Gap = 8f;

		private static readonly FieldInfo NameField = AccessTools.Field(typeof(BaitInfo), "_name");

		private static BaitNameUi _current;

		private RectTransform _root;

		private CanvasGroup _canvas;

		private TextMeshProUGUI _name;

		private BaitInfo _lastBait;

		private string _lastText;

		private float _shownAt;

		private bool _built;

		internal static void Attach()
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_current) || !Object.op_Implicit((Object)(object)Player.LocalPlayer) || !Object.op_Implicit((Object)(object)Player.LocalPlayer.Inventory))
			{
				return;
			}
			object? value = AccessTools.Field(typeof(PlayerInventory), "_baitSlot").GetValue(Player.LocalPlayer.Inventory);
			BaitSlot val = (BaitSlot)((value is BaitSlot) ? value : null);
			RectTransform val2 = (RectTransform)(Object.op_Implicit((Object)(object)val) ? /*isinst with value type is only supported in some contexts*/: null);
			if (Object.op_Implicit((Object)(object)val2))
			{
				GameObject val3 = new GameObject("Held Item Name HUD Bait", new Type[1] { typeof(RectTransform) });
				val3.transform.SetParent((Transform)(object)val2, false);
				_current = val3.AddComponent<BaitNameUi>();
				if (!_current.Build())
				{
					Object.Destroy((Object)(object)val3);
					_current = null;
				}
			}
		}

		internal static void Tick()
		{
			if (!Object.op_Implicit((Object)(object)_current))
			{
				Attach();
			}
			if (Object.op_Implicit((Object)(object)_current))
			{
				_current.Run();
			}
		}

		internal static void BaitChanged()
		{
			if (Object.op_Implicit((Object)(object)_current))
			{
				_current.Pulse();
			}
		}

		internal static void DestroyCurrent()
		{
			if (Object.op_Implicit((Object)(object)_current))
			{
				Object.Destroy((Object)(object)((Component)_current).gameObject);
			}
			_current = null;
		}

		private bool Build()
		{
			//IL_002c: 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_0060: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI canvasTextPrefab = PlayerUI.CanvasTextPrefab;
			if (!Object.op_Implicit((Object)(object)canvasTextPrefab))
			{
				return false;
			}
			_root = ((Component)this).GetComponent<RectTransform>();
			_root.anchorMin = new Vector2(0.5f, 1f);
			_root.anchorMax = new Vector2(0.5f, 1f);
			_root.pivot = new Vector2(0.5f, 0f);
			_root.anchoredPosition = new Vector2(0f, 8f);
			_root.sizeDelta = new Vector2(420f, 64f);
			_canvas = ((Component)this).gameObject.AddComponent<CanvasGroup>();
			_canvas.blocksRaycasts = false;
			_canvas.interactable = false;
			_name = Object.Instantiate<TextMeshProUGUI>(canvasTextPrefab, ((Component)this).transform);
			((Object)_name).name = "BaitName";
			((TMP_Text)_name).rectTransform.anchorMin = Vector2.zero;
			((TMP_Text)_name).rectTransform.anchorMax = Vector2.one;
			((TMP_Text)_name).rectTransform.offsetMin = Vector2.zero;
			((TMP_Text)_name).rectTransform.offsetMax = Vector2.zero;
			((TMP_Text)_name).alignment = (TextAlignmentOptions)514;
			((TMP_Text)_name).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)_name).overflowMode = (TextOverflowModes)0;
			((TMP_Text)_name).fontStyle = (FontStyles)1;
			((Graphic)_name).raycastTarget = false;
			_built = true;
			LocalizationApi.LanguageChanged += OnLanguageChanged;
			SetAlpha(0f);
			return true;
		}

		private void Run()
		{
			if (!_built || !Object.op_Implicit((Object)(object)Player.LocalPlayer) || !Object.op_Implicit((Object)(object)Player.LocalPlayer.Inventory))
			{
				SetAlpha(0f);
				return;
			}
			Player localPlayer = Player.LocalPlayer;
			if (localPlayer.Dying.IsDead || PauseManager.IsPaused || PlayerThinking.IsThinking || PlayerUI.UIDisabled)
			{
				SetAlpha(0f);
				return;
			}
			BaitInfo bait = GetBait(localPlayer);
			if (!Show(bait))
			{
				SetAlpha(0f);
				return;
			}
			ApplyLayout();
			ApplyAppearance();
			SetAlpha(Alpha());
		}

		private static BaitInfo GetBait(Player player)
		{
			byte curBait = player.Inventory.CurBait;
			if (curBait == 0 && Object.op_Implicit((Object)(object)player.Holding) && Object.op_Implicit((Object)(object)player.Holding.HeldItem) && Object.op_Implicit((Object)(object)player.Holding.HeldItem.FishingRod))
			{
				return player.Holding.HeldItem.FishingRod.GetCurBait();
			}
			if (GameInfo.AllBaits == null || curBait >= GameInfo.AllBaits.Count)
			{
				return null;
			}
			return GameInfo.AllBaits[curBait];
		}

		private bool Show(BaitInfo bait)
		{
			return Show(bait, force: false);
		}

		private bool Show(BaitInfo bait, bool force)
		{
			if (!Object.op_Implicit((Object)(object)bait))
			{
				Clear();
				return false;
			}
			string name = GetName(bait);
			if (string.IsNullOrWhiteSpace(name))
			{
				Clear();
				return false;
			}
			bool num = force || !Object.op_Implicit((Object)(object)_lastBait) || ((Object)(object)_lastBait != (Object)(object)bait && _lastText != name);
			_lastBait = bait;
			_lastText = name;
			((TMP_Text)_name).text = name;
			if (num)
			{
				_shownAt = Time.unscaledTime;
			}
			return true;
		}

		private void Pulse()
		{
			if (Object.op_Implicit((Object)(object)Player.LocalPlayer) && Object.op_Implicit((Object)(object)Player.LocalPlayer.Inventory))
			{
				BaitInfo bait = GetBait(Player.LocalPlayer);
				if (!Show(bait, force: true))
				{
					SetAlpha(0f);
					return;
				}
				ApplyLayout();
				ApplyAppearance();
				SetAlpha(Alpha());
			}
		}

		private static string GetName(BaitInfo bait)
		{
			string text = null;
			try
			{
				text = bait.NameLocalized;
			}
			catch (ArgumentException)
			{
				text = null;
			}
			if (!string.IsNullOrWhiteSpace(text))
			{
				return text;
			}
			return NameField?.GetValue(bait) as string;
		}

		private void Clear()
		{
			_lastBait = null;
			_lastText = null;
		}

		private void ApplyLayout()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			_root.sizeDelta = new Vector2(GetWidth(), 64f);
			((Transform)_root).localScale = Vector3.one * ConfigManager.Scale;
			FitText(ConfigManager.LargeText ? (ConfigManager.FontSize * 1.4f) : ConfigManager.FontSize);
		}

		private float GetWidth()
		{
			Canvas componentInParent = ((Component)_root).GetComponentInParent<Canvas>();
			float num = (Object.op_Implicit((Object)(object)componentInParent) ? Mathf.Max(componentInParent.scaleFactor, 0.01f) : 1f);
			float scale = ConfigManager.Scale;
			float num2 = ((float)Screen.width / num - 40f) / scale;
			return Mathf.Min(420f / scale, Mathf.Max(120f, num2));
		}

		private void FitText(float maxSize)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			((TMP_Text)_name).fontSize = maxSize;
			Rect rect = ((TMP_Text)_name).rectTransform.rect;
			float width = ((Rect)(ref rect)).width;
			if (width <= 0f || ((TMP_Text)_name).GetPreferredValues(((TMP_Text)_name).text).x <= width)
			{
				return;
			}
			float num = 10f;
			float num2 = maxSize;
			for (int i = 0; i < 8; i++)
			{
				float num3 = (num + num2) * 0.5f;
				((TMP_Text)_name).fontSize = num3;
				if (((TMP_Text)_name).GetPreferredValues(((TMP_Text)_name).text).x <= width)
				{
					num = num3;
				}
				else
				{
					num2 = num3;
				}
			}
			((TMP_Text)_name).fontSize = num;
		}

		private void ApplyAppearance()
		{
			//IL_000e: 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_0013: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Color color = (ConfigManager.HighContrast ? Color.white : ConfigManager.NormalColor);
			color.a *= ConfigManager.Opacity;
			((Graphic)_name).color = color;
			((TMP_Text)_name).outlineColor = Color32.op_Implicit(Color.black);
			((TMP_Text)_name).outlineWidth = (ConfigManager.HighContrast ? 0.25f : 0.15f);
		}

		private float Alpha()
		{
			if (ConfigManager.AlwaysShow)
			{
				return 1f;
			}
			float num = Time.unscaledTime - _shownAt;
			if (ConfigManager.DisableAnimation)
			{
				if (!(num <= ConfigManager.ShowSeconds))
				{
					return 0f;
				}
				return 1f;
			}
			float fadeSeconds = ConfigManager.FadeSeconds;
			if (num <= fadeSeconds)
			{
				if (!(fadeSeconds <= 0f))
				{
					return num / fadeSeconds;
				}
				return 1f;
			}
			float num2 = fadeSeconds + ConfigManager.ShowSeconds;
			if (num <= num2)
			{
				return 1f;
			}
			float num3 = num2 + fadeSeconds;
			if (!(num >= num3) && !(fadeSeconds <= 0f))
			{
				return 1f - (num - num2) / fadeSeconds;
			}
			return 0f;
		}

		private void SetAlpha(float alpha)
		{
			_canvas.alpha = Mathf.Clamp01(alpha);
		}

		private void OnLanguageChanged(string language)
		{
			if (Object.op_Implicit((Object)(object)Player.LocalPlayer) && Object.op_Implicit((Object)(object)Player.LocalPlayer.Inventory))
			{
				Show(GetBait(Player.LocalPlayer));
			}
		}

		private void OnDestroy()
		{
			LocalizationApi.LanguageChanged -= OnLanguageChanged;
			if ((Object)(object)_current == (Object)(object)this)
			{
				_current = null;
			}
		}
	}
	internal sealed class HeldItemNameUi : MonoBehaviour
	{
		private const float MaxWidth = 960f;

		private const float ScreenPadding = 40f;

		private const float Height = 100f;

		private static HeldItemNameUi _current;

		private RectTransform _root;

		private CanvasGroup _canvas;

		private TextMeshProUGUI _name;

		private Item _lastItem;

		private string _lastText;

		private float _shownAt;

		private bool _built;

		internal static void Attach()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)_current))
			{
				return;
			}
			Transform fXCanvasTrans = PlayerUI.FXCanvasTrans;
			if (Object.op_Implicit((Object)(object)fXCanvasTrans))
			{
				GameObject val = new GameObject("Held Item Name HUD", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(fXCanvasTrans, false);
				_current = val.AddComponent<HeldItemNameUi>();
				if (!_current.Build())
				{
					Object.Destroy((Object)(object)val);
					_current = null;
				}
			}
		}

		internal static void Tick()
		{
			if (Object.op_Implicit((Object)(object)_current))
			{
				_current.Run();
			}
		}

		internal static void HeldChanged(Item item)
		{
			if (Object.op_Implicit((Object)(object)_current))
			{
				_current.Show(item);
			}
		}

		internal static void DestroyCurrent()
		{
			if (Object.op_Implicit((Object)(object)_current))
			{
				Object.Destroy((Object)(object)((Component)_current).gameObject);
			}
			_current = null;
		}

		private bool Build()
		{
			//IL_002c: 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_0060: 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_00da: 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_0104: 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)
			TextMeshProUGUI canvasTextPrefab = PlayerUI.CanvasTextPrefab;
			if (!Object.op_Implicit((Object)(object)canvasTextPrefab))
			{
				return false;
			}
			_root = ((Component)this).GetComponent<RectTransform>();
			_root.anchorMin = new Vector2(0.5f, 0f);
			_root.anchorMax = new Vector2(0.5f, 0f);
			_root.pivot = new Vector2(0.5f, 0f);
			_root.sizeDelta = new Vector2(960f, 100f);
			_canvas = ((Component)this).gameObject.AddComponent<CanvasGroup>();
			_canvas.blocksRaycasts = false;
			_canvas.interactable = false;
			_name = Object.Instantiate<TextMeshProUGUI>(canvasTextPrefab, ((Component)this).transform);
			((Object)_name).name = "HeldItemName";
			((TMP_Text)_name).rectTransform.anchorMin = Vector2.zero;
			((TMP_Text)_name).rectTransform.anchorMax = Vector2.one;
			((TMP_Text)_name).rectTransform.offsetMin = Vector2.zero;
			((TMP_Text)_name).rectTransform.offsetMax = Vector2.zero;
			((TMP_Text)_name).alignment = (TextAlignmentOptions)514;
			((TMP_Text)_name).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)_name).overflowMode = (TextOverflowModes)0;
			((TMP_Text)_name).fontStyle = (FontStyles)1;
			((Graphic)_name).raycastTarget = false;
			_built = true;
			LocalizationApi.LanguageChanged += OnLanguageChanged;
			SetAlpha(0f);
			return true;
		}

		private void Run()
		{
			if (!_built || !Object.op_Implicit((Object)(object)Player.LocalPlayer) || !Object.op_Implicit((Object)(object)Player.LocalPlayer.Holding))
			{
				SetAlpha(0f);
				return;
			}
			Player localPlayer = Player.LocalPlayer;
			Item heldItem = localPlayer.Holding.HeldItem;
			if (!Object.op_Implicit((Object)(object)heldItem))
			{
				Clear();
				SetAlpha(0f);
			}
			else if (localPlayer.Dying.IsDead || PauseManager.IsPaused || PlayerThinking.IsThinking || PlayerUI.UIDisabled)
			{
				SetAlpha(0f);
			}
			else if (!Show(heldItem))
			{
				SetAlpha(0f);
			}
			else
			{
				ApplyLayout();
				ApplyAppearance();
				SetAlpha(Alpha());
			}
		}

		private bool Show(Item item)
		{
			if (!Object.op_Implicit((Object)(object)item))
			{
				Clear();
				return false;
			}
			string name = item.GetName();
			if (string.IsNullOrWhiteSpace(name))
			{
				Clear();
				return false;
			}
			string text = ((Object.op_Implicit((Object)(object)item.Creature) && item.Creature.IsDrip) ? (LocalizationManager.DripLocalized.GetLocalizedString() + " " + name) : name);
			bool num = !Object.op_Implicit((Object)(object)_lastItem) || ((Object)(object)_lastItem != (Object)(object)item && _lastText != text);
			_lastItem = item;
			_lastText = text;
			((TMP_Text)_name).text = text;
			if (num)
			{
				_shownAt = Time.unscaledTime;
			}
			return true;
		}

		private void Clear()
		{
			_lastItem = null;
			_lastText = null;
		}

		private void ApplyLayout()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			_root.sizeDelta = new Vector2(GetWidth(), 100f);
			_root.anchoredPosition = new Vector2(0f, ConfigManager.HotbarOffset);
			((Transform)_root).localScale = Vector3.one * ConfigManager.Scale;
			FitText(ConfigManager.LargeText ? (ConfigManager.FontSize * 1.4f) : ConfigManager.FontSize);
		}

		private float GetWidth()
		{
			Canvas componentInParent = ((Component)_root).GetComponentInParent<Canvas>();
			float num = (Object.op_Implicit((Object)(object)componentInParent) ? Mathf.Max(componentInParent.scaleFactor, 0.01f) : 1f);
			float scale = ConfigManager.Scale;
			float num2 = ((float)Screen.width / num - 40f) / scale;
			return Mathf.Min(960f / scale, Mathf.Max(120f, num2));
		}

		private void FitText(float maxSize)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			((TMP_Text)_name).fontSize = maxSize;
			Rect rect = ((TMP_Text)_name).rectTransform.rect;
			float width = ((Rect)(ref rect)).width;
			if (width <= 0f || ((TMP_Text)_name).GetPreferredValues(((TMP_Text)_name).text).x <= width)
			{
				return;
			}
			float num = 10f;
			float num2 = maxSize;
			for (int i = 0; i < 8; i++)
			{
				float num3 = (num + num2) * 0.5f;
				((TMP_Text)_name).fontSize = num3;
				if (((TMP_Text)_name).GetPreferredValues(((TMP_Text)_name).text).x <= width)
				{
					num = num3;
				}
				else
				{
					num2 = num3;
				}
			}
			((TMP_Text)_name).fontSize = num;
		}

		private void ApplyAppearance()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_003d: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Object.op_Implicit((Object)(object)_lastItem) && Object.op_Implicit((Object)(object)_lastItem.Creature) && _lastItem.Creature.IsDrip;
			Color color = (Color)((!ConfigManager.HighContrast) ? (flag ? ConfigManager.DripColor : ConfigManager.NormalColor) : (flag ? new Color(1f, 0.9f, 0.1f, 1f) : Color.white));
			color.a *= ConfigManager.Opacity;
			((Graphic)_name).color = color;
			((TMP_Text)_name).outlineColor = Color32.op_Implicit(Color.black);
			((TMP_Text)_name).outlineWidth = (ConfigManager.HighContrast ? 0.25f : 0.15f);
		}

		private float Alpha()
		{
			if (ConfigManager.AlwaysShow)
			{
				return 1f;
			}
			float num = Time.unscaledTime - _shownAt;
			if (ConfigManager.DisableAnimation)
			{
				if (!(num <= ConfigManager.ShowSeconds))
				{
					return 0f;
				}
				return 1f;
			}
			float fadeSeconds = ConfigManager.FadeSeconds;
			if (num <= fadeSeconds)
			{
				if (!(fadeSeconds <= 0f))
				{
					return num / fadeSeconds;
				}
				return 1f;
			}
			float num2 = fadeSeconds + ConfigManager.ShowSeconds;
			if (num <= num2)
			{
				return 1f;
			}
			float num3 = num2 + fadeSeconds;
			if (!(num >= num3) && !(fadeSeconds <= 0f))
			{
				return 1f - (num - num2) / fadeSeconds;
			}
			return 0f;
		}

		private void SetAlpha(float alpha)
		{
			_canvas.alpha = Mathf.Clamp01(alpha);
		}

		private void OnLanguageChanged(string language)
		{
			if (Object.op_Implicit((Object)(object)Player.LocalPlayer) && Object.op_Implicit((Object)(object)Player.LocalPlayer.Holding))
			{
				Show(Player.LocalPlayer.Holding.HeldItem);
			}
		}

		private void OnDestroy()
		{
			LocalizationApi.LanguageChanged -= OnLanguageChanged;
			if ((Object)(object)_current == (Object)(object)this)
			{
				_current = null;
			}
		}
	}
}
namespace HeldItemNameHud.Patches
{
	[HarmonyPatch(typeof(PlayerInventory), "OnCurBaitChange", new Type[]
	{
		typeof(byte),
		typeof(byte),
		typeof(bool)
	})]
	internal static class BaitPatch
	{
		private static void Postfix(PlayerInventory __instance, bool __2)
		{
			if (!__2 && Object.op_Implicit((Object)(object)Player.LocalPlayer) && !((Object)(object)Player.LocalPlayer.Inventory != (Object)(object)__instance))
			{
				HeldItemNameRuntime.BaitChanged();
			}
		}
	}
	[HarmonyPatch(typeof(PlayerHolding), "SetHeldItem")]
	internal static class HoldingPatch
	{
		private static void Postfix(PlayerHolding __instance, Item __0)
		{
			if (Object.op_Implicit((Object)(object)Player.LocalPlayer) && !((Object)(object)Player.LocalPlayer.Holding != (Object)(object)__instance))
			{
				HeldItemNameRuntime.HeldChanged(__0);
			}
		}
	}
	[HarmonyPatch(typeof(PlayerUI), "Update")]
	internal static class HudUpdatePatch
	{
		private static void Postfix()
		{
			HeldItemNameRuntime.Tick();
		}
	}
	[HarmonyPatch(typeof(Player), "OnStartClient")]
	internal static class PlayerStartPatch
	{
		private static void Postfix(Player __instance)
		{
			HeldItemNameRuntime.PlayerStarted(__instance);
		}
	}
	[HarmonyPatch(typeof(Player), "OnStopClient")]
	internal static class PlayerStopPatch
	{
		private static void Postfix(Player __instance)
		{
			HeldItemNameRuntime.PlayerStopped(__instance);
		}
	}
}
namespace HeldItemNameHud.Localization
{
	internal static class I18n
	{
		private const string FileName = "HeldItemNameHud.Localization.json";

		private static readonly ModLocalizer _localizer = Load();

		internal static string Text(string key, params object[] args)
		{
			return _localizer.GetLocalizedText(key, args);
		}

		private static ModLocalizer Load()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			ModLocalizer obj = LocalizationApi.For("IceBoxStudio.HowToFish.HeldItemNameHud");
			obj.RegisterJson(Path.Combine(directoryName, "HeldItemNameHud.Localization.json"));
			return obj;
		}
	}
}
namespace HeldItemNameHud.Configuration
{
	internal static class ConfigManager
	{
		private static ConfigEntry<float> _hotbarOffset;

		private static ConfigEntry<float> _scale;

		private static ConfigEntry<float> _fontSize;

		private static ConfigEntry<float> _opacity;

		private static ConfigEntry<float> _showSeconds;

		private static ConfigEntry<float> _fadeSeconds;

		private static ConfigEntry<bool> _alwaysShow;

		private static ConfigEntry<bool> _largeText;

		private static ConfigEntry<bool> _highContrast;

		private static ConfigEntry<bool> _disableAnimation;

		private static ConfigEntry<Color> _normalColor;

		private static ConfigEntry<Color> _dripColor;

		internal static float HotbarOffset => Mathf.Max(0f, _hotbarOffset.Value);

		internal static float Scale => Mathf.Clamp(_scale.Value, 0.5f, 2f);

		internal static float FontSize => Mathf.Clamp(_fontSize.Value, 12f, 72f);

		internal static float Opacity => Mathf.Clamp01(_opacity.Value);

		internal static float ShowSeconds => Mathf.Clamp(_showSeconds.Value, 0.1f, 10f);

		internal static float FadeSeconds => Mathf.Clamp(_fadeSeconds.Value, 0f, 2f);

		internal static bool AlwaysShow => _alwaysShow.Value;

		internal static bool LargeText => _largeText.Value;

		internal static bool HighContrast => _highContrast.Value;

		internal static bool DisableAnimation => _disableAnimation.Value;

		internal static Color NormalColor => _normalColor.Value;

		internal static Color DripColor => _dripColor.Value;

		internal static void Init(ConfigFile config)
		{
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			_hotbarOffset = config.Bind<float>("UI", "HotbarOffset", 142f, I18n.Text("hud.config.hotbar_offset"));
			_scale = config.Bind<float>("UI", "Scale", 1f, I18n.Text("hud.config.scale"));
			_fontSize = config.Bind<float>("UI", "FontSize", 30f, I18n.Text("hud.config.font_size"));
			_opacity = config.Bind<float>("UI", "Opacity", 0.92f, I18n.Text("hud.config.opacity"));
			_showSeconds = config.Bind<float>("Display", "ShowSeconds", 1.75f, I18n.Text("hud.config.show_seconds"));
			_fadeSeconds = config.Bind<float>("Display", "FadeSeconds", 0.15f, I18n.Text("hud.config.fade_seconds"));
			_alwaysShow = config.Bind<bool>("Display", "AlwaysShow", false, I18n.Text("hud.config.always_show"));
			_largeText = config.Bind<bool>("Accessibility", "LargeText", false, I18n.Text("hud.config.large_text"));
			_highContrast = config.Bind<bool>("Accessibility", "HighContrast", false, I18n.Text("hud.config.high_contrast"));
			_disableAnimation = config.Bind<bool>("Accessibility", "DisableAnimation", false, I18n.Text("hud.config.disable_animation"));
			_normalColor = config.Bind<Color>("Colors", "NormalColor", Color.white, I18n.Text("hud.config.normal_color"));
			_dripColor = config.Bind<Color>("Colors", "DripColor", new Color(1f, 0.83f, 0.2f, 1f), I18n.Text("hud.config.drip_color"));
			config.Save();
		}
	}
}