Decompiled source of ArcadeFishing v1.0.1

ArcadeFishing.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using ArcadeFishing.UI;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ArcadeFishing
{
	public static class AFLocal
	{
		private static readonly Dictionary<string, string> s_en = new Dictionary<string, string>
		{
			{ "panel_title", "ANGLER'S COMPENDIUM" },
			{ "tab_species", "\ud83d\udc1f Fish Species" },
			{ "tab_baits", "\ud83e\udeb1 Baits & Recipes" },
			{ "tab_stats", "\ud83d\udcca Statistics" },
			{ "btn_tooltip_topic", "Angler's Logbook" },
			{ "btn_tooltip_text", "Open fish records, personal bests, and bait recipes." },
			{ "close", "Close" },
			{ "record", "Record" },
			{ "caught", "Caught" },
			{ "biome", "Biome" },
			{ "favored_bait", "Favored Bait" },
			{ "recipe", "Recipe" },
			{ "target_fish", "Target Fish" },
			{ "zones", "Zones" },
			{ "tips", "Tips" },
			{ "clue", "Hint" },
			{ "undiscovered", "Undiscovered Species" },
			{ "stats_overview", "VIKING ANGLER CAREER STATS" },
			{ "cat_fish", "\ud83d\udc1f Fish Species (12)" },
			{ "cat_logs", "\ud83d\udcdc Catch Logs & Records" },
			{ "cat_baits", "\ud83e\udeb1 Baits & Recipes (9)" },
			{ "first_caught", "First Caught" },
			{ "day", "Day" },
			{ "no_logs_yet", "No catches recorded yet. Cast your line into any water body to start your fishing log!" },
			{ "sec_stats", "─── \ud83c\udfc6 CAREER STATISTICS ───" },
			{ "sec_fish", "─── \ud83d\udc1f FISH SPECIES COMPENDIUM ───" },
			{ "sec_baits", "─── \ud83e\udeb1 BAITS & CRAFTING GUIDE ───" },
			{ "total_catches", "Total Catches" },
			{ "species_discovered", "Species Discovered" },
			{ "heaviest_catch", "Heaviest Fish" },
			{ "highest_quality", "Highest Star Quality" },
			{ "fishing_skill", "Fishing Skill" },
			{ "none_yet", "None yet" },
			{ "level", "Level" },
			{ "breakdown_title", "\ud83d\udccb FISH SPECIES CATCH RECORD" },
			{ "not_caught_yet", "Not caught yet" }
		};

		private static readonly Dictionary<string, string> s_bg = new Dictionary<string, string>
		{
			{ "panel_title", "РИБАРСКИ ДНЕВНИК" },
			{ "tab_species", "\ud83d\udc1f Видове риби" },
			{ "tab_baits", "\ud83e\udeb1 Стръв и рецепти" },
			{ "tab_stats", "\ud83d\udcca Статистика" },
			{ "btn_tooltip_topic", "Рибарски дневник" },
			{ "btn_tooltip_text", "Отвори дневника с рекорди за всички риби и рецепти за стръв." },
			{ "close", "Затвори" },
			{ "record", "Рекорд" },
			{ "caught", "Улов" },
			{ "biome", "Биом" },
			{ "favored_bait", "Препоръчителна стръв" },
			{ "recipe", "Рецепта" },
			{ "target_fish", "Целеви риби" },
			{ "zones", "Зони" },
			{ "tips", "Съвети" },
			{ "clue", "Подсказка" },
			{ "undiscovered", "Неоткрит вид" },
			{ "stats_overview", "РИБОЛОВНА КАРИЕРА НА ВИКИНГА" },
			{ "cat_fish", "\ud83d\udc1f Видове риби (12)" },
			{ "cat_logs", "\ud83d\udcdc Дневник с улов" },
			{ "cat_baits", "\ud83e\udeb1 Наръчник за стръв (9)" },
			{ "first_caught", "Първи улов" },
			{ "day", "Ден" },
			{ "no_logs_yet", "Все още няма записан улов. Хвърли въдицата във водата, за да започнеш дневника!" },
			{ "sec_stats", "─── \ud83c\udfc6 РИБОЛОВНА СТАТИСТИКА ───" },
			{ "sec_fish", "─── \ud83d\udc1f КАТАЛОГ С ВИДОВЕ РИБИ ───" },
			{ "sec_baits", "─── \ud83e\udeb1 НАРЪЧНИК ЗА СТРЪВ И РЕЦЕПТИ ───" },
			{ "total_catches", "Общ улов" },
			{ "species_discovered", "Открити видове" },
			{ "heaviest_catch", "Най-тежка риба" },
			{ "highest_quality", "Най-високо качество" },
			{ "fishing_skill", "Умение Риболов" },
			{ "none_yet", "Няма все още" },
			{ "level", "Ниво" },
			{ "breakdown_title", "\ud83d\udccb РЕКОРДИ ПО ВИДОВЕ РИБИ" },
			{ "not_caught_yet", "Все още не е ловена" }
		};

		public static bool IsBulgarian()
		{
			try
			{
				if (Localization.instance != null)
				{
					string selectedLanguage = Localization.instance.GetSelectedLanguage();
					if (!string.IsNullOrEmpty(selectedLanguage) && (selectedLanguage.IndexOf("bulgarian", StringComparison.OrdinalIgnoreCase) >= 0 || selectedLanguage.IndexOf("българ", StringComparison.OrdinalIgnoreCase) >= 0))
					{
						return true;
					}
				}
				string text = PlayerPrefs.GetString("language", "English");
				if (!string.IsNullOrEmpty(text) && (text.IndexOf("bulgarian", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("българ", StringComparison.OrdinalIgnoreCase) >= 0))
				{
					return true;
				}
			}
			catch (Exception)
			{
			}
			return false;
		}

		public static string Get(string key)
		{
			if (IsBulgarian() && s_bg.TryGetValue(key, out var value))
			{
				return value;
			}
			if (s_en.TryGetValue(key, out var value2))
			{
				return value2;
			}
			return key;
		}
	}
	[BepInPlugin("com.arcaderoom.arcadefishing", "ArcadeFishing", "1.0.1")]
	public class ArcadeFishingPlugin : BaseUnityPlugin
	{
		public const string ModGUID = "com.arcaderoom.arcadefishing";

		public const string ModName = "ArcadeFishing";

		public const string ModVersion = "1.0.1";

		public static ConfigEntry<KeyCode> MinigameKey;

		public static ConfigEntry<KeyCode> LogbookKey;

		public static ConfigEntry<float> MinigameDifficultyMultiplier;

		public static ConfigEntry<float> MinigameStaminaDrain;

		public static ConfigEntry<bool> EnableMinigame;

		public static ConfigEntry<bool> EnableSoundEffects;

		public static ConfigEntry<bool> ShowJournalButton;

		private Harmony m_harmony;

		private GameObject m_uiRoot;

		private void Awake()
		{
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			MinigameKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MinigameKey", (KeyCode)324, "Primary key to reel in / raise the green catch bar during minigame (Mouse1 = Right Click).");
			LogbookKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "LogbookKey", (KeyCode)0, "Optional hotkey to toggle the Angler's Logbook UI (KeyCode.None = disabled; use inventory Tab menu button).");
			MinigameDifficultyMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "DifficultyMultiplier", 1f, "Global multiplier for fish speed and dart frequency (0.5 = easier, 2.0 = hardcore).");
			MinigameStaminaDrain = ((BaseUnityPlugin)this).Config.Bind<float>("Gameplay", "StaminaDrainRate", 6f, "Stamina drained per second when the fish remains outside the green zone for over 1 second.");
			EnableMinigame = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "EnableMinigame", true, "Enable the interactive Stardew-style fishing minigame.");
			EnableSoundEffects = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual & Audio", "EnableSoundEffects", true, "Play audio effects upon successful catch and discovery.");
			ShowJournalButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Visual & Audio", "ShowJournalButton", false, "Legacy floating HUD button (disabled by default; the logbook is now integrated directly into the inventory menu).");
			m_uiRoot = new GameObject("ArcadeFishing_UIRoot");
			Object.DontDestroyOnLoad((Object)(object)m_uiRoot);
			m_uiRoot.AddComponent<FishingMinigameUI>();
			m_uiRoot.AddComponent<FishJournalUI>();
			try
			{
				m_harmony = new Harmony("com.arcaderoom.arcadefishing");
				m_harmony.PatchAll();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"[ArcadeFishing] Successfully initialized v1.0.1! Harmony patches loaded.");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("[ArcadeFishing] Failed to apply Harmony patches: " + ex.Message));
			}
		}

		private void OnDestroy()
		{
			if (m_harmony != null)
			{
				m_harmony.UnpatchSelf();
			}
			if ((Object)(object)m_uiRoot != (Object)null)
			{
				Object.Destroy((Object)(object)m_uiRoot);
			}
		}
	}
	public class FishSpeciesInfo
	{
		public int Id { get; set; }

		public string PrefabName { get; set; }

		public string ItemName { get; set; }

		public string EnglishName { get; set; }

		public string BulgarianName { get; set; }

		public string LocalizedKey { get; set; }

		public string BiomeName { get; set; }

		public Biome Biome { get; set; }

		public string FavoredBait { get; set; }

		public float BaseWeight { get; set; }

		public float Difficulty { get; set; }

		public float DartFrequency { get; set; }

		public float DartSpeed { get; set; }

		public string Description { get; set; }

		public string HabitatClue { get; set; }

		public Color ThemeColor { get; set; }
	}
	public class BaitInfo
	{
		public string PrefabName;

		public string EnglishName;

		public string BulgarianName;

		public string EnglishRecipe;

		public string BulgarianRecipe;

		public string EnglishBiomes;

		public string BulgarianBiomes;

		public string EnglishTargetFish;

		public string BulgarianTargetFish;

		public string EnglishDescription;

		public string BulgarianDescription;

		public Sprite GetIcon()
		{
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				return null;
			}
			string[] array = new string[3]
			{
				PrefabName,
				PrefabName.ToLower(),
				PrefabName.Replace("_", "")
			};
			string[] array2 = array;
			foreach (string text in array2)
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text);
				if (!((Object)(object)itemPrefab != (Object)null))
				{
					continue;
				}
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component != (Object)null && component.m_itemData != null)
				{
					Sprite icon = component.m_itemData.GetIcon();
					if ((Object)(object)icon != (Object)null)
					{
						return icon;
					}
				}
			}
			return null;
		}
	}
	public static class FishDatabase
	{
		private static readonly List<FishSpeciesInfo> s_species;

		private static readonly Dictionary<string, FishSpeciesInfo> s_byKey;

		private static readonly Dictionary<int, FishSpeciesInfo> s_byId;

		private static readonly List<BaitInfo> s_baits;

		static FishDatabase()
		{
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_078a: Unknown result type (might be due to invalid IL or missing references)
			//IL_085e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0932: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a09: Unknown result type (might be due to invalid IL or missing references)
			s_species = new List<FishSpeciesInfo>();
			s_byKey = new Dictionary<string, FishSpeciesInfo>(StringComparer.OrdinalIgnoreCase);
			s_byId = new Dictionary<int, FishSpeciesInfo>();
			s_baits = new List<BaitInfo>();
			Register(new FishSpeciesInfo
			{
				Id = 1,
				PrefabName = "Fish1",
				ItemName = "Fish1",
				EnglishName = "Perch",
				BulgarianName = "Костур",
				LocalizedKey = "$animal_fish1",
				BiomeName = "Meadows",
				Biome = (Biome)1,
				FavoredBait = "FishingBait",
				BaseWeight = 1.5f,
				Difficulty = 1f,
				DartFrequency = 1.8f,
				DartSpeed = 1.1f,
				Description = "A common freshwater perch found basking in the quiet coastal shoals and tranquil lakes of the Meadows.",
				HabitatClue = "Found swimming peacefully along calm shorelines and lakes of the Meadows.",
				ThemeColor = new Color(0.35f, 0.75f, 0.45f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 2,
				PrefabName = "Fish2",
				ItemName = "Fish2",
				EnglishName = "Pike",
				BulgarianName = "Щука",
				LocalizedKey = "$animal_fish2",
				BiomeName = "Meadows / Rivers",
				Biome = (Biome)1,
				FavoredBait = "FishingBait",
				BaseWeight = 3.2f,
				Difficulty = 1.25f,
				DartFrequency = 1.5f,
				DartSpeed = 1.35f,
				Description = "An aggressive predator lurking near river mouths and reeds. Famous for its sudden bursts of speed.",
				HabitatClue = "Hides amidst the reeds and running streams dividing meadows and woods.",
				ThemeColor = new Color(0.55f, 0.7f, 0.35f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 3,
				PrefabName = "Fish3",
				ItemName = "Fish3",
				EnglishName = "Tuna",
				BulgarianName = "Риба Тон",
				LocalizedKey = "$animal_fish3",
				BiomeName = "Ocean",
				Biome = (Biome)256,
				FavoredBait = "FishingBaitOcean",
				BaseWeight = 14.5f,
				Difficulty = 2.4f,
				DartFrequency = 0.9f,
				DartSpeed = 2.2f,
				Description = "A massive torpedo-shaped pelagic wanderer slicing through the tempestuous swells of the open Ocean.",
				HabitatClue = "Roams the endless horizons of the open sea far beyond Viking coastlines.",
				ThemeColor = new Color(0.25f, 0.5f, 0.9f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 4,
				PrefabName = "Fish4_cave",
				ItemName = "Fish4_cave",
				EnglishName = "Tetra",
				BulgarianName = "Тетра",
				LocalizedKey = "$animal_fish4",
				BiomeName = "Mountain / Frost Caves",
				Biome = (Biome)4,
				FavoredBait = "FishingBaitCave",
				BaseWeight = 0.8f,
				Difficulty = 2.1f,
				DartFrequency = 0.7f,
				DartSpeed = 1.9f,
				Description = "A rare subterranean wonder glowing with pale bioluminescence inside frozen underground lakes.",
				HabitatClue = "Only caught in still, icy ponds buried deep within Mountain Frost Caves.",
				ThemeColor = new Color(0.4f, 0.85f, 0.95f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 5,
				PrefabName = "Fish5",
				ItemName = "Fish5",
				EnglishName = "Trollfish",
				BulgarianName = "Тролска риба",
				LocalizedKey = "$animal_fish5",
				BiomeName = "Black Forest",
				Biome = (Biome)8,
				FavoredBait = "FishingBaitForest",
				BaseWeight = 6f,
				Difficulty = 1.6f,
				DartFrequency = 1.3f,
				DartSpeed = 1.5f,
				Description = "A rugged, thick-skinned fish steeped in ancient forest moss. It possesses stubborn pulling power.",
				HabitatClue = "Haunts foggy shorelines and pine-shaded coves of the Black Forest.",
				ThemeColor = new Color(0.3f, 0.6f, 0.5f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 6,
				PrefabName = "Fish6",
				ItemName = "Fish6",
				EnglishName = "Giant Herring",
				BulgarianName = "Гигантска херинга",
				LocalizedKey = "$animal_fish6",
				BiomeName = "Black Forest Coast",
				Biome = (Biome)8,
				FavoredBait = "FishingBaitForest",
				BaseWeight = 4f,
				Difficulty = 1.5f,
				DartFrequency = 1.2f,
				DartSpeed = 1.4f,
				Description = "A silvery, large-scaled schooling herring that shimmers brightly under moonlight across northern coasts.",
				HabitatClue = "Travels in glimmering schools along rocky shores of the Black Forest.",
				ThemeColor = new Color(0.7f, 0.8f, 0.9f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 7,
				PrefabName = "Fish7",
				ItemName = "Fish7",
				EnglishName = "Grouper",
				BulgarianName = "Меру",
				LocalizedKey = "$animal_fish7",
				BiomeName = "Plains",
				Biome = (Biome)16,
				FavoredBait = "FishingBaitPlains",
				BaseWeight = 9f,
				Difficulty = 2f,
				DartFrequency = 1.1f,
				DartSpeed = 1.7f,
				Description = "A heavy, golden-finned bottom feeder flourishing under the warm sunlit banks of the Plains.",
				HabitatClue = "Swims where golden plains meet warm ocean waves, braving mosquito territory.",
				ThemeColor = new Color(0.85f, 0.7f, 0.25f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 8,
				PrefabName = "Fish8",
				ItemName = "Fish8",
				EnglishName = "Coral Cod",
				BulgarianName = "Коралова треска",
				LocalizedKey = "$animal_fish8",
				BiomeName = "Ocean / Plains Reefs",
				Biome = (Biome)16,
				FavoredBait = "FishingBaitPlains",
				BaseWeight = 7.5f,
				Difficulty = 2.2f,
				DartFrequency = 1f,
				DartSpeed = 1.8f,
				Description = "Adorned with vivid coral patterns, this cunning cod weaves through sharp subaquatic reef passages.",
				HabitatClue = "Feeds around shallow reefs and sunny coral shoals off the Plains.",
				ThemeColor = new Color(0.95f, 0.45f, 0.35f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 9,
				PrefabName = "Fish9",
				ItemName = "Fish9",
				EnglishName = "Anglerfish",
				BulgarianName = "Морски дявол",
				LocalizedKey = "$animal_fish9",
				BiomeName = "Mistlands",
				Biome = (Biome)512,
				FavoredBait = "FishingBaitMistlands",
				BaseWeight = 11f,
				Difficulty = 2.7f,
				DartFrequency = 0.8f,
				DartSpeed = 2.3f,
				Description = "A terrifying denizen of impenetrable mists, wielding an eerie lantern lure to entice prey into darkness.",
				HabitatClue = "Lurks beneath heavy purple fog and craggy jagged shores in the Mistlands.",
				ThemeColor = new Color(0.65f, 0.35f, 0.85f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 10,
				PrefabName = "Fish10",
				ItemName = "Fish10",
				EnglishName = "Northern Salmon",
				BulgarianName = "Северна сьомга",
				LocalizedKey = "$animal_fish10",
				BiomeName = "Deep North",
				Biome = (Biome)64,
				FavoredBait = "FishingBaitDeepNorth",
				BaseWeight = 12f,
				Difficulty = 2.9f,
				DartFrequency = 0.75f,
				DartSpeed = 2.4f,
				Description = "A legendary titan of polar ice shelves. Its powerful thrashing can pull unwary anglers into glacial waters.",
				HabitatClue = "Leaps among glacial floes and blizzard-lashed seas of the far Deep North.",
				ThemeColor = new Color(0.5f, 0.8f, 1f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 11,
				PrefabName = "Fish11",
				ItemName = "Fish11",
				EnglishName = "Magmafish",
				BulgarianName = "Магмена риба",
				LocalizedKey = "$animal_fish11",
				BiomeName = "Ashlands",
				Biome = (Biome)32,
				FavoredBait = "FishingBaitAshlands",
				BaseWeight = 13.5f,
				Difficulty = 3.2f,
				DartFrequency = 0.65f,
				DartSpeed = 2.6f,
				Description = "Born of molten magma and volcanic brine. Its obsidian scales radiate scorching thermal fury.",
				HabitatClue = "Survives only in boiling seas surrounding the smoke-veiled volcanic Ashlands.",
				ThemeColor = new Color(0.95f, 0.3f, 0.15f)
			});
			Register(new FishSpeciesInfo
			{
				Id = 12,
				PrefabName = "Fish12",
				ItemName = "Fish12",
				EnglishName = "Pufferfish",
				BulgarianName = "Риба Балон",
				LocalizedKey = "$animal_fish12",
				BiomeName = "Mistlands / Ocean",
				Biome = (Biome)512,
				FavoredBait = "FishingBaitMistlands",
				BaseWeight = 5f,
				Difficulty = 2.5f,
				DartFrequency = 1f,
				DartSpeed = 2f,
				Description = "A spiny hazard capable of inflating violently when hooked. Releases deadly venomous mist.",
				HabitatClue = "Dwells in enigmatic Mistlands waters and warm Ocean currents.",
				ThemeColor = new Color(0.85f, 0.85f, 0.3f)
			});
			s_baits.Add(new BaitInfo
			{
				PrefabName = "FishingBait",
				EnglishName = "Ordinary Fishing Bait",
				BulgarianName = "Обикновена рибарска стръв",
				EnglishRecipe = "Purchased from Haldor (50x for 10 Coins)",
				BulgarianRecipe = "Купува се от търговеца Халдор (50 бр. за 10 монети)",
				EnglishBiomes = "Meadows, Black Forest",
				BulgarianBiomes = "Ливади, Черна гора",
				EnglishTargetFish = "Perch, Pike",
				BulgarianTargetFish = "Костур, Щука",
				EnglishDescription = "Standard earthworm bait. Attracts common freshwater fish in calm shallow waters.",
				BulgarianDescription = "Класическа земна стръв. Привлича обикновени сладководни риби в плитки води."
			});
			s_baits.Add(new BaitInfo
			{
				PrefabName = "FishingBaitForest",
				EnglishName = "Mossy Fishing Bait",
				BulgarianName = "Мъхеста рибарска стръв",
				EnglishRecipe = "Cauldron: Troll Trophy x1 + Ordinary Bait x20 (Yields 20x)",
				BulgarianRecipe = "Казан: Трофей от трол x1 + Обикновена стръв x20 (Дава 20 бр.)",
				EnglishBiomes = "Black Forest Coast & Coves",
				BulgarianBiomes = "Брегове и заливи на Черната гора",
				EnglishTargetFish = "Trollfish, Giant Herring",
				BulgarianTargetFish = "Тролска риба, Гигантска херинга",
				EnglishDescription = "Infused with crushed troll moss. Its pungent earthy scent lures stubborn forest swimmers.",
				BulgarianDescription = "Напоена с мъх от трол. Острият горски аромат привлича упорити горски риби."
			});
			s_baits.Add(new BaitInfo
			{
				PrefabName = "FishingBaitSwamp",
				EnglishName = "Sticky Fishing Bait",
				BulgarianName = "Лепкава рибарска стръв",
				EnglishRecipe = "Cauldron: Abomination Trophy x1 + Ordinary Bait x20 (Yields 20x)",
				BulgarianRecipe = "Казан: Трофей от изчадие x1 + Обикновена стръв x20 (Дава 20 бр.)",
				EnglishBiomes = "Swamp Rivers & Murky Waters",
				BulgarianBiomes = "Блатни реки и мътни води",
				EnglishTargetFish = "Giant Herring",
				BulgarianTargetFish = "Гигантска херинга",
				EnglishDescription = "Coated with tarry root sap that resists dissolving in muddy, decomposing waters.",
				BulgarianDescription = "Покрита с лепкава смола от корени, която не се размива в мътните блатни води."
			});
			s_baits.Add(new BaitInfo
			{
				PrefabName = "FishingBaitCave",
				EnglishName = "Cold Fishing Bait",
				BulgarianName = "Студена рибарска стръв",
				EnglishRecipe = "Cauldron: Fenring Trophy x1 + Ordinary Bait x20 (Yields 20x)",
				BulgarianRecipe = "Казан: Трофей от фенринг x1 + Обикновена стръв x20 (Дава 20 бр.)",
				EnglishBiomes = "Mountain Frost Caves",
				BulgarianBiomes = "Планински ледени пещери",
				EnglishTargetFish = "Tetra",
				BulgarianTargetFish = "Тетра",
				EnglishDescription = "Imbued with frost oils that stay liquid in subterranean sub-zero ponds.",
				BulgarianDescription = "Напоена с мразовити масла, които не замръзват в подземните ледени езера."
			});
			s_baits.Add(new BaitInfo
			{
				PrefabName = "FishingBaitOcean",
				EnglishName = "Heavy Fishing Bait",
				BulgarianName = "Тежка рибарска стръв",
				EnglishRecipe = "Cauldron: Serpent Trophy x1 + Ordinary Bait x20 (Yields 20x)",
				BulgarianRecipe = "Казан: Трофей от морска змия x1 + Обикновена стръв x20 (Дава 20 бр.)",
				EnglishBiomes = "Open Ocean",
				BulgarianBiomes = "Открит океан",
				EnglishTargetFish = "Tuna, Coral Cod",
				BulgarianTargetFish = "Риба Тон, Коралова треска",
				EnglishDescription = "Heavily weighted to dive swiftly through open sea waves into the deep oceanic abyss.",
				BulgarianDescription = "Утежнена за бързо потъване през високите океански вълни в дълбините."
			});
			s_baits.Add(new BaitInfo
			{
				PrefabName = "FishingBaitPlains",
				EnglishName = "Stingy Fishing Bait",
				BulgarianName = "Жилеща рибарска стръв",
				EnglishRecipe = "Cauldron: Deathsquito Trophy x1 + Ordinary Bait x20 (Yields 20x)",
				BulgarianRecipe = "Казан: Трофей от комар-убиец x1 + Обикновена стръв x20 (Дава 20 бр.)",
				EnglishBiomes = "Plains Coast & Sunlit Reefs",
				BulgarianBiomes = "Брегове на равнините и слънчеви рифове",
				EnglishTargetFish = "Grouper, Coral Cod",
				BulgarianTargetFish = "Меру, Коралова треска",
				EnglishDescription = "Spiked with sharp mosquito barbs that snag the jaws of aggressive reef predators.",
				BulgarianDescription = "Осеяна с игли от комари, които се забиват в челюстите на агресивни рифови хищници."
			});
			s_baits.Add(new BaitInfo
			{
				PrefabName = "FishingBaitMistlands",
				EnglishName = "Misty Fishing Bait",
				BulgarianName = "Мъглива рибарска стръв",
				EnglishRecipe = "Cauldron: Seeker Trophy x1 + Ordinary Bait x20 (Yields 20x)",
				BulgarianRecipe = "Казан: Трофей от търсач x1 + Обикновена стръв x20 (Дава 20 бр.)",
				EnglishBiomes = "Mistlands Waters",
				BulgarianBiomes = "Мъгливи земи и крайбрежия",
				EnglishTargetFish = "Anglerfish, Pufferfish",
				BulgarianTargetFish = "Морски дявол, Риба Балон",
				EnglishDescription = "Glows with eerie bioluminescence to pierce dark, thick purple mists.",
				BulgarianDescription = "Свети с мистично фосфоресциране, прорязващо гъстите виолетови мъгли."
			});
			s_baits.Add(new BaitInfo
			{
				PrefabName = "FishingBaitAshlands",
				EnglishName = "Hot Fishing Bait",
				BulgarianName = "Гореща рибарска стръв",
				EnglishRecipe = "Food Prep: Charred / Surtling Trophy x1 + Ordinary Bait x20",
				BulgarianRecipe = "Кулинарна маса: Трофей от овъглен / съртлинг x1 + Обикновена стръв x20",
				EnglishBiomes = "Ashlands (Boiling Volcanic Seas)",
				BulgarianBiomes = "Пепелни земи (Врящи вулканични морета)",
				EnglishTargetFish = "Magmafish",
				BulgarianTargetFish = "Магмена риба",
				EnglishDescription = "Basalt-coated core designed to withstand boiling magma seas without burning.",
				BulgarianDescription = "Базалтова обвивка, издържаща на врящите магмени морета без да изгори."
			});
			s_baits.Add(new BaitInfo
			{
				PrefabName = "FishingBaitDeepNorth",
				EnglishName = "Frosty Fishing Bait",
				BulgarianName = "Ледена рибарска стръв",
				EnglishRecipe = "Cauldron: Freeze Gland x1 + Ordinary Bait x20 (Yields 20x)",
				BulgarianRecipe = "Казан: Ледена жлеза x1 + Обикновена стръв x20 (Дава 20 бр.)",
				EnglishBiomes = "Deep North (Glacial Frontiers)",
				BulgarianBiomes = "Дълбок север (Ледникови брегове)",
				EnglishTargetFish = "Northern Salmon, Pufferfish",
				BulgarianTargetFish = "Северна сьомга, Риба Балон",
				EnglishDescription = "Sub-zero bait forged for extreme polar seas among glacial floes.",
				BulgarianDescription = "Създадена за екстремни полярни морета сред ледниците."
			});
		}

		private static void Register(FishSpeciesInfo info)
		{
			s_species.Add(info);
			s_byId[info.Id] = info;
			s_byKey[info.PrefabName] = info;
			s_byKey[info.ItemName] = info;
			s_byKey["Fish" + info.Id] = info;
			if (info.Id == 4)
			{
				s_byKey["Fish4_cave"] = info;
			}
		}

		public static IReadOnlyList<FishSpeciesInfo> GetAllSpecies()
		{
			return s_species;
		}

		public static IReadOnlyList<BaitInfo> GetAllBaits()
		{
			return s_baits;
		}

		public static string GetBaitDisplayName(string baitPrefabName)
		{
			if (string.IsNullOrEmpty(baitPrefabName))
			{
				return "";
			}
			bool flag = AFLocal.IsBulgarian();
			foreach (BaitInfo s_bait in s_baits)
			{
				if (string.Equals(s_bait.PrefabName, baitPrefabName, StringComparison.OrdinalIgnoreCase))
				{
					return flag ? s_bait.BulgarianName : s_bait.EnglishName;
				}
			}
			if (baitPrefabName.IndexOf("Ocean", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return flag ? "Тежка океанска стръв" : "Heavy Fishing Bait";
			}
			if (baitPrefabName.IndexOf("Forest", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return flag ? "Мъхеста стръв" : "Mossy Fishing Bait";
			}
			if (baitPrefabName.IndexOf("Cave", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return flag ? "Студена рибарска стръв" : "Cold Fishing Bait";
			}
			if (baitPrefabName.IndexOf("Plains", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return flag ? "Жилеща стръв" : "Stingy Fishing Bait";
			}
			if (baitPrefabName.IndexOf("Mistlands", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return flag ? "Мъглива стръв" : "Misty Fishing Bait";
			}
			if (baitPrefabName.IndexOf("Ashlands", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return flag ? "Гореща стръв" : "Hot Fishing Bait";
			}
			if (baitPrefabName.IndexOf("DeepNorth", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return flag ? "Мразовита стръв" : "Frosty Fishing Bait";
			}
			if (baitPrefabName.IndexOf("Swamp", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return flag ? "Лепкава стръв" : "Sticky Fishing Bait";
			}
			return flag ? "Обикновена стръв" : "Ordinary Fishing Bait";
		}

		public static FishSpeciesInfo GetById(int id)
		{
			s_byId.TryGetValue(id, out var value);
			return value;
		}

		public static FishSpeciesInfo FindSpecies(string nameOrKey)
		{
			if (string.IsNullOrEmpty(nameOrKey))
			{
				return null;
			}
			string text = nameOrKey.Replace("(Clone)", "").Trim();
			if (s_byKey.TryGetValue(text, out var value))
			{
				return value;
			}
			foreach (FishSpeciesInfo s_specy in s_species)
			{
				if (text.IndexOf(s_specy.EnglishName, StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf(s_specy.PrefabName, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return s_specy;
				}
			}
			return null;
		}

		public static FishSpeciesInfo GetSpeciesForFish(Fish fish)
		{
			if ((Object)(object)fish == (Object)null)
			{
				return s_species[0];
			}
			if (!string.IsNullOrEmpty(fish.m_name))
			{
				FishSpeciesInfo fishSpeciesInfo = FindSpecies(fish.m_name);
				if (fishSpeciesInfo != null)
				{
					return fishSpeciesInfo;
				}
			}
			string name = ((Object)((Component)fish).gameObject).name;
			FishSpeciesInfo fishSpeciesInfo2 = FindSpecies(name);
			if (fishSpeciesInfo2 != null)
			{
				return fishSpeciesInfo2;
			}
			if ((Object)(object)fish.m_pickupItem != (Object)null)
			{
				FishSpeciesInfo fishSpeciesInfo3 = FindSpecies(((Object)fish.m_pickupItem).name);
				if (fishSpeciesInfo3 != null)
				{
					return fishSpeciesInfo3;
				}
			}
			return s_species[0];
		}

		public static string GetLocalizedName(FishSpeciesInfo species)
		{
			if (species == null)
			{
				return "Unknown Fish";
			}
			if (AFLocal.IsBulgarian())
			{
				if (Localization.instance != null)
				{
					string text = Localization.instance.Localize(species.LocalizedKey);
					if (!string.IsNullOrEmpty(text) && !text.StartsWith("$"))
					{
						return text;
					}
				}
				return (!string.IsNullOrEmpty(species.BulgarianName)) ? species.BulgarianName : species.EnglishName;
			}
			return species.EnglishName;
		}

		public static Sprite GetSpeciesIcon(FishSpeciesInfo species)
		{
			if (species == null || (Object)(object)ObjectDB.instance == (Object)null)
			{
				return null;
			}
			string[] array = new string[11]
			{
				species.ItemName,
				species.PrefabName,
				"Fish" + species.Id,
				"Fish" + species.Id + "_cave",
				"Fish" + species.Id + "_Ocean",
				"Fish" + species.Id + "_Forest",
				"Fish" + species.Id + "_Swamp",
				"Fish" + species.Id + "_Plains",
				"Fish" + species.Id + "_Mistlands",
				"Fish" + species.Id + "_Ashlands",
				"Fish" + species.Id + "_DeepNorth"
			};
			string[] array2 = array;
			foreach (string text in array2)
			{
				if (string.IsNullOrEmpty(text))
				{
					continue;
				}
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text);
				if (!((Object)(object)itemPrefab != (Object)null))
				{
					continue;
				}
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component != (Object)null && component.m_itemData != null)
				{
					Sprite icon = component.m_itemData.GetIcon();
					if ((Object)(object)icon != (Object)null)
					{
						return icon;
					}
				}
			}
			return null;
		}

		public static Sprite GetFishIcon(Fish fish, FishSpeciesInfo species)
		{
			if ((Object)(object)fish != (Object)null)
			{
				ItemDrop component = ((Component)fish).GetComponent<ItemDrop>();
				if ((Object)(object)component != (Object)null && component.m_itemData != null)
				{
					Sprite icon = component.m_itemData.GetIcon();
					if ((Object)(object)icon != (Object)null)
					{
						return icon;
					}
				}
				if ((Object)(object)fish.m_pickupItem != (Object)null)
				{
					ItemDrop component2 = fish.m_pickupItem.GetComponent<ItemDrop>();
					if ((Object)(object)component2 != (Object)null && component2.m_itemData != null)
					{
						Sprite icon2 = component2.m_itemData.GetIcon();
						if ((Object)(object)icon2 != (Object)null)
						{
							return icon2;
						}
					}
				}
			}
			return GetSpeciesIcon(species);
		}

		public static int GetFishQuality(Fish fish)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fish == (Object)null)
			{
				return 1;
			}
			ItemDrop component = ((Component)fish).GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && component.m_itemData != null && component.m_itemData.m_quality > 0)
			{
				return Mathf.Clamp(component.m_itemData.m_quality, 1, 5);
			}
			int num = (int)Mathf.Round(((Component)fish).transform.localScale.x);
			if (num >= 1 && num <= 5)
			{
				return num;
			}
			return 1;
		}

		public static float GetBiomeDifficultyMultiplier(Biome biome)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Invalid comparison between Unknown and I4
			if ((int)biome <= 16)
			{
				switch (biome - 1)
				{
				default:
					if ((int)biome != 8)
					{
						if ((int)biome != 16)
						{
							break;
						}
						return 1.65f;
					}
					return 1.2f;
				case 0:
					return 1f;
				case 1:
					return 1.4f;
				case 3:
					return 1.5f;
				case 2:
					break;
				}
			}
			else if ((int)biome <= 64)
			{
				if ((int)biome == 32)
				{
					return 2.4f;
				}
				if ((int)biome == 64)
				{
					return 2.15f;
				}
			}
			else
			{
				if ((int)biome == 256)
				{
					return 1.35f;
				}
				if ((int)biome == 512)
				{
					return 1.9f;
				}
			}
			return 1f;
		}

		public static float GetStarDifficultyMultiplier(int stars)
		{
			return stars switch
			{
				2 => 1.25f, 
				3 => 1.55f, 
				4 => 1.9f, 
				5 => 2.35f, 
				_ => 1f, 
			};
		}
	}
	[HarmonyPatch]
	public static class FishingPatches
	{
		private static bool s_isMinigameCatching = false;

		private static GameObject s_menuButtonInstance = null;

		private static Sprite s_fishMenuSprite = null;

		private static Sprite s_squareSlotSprite = null;

		public static GameObject s_fishingPanel = null;

		public static RectTransform s_fishingListRoot = null;

		public static Scrollbar s_fishingScrollbar = null;

		public static List<GameObject> s_fishingListElements = new List<GameObject>();

		public static int s_currentCategory = 0;

		public static bool IsFishingPanelOpen()
		{
			return (Object)(object)s_fishingPanel != (Object)null && s_fishingPanel.activeSelf;
		}

		public static Sprite GetFishMenuSprite()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)s_fishMenuSprite == (Object)null)
			{
				try
				{
					byte[] array = Convert.FromBase64String("iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABOElEQVR4nO2YSw7DIAxEPVbvf2W6qhRVAmKwwSTzdlWTjD2YjxEhhBBCCCGEkCBKKUWSgpWJAwjVGwGrRzybCfr26aARH+2NciYTdJdwFhN0p3gGE3R3ALtNQMbkVu4U6CUwE8z1/ZmRjjQErT9/Qc8G4Fnm3mbAErxVfMX8njVEoxJatbjN6mBUpOX8jpV9tBJ0VLCWZETy2xZBS4MTNeq1XeRqysxirR5B7ky+9ZyrAUjWxtawmqCSFI8DlLsBSFIF/6b0frf4yKH0krx7jFd5KHerVU9qXSOmqkpSRvd26/NqDehpqMdHonYHaxWMxAFLIHcEo3qB3neXN0OoCEZUQ1Ty5gsRi1j0muFlNE66EYqoLpxwJ7j1UhRO4lYTsvQdS3jqGeMWr06eEEIIIYQQQgghhMh6vr3l3BCBzyXRAAAAAElFTkSuQmCC");
					Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
					ImageConversion.LoadImage(val, array);
					s_fishMenuSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
				}
				catch (Exception ex)
				{
					ZLog.LogWarning((object)("[ArcadeFishing] Failed to create fish menu sprite: " + ex.Message));
				}
			}
			return s_fishMenuSprite;
		}

		public static Sprite GetSquareSlotSprite()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0134: 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)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)s_squareSlotSprite == (Object)null)
			{
				try
				{
					int num = 48;
					Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
					Color val2 = default(Color);
					((Color)(ref val2))..ctor(0.1f, 0.09f, 0.08f, 1f);
					Color val3 = default(Color);
					((Color)(ref val3))..ctor(0.35f, 0.3f, 0.22f, 1f);
					Color val4 = default(Color);
					((Color)(ref val4))..ctor(0.14f, 0.13f, 0.12f, 0.95f);
					for (int i = 0; i < num; i++)
					{
						for (int j = 0; j < num; j++)
						{
							if (j < 2 || j >= num - 2 || i < 2 || i >= num - 2)
							{
								val.SetPixel(j, i, val2);
							}
							else if (j < 4 || j >= num - 4 || i < 4 || i >= num - 4)
							{
								val.SetPixel(j, i, val3);
							}
							else
							{
								val.SetPixel(j, i, val4);
							}
						}
					}
					val.Apply();
					s_squareSlotSprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(4f, 4f, 4f, 4f));
				}
				catch (Exception)
				{
					s_squareSlotSprite = null;
				}
			}
			return s_squareSlotSprite;
		}

		[HarmonyPatch(typeof(FishingFloat), "SetCatch")]
		[HarmonyPrefix]
		public static void FishingFloat_SetCatch_Prefix(FishingFloat __instance, Fish fish)
		{
			if ((Object)(object)fish == (Object)null || s_isMinigameCatching || !ArcadeFishingPlugin.EnableMinigame.Value)
			{
				return;
			}
			Character value = Traverse.Create((object)__instance).Method("GetOwner", Array.Empty<object>()).GetValue<Character>();
			if (!((Object)(object)value == (Object)null) && !((Object)(object)value != (Object)(object)Player.m_localPlayer))
			{
				EnsureBaitConsumed(__instance, Player.m_localPlayer);
				if ((Object)(object)FishingMinigameUI.Instance != (Object)null && !FishingMinigameUI.Instance.IsActive)
				{
					FishingMinigameUI.Instance.StartMinigame(__instance, fish);
				}
			}
		}

		[HarmonyPatch(typeof(FishingFloat), "ReturnBait")]
		[HarmonyPrefix]
		public static bool FishingFloat_ReturnBait_Prefix(FishingFloat __instance)
		{
			if (Traverse.Create((object)__instance).Field("m_baitConsumed").GetValue<bool>())
			{
				return false;
			}
			return true;
		}

		public static void EnsureBaitConsumed(FishingFloat ff, Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			bool flag = false;
			if ((Object)(object)ff != (Object)null)
			{
				Traverse.Create((object)ff).Field("m_baitConsumed").SetValue((object)true);
				string bait = ff.GetBait();
				if (!string.IsNullOrEmpty(bait))
				{
					flag = true;
				}
			}
			if (flag)
			{
				return;
			}
			Inventory inventory = ((Humanoid)player).GetInventory();
			if (inventory == null)
			{
				return;
			}
			foreach (ItemData allItem in inventory.GetAllItems())
			{
				if (allItem != null && allItem.m_stack > 0)
				{
					string text = (((Object)(object)allItem.m_dropPrefab != (Object)null) ? ((Object)allItem.m_dropPrefab).name : allItem.m_shared.m_name).ToLower();
					if (text.Contains("bait") || text.Contains("fishingbait"))
					{
						inventory.RemoveItem(allItem, 1);
						ZLog.Log((object)("[ArcadeFishing] Deducted 1 " + allItem.m_shared.m_name + " from inventory."));
						break;
					}
				}
			}
		}

		[HarmonyPatch(typeof(FishingFloat), "FixedUpdate")]
		[HarmonyPrefix]
		public static bool FishingFloat_FixedUpdate_Prefix(FishingFloat __instance)
		{
			//IL_008e: 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)
			if ((Object)(object)FishingMinigameUI.Instance != (Object)null && FishingMinigameUI.Instance.IsActive)
			{
				Character value = Traverse.Create((object)__instance).Method("GetOwner", Array.Empty<object>()).GetValue<Character>();
				if ((Object)(object)value != (Object)null && (Object)(object)value == (Object)(object)Player.m_localPlayer)
				{
					Transform value2 = Traverse.Create((object)__instance).Method("GetRodTop", new object[1] { value }).GetValue<Transform>();
					if ((Object)(object)value2 != (Object)null)
					{
						float num = Vector3.Distance(((Component)__instance).transform.position, value2.position);
						Traverse.Create((object)__instance).Field("m_lineLength").SetValue((object)Mathf.Max(2f, num));
					}
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(Player), "OnSpawned")]
		[HarmonyPostfix]
		public static void Player_OnSpawned_Postfix(Player __instance)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				FishSaveData.InitializeForPlayer(__instance);
			}
		}

		[HarmonyPatch(typeof(Player), "TakeInput")]
		[HarmonyPrefix]
		public static bool Player_TakeInput_Prefix(ref bool __result)
		{
			if (IsFishingPanelOpen() || ((Object)(object)FishJournalUI.Instance != (Object)null && FishJournalUI.Instance.IsOpen))
			{
				__result = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Humanoid), "StartAttack")]
		[HarmonyPrefix]
		public static bool Humanoid_StartAttack_Prefix(Humanoid __instance, ref bool __result)
		{
			if (__instance is Player && (IsFishingPanelOpen() || ((Object)(object)FishJournalUI.Instance != (Object)null && FishJournalUI.Instance.IsOpen)))
			{
				__result = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(InventoryGui), "Show")]
		[HarmonyPostfix]
		public static void InventoryGui_Show_Postfix(InventoryGui __instance)
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null && ((Humanoid)Player.m_localPlayer).GetInventory() != null)
			{
				FishSaveData.SyncInventory(((Humanoid)Player.m_localPlayer).GetInventory());
			}
			EnsureInventoryMenuButton(__instance);
			EnsureFishingNativePanel(__instance);
		}

		[HarmonyPatch(typeof(InventoryGui), "Update")]
		[HarmonyPostfix]
		public static void InventoryGui_Update_Postfix(InventoryGui __instance)
		{
			if ((Object)(object)s_menuButtonInstance == (Object)null || !Object.op_Implicit((Object)(object)s_menuButtonInstance))
			{
				EnsureInventoryMenuButton(__instance);
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "Hide")]
		[HarmonyPostfix]
		public static void InventoryGui_Hide_Postfix(InventoryGui __instance)
		{
			CloseFishingNativePanel(__instance);
		}

		[HarmonyPatch(typeof(InventoryGui), "OnOpenTrophies")]
		[HarmonyPostfix]
		public static void InventoryGui_OnOpenTrophies_Postfix(InventoryGui __instance)
		{
			CloseFishingNativePanel(__instance);
		}

		[HarmonyPatch(typeof(InventoryGui), "OnOpenSkills")]
		[HarmonyPostfix]
		public static void InventoryGui_OnOpenSkills_Postfix(InventoryGui __instance)
		{
			CloseFishingNativePanel(__instance);
		}

		[HarmonyPatch(typeof(InventoryGui), "OnOpenTexts")]
		[HarmonyPostfix]
		public static void InventoryGui_OnOpenTexts_Postfix(InventoryGui __instance)
		{
			CloseFishingNativePanel(__instance);
		}

		[HarmonyPatch(typeof(InventoryGui), "OnTabCraftPressed")]
		[HarmonyPostfix]
		public static void InventoryGui_OnTabCraftPressed_Postfix(InventoryGui __instance)
		{
			CloseFishingNativePanel(__instance);
		}

		[HarmonyPatch(typeof(InventoryGui), "OnTabUpgradePressed")]
		[HarmonyPostfix]
		public static void InventoryGui_OnTabUpgradePressed_Postfix(InventoryGui __instance)
		{
			CloseFishingNativePanel(__instance);
		}

		public static void EnsureInventoryMenuButton(InventoryGui gui)
		{
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e6: Expected O, but got Unknown
			//IL_0911: Unknown result type (might be due to invalid IL or missing references)
			//IL_0928: Unknown result type (might be due to invalid IL or missing references)
			//IL_093f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0956: Unknown result type (might be due to invalid IL or missing references)
			//IL_096d: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a08: Expected O, but got Unknown
			//IL_0a35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a59: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adf: Expected O, but got Unknown
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_0684: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_072e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			//IL_078e: Expected O, but got Unknown
			//IL_079d: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a7: Expected O, but got Unknown
			if ((Object)(object)gui == (Object)null)
			{
				return;
			}
			if ((Object)(object)s_menuButtonInstance != (Object)null && Object.op_Implicit((Object)(object)s_menuButtonInstance) && ((Object)s_menuButtonInstance).name == "ArcadeFishing_EquipmentFishButton")
			{
				s_menuButtonInstance.SetActive(true);
				return;
			}
			try
			{
				Transform val = null;
				Transform[] array = Resources.FindObjectsOfTypeAll<Transform>();
				foreach (Transform val2 in array)
				{
					if (((Object)val2).name == "Valheiman equipment")
					{
						val = val2;
						break;
					}
				}
				Transform val3 = null;
				Transform val4 = null;
				Transform val5 = null;
				if ((Object)(object)val != (Object)null)
				{
					Image[] componentsInChildren = ((Component)val).GetComponentsInChildren<Image>(true);
					foreach (Image val6 in componentsInChildren)
					{
						if ((Object)(object)val6.sprite != (Object)null && !string.IsNullOrEmpty(((Object)val6.sprite).name))
						{
							string name = ((Object)val6.sprite).name;
							if (name.Contains("trinket"))
							{
								val3 = (((Object)(object)((Component)val6).transform.parent != (Object)null) ? ((Component)val6).transform.parent : ((Component)val6).transform);
							}
							else if (name.Contains("helmet"))
							{
								val4 = (((Object)(object)((Component)val6).transform.parent != (Object)null) ? ((Component)val6).transform.parent : ((Component)val6).transform);
							}
							else if ((name.Contains("slots.") || name.Contains("ring") || name.Contains("cape")) && (Object)(object)val5 == (Object)null)
							{
								val5 = (((Object)(object)((Component)val6).transform.parent != (Object)null) ? ((Component)val6).transform.parent : ((Component)val6).transform);
							}
						}
					}
				}
				if ((Object)(object)val3 == (Object)null && (Object)(object)val4 == (Object)null)
				{
					Image[] componentsInChildren2 = ((Component)gui).GetComponentsInChildren<Image>(true);
					foreach (Image val7 in componentsInChildren2)
					{
						if ((Object)(object)val7.sprite != (Object)null && !string.IsNullOrEmpty(((Object)val7.sprite).name) && (!((Object)(object)gui.m_recipeListRoot != (Object)null) || !((Component)val7).transform.IsChildOf((Transform)(object)gui.m_recipeListRoot)) && (!((Object)(object)gui.m_repairPanel != (Object)null) || !((Component)val7).transform.IsChildOf(gui.m_repairPanel)))
						{
							string name2 = ((Object)val7.sprite).name;
							if (name2.Contains("slots.trinket") || (name2.Contains("trinket") && name2.Contains("PassiveTree")))
							{
								val3 = (((Object)(object)((Component)val7).transform.parent != (Object)null) ? ((Component)val7).transform.parent : ((Component)val7).transform);
							}
							else if (name2.Contains("slots.helmet") || (name2.Contains("helmet") && name2.Contains("PassiveTree")))
							{
								val4 = (((Object)(object)((Component)val7).transform.parent != (Object)null) ? ((Component)val7).transform.parent : ((Component)val7).transform);
							}
							else if ((name2.StartsWith("PassiveTree.equipment.slots.") || (name2.Contains("slots.") && name2.Contains("equipment"))) && (Object)(object)val5 == (Object)null)
							{
								val5 = (((Object)(object)((Component)val7).transform.parent != (Object)null) ? ((Component)val7).transform.parent : ((Component)val7).transform);
							}
						}
					}
				}
				Transform val8 = val3 ?? val4 ?? val5;
				if ((Object)(object)val8 != (Object)null && (Object)(object)val8.parent != (Object)null)
				{
					if ((Object)(object)s_menuButtonInstance != (Object)null && Object.op_Implicit((Object)(object)s_menuButtonInstance))
					{
						Object.Destroy((Object)(object)s_menuButtonInstance);
						s_menuButtonInstance = null;
					}
					Transform parent = val8.parent;
					RectTransform component = ((Component)val8).GetComponent<RectTransform>();
					float y = component.anchoredPosition.y;
					Rect rect;
					float num2;
					if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null)
					{
						RectTransform component2 = ((Component)val3).GetComponent<RectTransform>();
						RectTransform component3 = ((Component)val4).GetComponent<RectTransform>();
						float num = Mathf.Abs(component2.anchoredPosition.x - component3.anchoredPosition.x);
						if (num < 10f)
						{
							rect = component2.rect;
							num = ((Rect)(ref rect)).width + 6f;
						}
						num2 = component2.anchoredPosition.x + num;
						y = component2.anchoredPosition.y;
					}
					else
					{
						float x = component.anchoredPosition.x;
						rect = component.rect;
						num2 = x + (((Rect)(ref rect)).width + 8f);
					}
					s_menuButtonInstance = Object.Instantiate<GameObject>(((Component)val8).gameObject, parent);
					((Object)s_menuButtonInstance).name = "ArcadeFishing_EquipmentFishButton";
					MonoBehaviour[] components = s_menuButtonInstance.GetComponents<MonoBehaviour>();
					foreach (MonoBehaviour val9 in components)
					{
						if (!(val9 is Graphic) && !(val9 is Selectable) && !(val9 is LayoutElement) && !(val9 is UITooltip))
						{
							Object.Destroy((Object)(object)val9);
						}
					}
					LayoutElement val10 = s_menuButtonInstance.GetComponent<LayoutElement>();
					if ((Object)(object)val10 == (Object)null)
					{
						val10 = s_menuButtonInstance.AddComponent<LayoutElement>();
					}
					val10.ignoreLayout = true;
					RectTransform component4 = s_menuButtonInstance.GetComponent<RectTransform>();
					if ((Object)(object)component4 != (Object)null && (Object)(object)component != (Object)null)
					{
						component4.anchorMin = component.anchorMin;
						component4.anchorMax = component.anchorMax;
						component4.pivot = component.pivot;
						component4.sizeDelta = component.sizeDelta;
						component4.anchoredPosition = new Vector2(num2, y);
					}
					Sprite fishMenuSprite = GetFishMenuSprite();
					Image[] componentsInChildren3 = s_menuButtonInstance.GetComponentsInChildren<Image>(true);
					for (int num3 = componentsInChildren3.Length - 1; num3 >= 0; num3--)
					{
						if ((Object)(object)((Component)componentsInChildren3[num3]).gameObject != (Object)(object)s_menuButtonInstance)
						{
							componentsInChildren3[num3].sprite = fishMenuSprite;
							((Graphic)componentsInChildren3[num3]).color = new Color(0.92f, 0.8f, 0.52f, 1f);
							componentsInChildren3[num3].preserveAspect = true;
							break;
						}
					}
					Button val11 = s_menuButtonInstance.GetComponent<Button>();
					if ((Object)(object)val11 == (Object)null)
					{
						val11 = s_menuButtonInstance.AddComponent<Button>();
					}
					val11.onClick = new ButtonClickedEvent();
					((UnityEvent)val11.onClick).AddListener((UnityAction)delegate
					{
						ToggleFishingNativePanel(gui);
					});
					UITooltip val12 = s_menuButtonInstance.GetComponent<UITooltip>();
					if ((Object)(object)val12 == (Object)null)
					{
						val12 = s_menuButtonInstance.AddComponent<UITooltip>();
					}
					val12.m_topic = AFLocal.Get("btn_tooltip_topic");
					val12.m_text = AFLocal.Get("btn_tooltip_text");
					s_menuButtonInstance.SetActive(true);
					ZLog.Log((object)$"[ArcadeFishing] Cloned equipment slot fish button positioned at ({num2:F1}, {y:F1}) inside {((Object)parent).name}!");
					return;
				}
				if ((Object)(object)s_menuButtonInstance != (Object)null && Object.op_Implicit((Object)(object)s_menuButtonInstance))
				{
					s_menuButtonInstance.SetActive(true);
					return;
				}
				Transform val13 = (((Object)(object)gui.m_player != (Object)null) ? ((Component)gui.m_player).transform : gui.m_inventoryRoot);
				if (!((Object)(object)val13 == (Object)null))
				{
					s_menuButtonInstance = new GameObject("ArcadeFishing_ExternalButton", new Type[4]
					{
						typeof(RectTransform),
						typeof(CanvasRenderer),
						typeof(Image),
						typeof(Button)
					});
					s_menuButtonInstance.transform.SetParent(val13, false);
					RectTransform component5 = s_menuButtonInstance.GetComponent<RectTransform>();
					component5.sizeDelta = new Vector2(46f, 46f);
					component5.anchorMin = new Vector2(1f, 1f);
					component5.anchorMax = new Vector2(1f, 1f);
					component5.pivot = new Vector2(1f, 1f);
					component5.anchoredPosition = new Vector2(-10f, 48f);
					Image component6 = s_menuButtonInstance.GetComponent<Image>();
					Sprite squareSlotSprite = GetSquareSlotSprite();
					if ((Object)(object)squareSlotSprite != (Object)null)
					{
						component6.sprite = squareSlotSprite;
						component6.type = (Type)1;
					}
					((Graphic)component6).color = new Color(0.2f, 0.18f, 0.16f, 0.95f);
					GameObject val14 = new GameObject("Icon", new Type[3]
					{
						typeof(RectTransform),
						typeof(CanvasRenderer),
						typeof(Image)
					});
					val14.transform.SetParent(s_menuButtonInstance.transform, false);
					RectTransform component7 = val14.GetComponent<RectTransform>();
					component7.anchorMin = new Vector2(0.12f, 0.12f);
					component7.anchorMax = new Vector2(0.88f, 0.88f);
					component7.offsetMin = Vector2.zero;
					component7.offsetMax = Vector2.zero;
					Image component8 = val14.GetComponent<Image>();
					component8.sprite = GetFishMenuSprite();
					((Graphic)component8).color = new Color(0.92f, 0.8f, 0.52f, 1f);
					component8.preserveAspect = true;
					Button component9 = s_menuButtonInstance.GetComponent<Button>();
					((Selectable)component9).targetGraphic = (Graphic)(object)component6;
					((UnityEvent)component9.onClick).AddListener((UnityAction)delegate
					{
						ToggleFishingNativePanel(gui);
					});
					UITooltip val15 = s_menuButtonInstance.AddComponent<UITooltip>();
					val15.m_topic = AFLocal.Get("btn_tooltip_topic");
					val15.m_text = AFLocal.Get("btn_tooltip_text");
					s_menuButtonInstance.SetActive(true);
					ZLog.Log((object)"[ArcadeFishing] Vanilla fallback fish button placed on player inventory!");
				}
			}
			catch (Exception ex)
			{
				ZLog.LogWarning((object)("[ArcadeFishing] Error attaching external menu button: " + ex.Message));
			}
		}

		public static void EnsureFishingNativePanel(InventoryGui gui)
		{
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Expected O, but got Unknown
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Expected O, but got Unknown
			//IL_02f0: Expected O, but got Unknown
			if ((Object)(object)gui == (Object)null || (Object)(object)gui.m_trophiesPanel == (Object)null || ((Object)(object)s_fishingPanel != (Object)null && Object.op_Implicit((Object)(object)s_fishingPanel)))
			{
				return;
			}
			try
			{
				s_fishingPanel = Object.Instantiate<GameObject>(gui.m_trophiesPanel, gui.m_trophiesPanel.transform.parent);
				((Object)s_fishingPanel).name = "ArcadeFishing_NativeJournalPanel";
				s_fishingPanel.SetActive(false);
				string text = AFLocal.Get("panel_title");
				TMP_Text[] componentsInChildren = s_fishingPanel.GetComponentsInChildren<TMP_Text>(true);
				foreach (TMP_Text val in componentsInChildren)
				{
					string text2 = ((Object)((Component)val).gameObject).name.ToLower();
					string text3 = val.text.ToLower();
					if ((Object)(object)val.transform.parent == (Object)(object)s_fishingPanel.transform || text2.Contains("topic") || text2.Contains("title") || text2.Contains("header") || text3.Contains("troph") || text3.Contains("трофе"))
					{
						val.text = text;
					}
				}
				Text[] componentsInChildren2 = s_fishingPanel.GetComponentsInChildren<Text>(true);
				foreach (Text val2 in componentsInChildren2)
				{
					string text4 = ((Object)((Component)val2).gameObject).name.ToLower();
					string text5 = val2.text.ToLower();
					if ((Object)(object)((Component)val2).transform.parent == (Object)(object)s_fishingPanel.transform || text4.Contains("topic") || text4.Contains("title") || text4.Contains("header") || text5.Contains("troph") || text5.Contains("трофе"))
					{
						val2.text = text;
					}
				}
				Button[] componentsInChildren3 = s_fishingPanel.GetComponentsInChildren<Button>(true);
				UnityAction val4 = default(UnityAction);
				foreach (Button val3 in componentsInChildren3)
				{
					string text6 = ((Object)((Component)val3).gameObject).name.ToLower();
					if (!text6.Contains("close") && !text6.Contains("cancel") && !text6.Contains("x") && !text6.Contains("ok") && !text6.Contains("back"))
					{
						continue;
					}
					val3.onClick = new ButtonClickedEvent();
					ButtonClickedEvent onClick = val3.onClick;
					UnityAction obj = val4;
					if (obj == null)
					{
						UnityAction val5 = delegate
						{
							CloseFishingNativePanel(gui);
						};
						UnityAction val6 = val5;
						val4 = val5;
						obj = val6;
					}
					((UnityEvent)onClick).AddListener(obj);
					TMP_Text[] componentsInChildren4 = ((Component)val3).GetComponentsInChildren<TMP_Text>(true);
					foreach (TMP_Text val7 in componentsInChildren4)
					{
						val7.text = AFLocal.Get("close");
					}
					Text[] componentsInChildren5 = ((Component)val3).GetComponentsInChildren<Text>(true);
					foreach (Text val8 in componentsInChildren5)
					{
						val8.text = AFLocal.Get("close");
					}
				}
				if ((Object)(object)gui.m_trophieListRoot != (Object)null)
				{
					string name = ((Object)gui.m_trophieListRoot).name;
					RectTransform[] componentsInChildren6 = s_fishingPanel.GetComponentsInChildren<RectTransform>(true);
					foreach (RectTransform val9 in componentsInChildren6)
					{
						if (((Object)val9).name == name && (Object)(object)val9 != (Object)(object)gui.m_trophieListRoot)
						{
							s_fishingListRoot = val9;
							break;
						}
					}
				}
				if ((Object)(object)s_fishingListRoot == (Object)null)
				{
					ScrollRect componentInChildren = s_fishingPanel.GetComponentInChildren<ScrollRect>(true);
					if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.content != (Object)null)
					{
						s_fishingListRoot = componentInChildren.content;
					}
					else
					{
						s_fishingListRoot = s_fishingPanel.GetComponent<RectTransform>();
					}
				}
				if ((Object)(object)s_fishingListRoot != (Object)null)
				{
					s_fishingListRoot.pivot = new Vector2(0.5f, 1f);
					s_fishingListRoot.anchorMin = new Vector2(0f, 1f);
					s_fishingListRoot.anchorMax = new Vector2(1f, 1f);
					s_fishingListRoot.anchoredPosition = new Vector2(0f, 0f);
					for (int num4 = ((Transform)s_fishingListRoot).childCount - 1; num4 >= 0; num4--)
					{
						Object.Destroy((Object)(object)((Component)((Transform)s_fishingListRoot).GetChild(num4)).gameObject);
					}
				}
				s_fishingScrollbar = s_fishingPanel.GetComponentInChildren<Scrollbar>(true);
				ZLog.Log((object)"[ArcadeFishing] Native Fish Journal Panel initialized cleanly!");
			}
			catch (Exception ex)
			{
				ZLog.LogWarning((object)("[ArcadeFishing] Error initializing native fishing panel: " + ex.Message));
			}
		}

		public static void ToggleFishingNativePanel(InventoryGui gui)
		{
			if (!((Object)(object)gui == (Object)null))
			{
				EnsureFishingNativePanel(gui);
				if ((Object)(object)s_fishingPanel != (Object)null && s_fishingPanel.activeSelf)
				{
					CloseFishingNativePanel(gui);
				}
				else
				{
					OpenFishingNativePanel(gui);
				}
			}
		}

		public static void OpenFishingNativePanel(InventoryGui gui)
		{
			if ((Object)(object)gui == (Object)null)
			{
				return;
			}
			EnsureFishingNativePanel(gui);
			if ((Object)(object)Player.m_localPlayer != (Object)null && ((Humanoid)Player.m_localPlayer).GetInventory() != null)
			{
				FishSaveData.SyncInventory(((Humanoid)Player.m_localPlayer).GetInventory());
			}
			if ((Object)(object)gui.m_trophiesPanel != (Object)null)
			{
				gui.m_trophiesPanel.SetActive(false);
			}
			if ((Object)(object)gui.m_skillsDialog != (Object)null)
			{
				((Component)gui.m_skillsDialog).gameObject.SetActive(false);
			}
			if ((Object)(object)gui.m_textsDialog != (Object)null)
			{
				((Component)gui.m_textsDialog).gameObject.SetActive(false);
			}
			if ((Object)(object)gui.m_splitDialog != (Object)null)
			{
				((Component)gui.m_splitDialog).gameObject.SetActive(false);
			}
			if ((Object)(object)gui.m_variantDialog != (Object)null)
			{
				((Component)gui.m_variantDialog).gameObject.SetActive(false);
			}
			if ((Object)(object)s_fishingPanel != (Object)null)
			{
				s_fishingPanel.SetActive(true);
				try
				{
					Traverse.Create((object)gui).Method("SetActiveGroup", new object[2] { 2, true }).GetValue();
				}
				catch (Exception)
				{
				}
				UpdateFishingNativePanel(gui);
			}
		}

		public static void CloseFishingNativePanel(InventoryGui gui)
		{
			if ((Object)(object)s_fishingPanel != (Object)null && s_fishingPanel.activeSelf)
			{
				s_fishingPanel.SetActive(false);
			}
		}

		public static void UpdateFishingNativePanel(InventoryGui gui)
		{
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: 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)
			//IL_0792: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_072e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0924: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)gui == (Object)null || (Object)(object)s_fishingPanel == (Object)null || (Object)(object)s_fishingListRoot == (Object)null || (Object)(object)gui.m_trophieElementPrefab == (Object)null)
			{
				return;
			}
			foreach (GameObject s_fishingListElement in s_fishingListElements)
			{
				if ((Object)(object)s_fishingListElement != (Object)null)
				{
					Object.Destroy((Object)(object)s_fishingListElement);
				}
			}
			s_fishingListElements.Clear();
			bool flag = AFLocal.IsBulgarian();
			float width = 700f;
			float num = -8f;
			CreateCategoryHeaderButtons(gui, num);
			num -= 48f;
			if (s_currentCategory == 0)
			{
				IReadOnlyList<FishSpeciesInfo> allSpecies = FishDatabase.GetAllSpecies();
				for (int i = 0; i < allSpecies.Count; i++)
				{
					FishSpeciesInfo fishSpeciesInfo = allSpecies[i];
					FishRecord record = FishSaveData.GetRecord(fishSpeciesInfo.Id);
					bool flag2 = record != null && (record.Discovered || record.TotalCaught > 0);
					Sprite icon = FishDatabase.GetSpeciesIcon(fishSpeciesInfo) ?? GetFishMenuSprite();
					Color iconColor = (Color)(flag2 ? Color.white : new Color(0.12f, 0.12f, 0.12f, 0.75f));
					string localizedName = FishDatabase.GetLocalizedName(fishSpeciesInfo);
					string baitDisplayName = FishDatabase.GetBaitDisplayName(fishSpeciesInfo.FavoredBait);
					string titleText;
					string detailsText;
					if (flag2)
					{
						int num2 = record?.MaxQuality ?? 1;
						string text = new string('★', Mathf.Clamp(num2, 1, 5));
						titleText = "<size=110%><color=#FFD700>" + localizedName + "</color>  <color=#ECC94B>" + text + "</color></size>";
						detailsText = string.Format("{0}: <color=#FFD700>{1:F1} kg</color>  •  {2}: <color=#68D391>{3}</color>  •  {4}: <color=#63B3ED>{5}</color>  •  {6}: <color=#ECC94B>{7}</color>\n<size=85%><color=#CBD5E0>\"{8}\"</color></size>", AFLocal.Get("record"), record.MaxWeight, AFLocal.Get("caught"), record.TotalCaught, AFLocal.Get("biome"), record.CatchBiome, AFLocal.Get("favored_bait"), baitDisplayName, fishSpeciesInfo.Description);
					}
					else
					{
						titleText = "<size=110%><color=#A0AEC0>??? (" + fishSpeciesInfo.BiomeName + ")</color></size>";
						string text2 = ((!string.IsNullOrEmpty(fishSpeciesInfo.HabitatClue)) ? fishSpeciesInfo.HabitatClue : fishSpeciesInfo.Description);
						detailsText = AFLocal.Get("biome") + ": <color=#63B3ED>" + fishSpeciesInfo.BiomeName + "</color>  •  " + AFLocal.Get("favored_bait") + ": <color=#ECC94B>" + baitDisplayName + "</color>\n<size=85%><color=#718096>" + AFLocal.Get("clue") + ": \"" + text2 + "\"</color></size>";
					}
					GameObject elem = CreateCompendiumCard(gui, width, 84f, num);
					FormatCardLayout(elem, icon, iconColor, titleText, detailsText);
					num -= 92f;
				}
			}
			else if (s_currentCategory == 1)
			{
				PlayerFishData current2 = FishSaveData.Current;
				int num3 = current2?.TotalCatches ?? 0;
				int discoveredCount = FishSaveData.GetDiscoveredCount();
				int num4 = 12;
				float num5 = 0f;
				string text3 = AFLocal.Get("none_yet");
				int num6 = 1;
				if (current2 != null && current2.Records != null)
				{
					foreach (FishRecord record3 in current2.Records)
					{
						if (record3.MaxWeight > num5)
						{
							num5 = record3.MaxWeight;
							FishSpeciesInfo byId = FishDatabase.GetById(record3.SpeciesId);
							if (byId != null)
							{
								text3 = FishDatabase.GetLocalizedName(byId);
							}
						}
						if (record3.MaxQuality > num6)
						{
							num6 = record3.MaxQuality;
						}
					}
				}
				float num7 = 0f;
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					Skills skills = ((Character)Player.m_localPlayer).GetSkills();
					if ((Object)(object)skills != (Object)null)
					{
						num7 = skills.GetSkillFactor((SkillType)104) * 100f;
					}
				}
				string text4 = new string('★', Mathf.Clamp(num6, 1, 5));
				string text5 = string.Format("{0}: <color=#68D391>{1}</color>  |  {2}: <color=#63B3ED>{3}/{4} ({5:F0}%)</color>  |  {6}: <color=#E2E8F0>{7} {8:F1}</color>", AFLocal.Get("total_catches"), num3, AFLocal.Get("species_discovered"), discoveredCount, num4, (float)discoveredCount / (float)num4 * 100f, AFLocal.Get("fishing_skill"), AFLocal.Get("level"), num7);
				string text6 = string.Format("{0}: <color=#FFD700>{1:F1} kg ({2})</color>  |  {3}: <color=#FFD700>{4}</color>", AFLocal.Get("heaviest_catch"), num5, text3, AFLocal.Get("highest_quality"), text4);
				GameObject elem2 = CreateCompendiumCard(gui, width, 84f, num);
				FormatCardLayout(elem2, GetFishMenuSprite(), new Color(1f, 0.85f, 0.4f), "<size=110%><color=#FFD700>" + AFLocal.Get("stats_overview") + "</color></size>", text5 + "\n" + text6);
				num -= 92f;
				int num8 = 0;
				IReadOnlyList<FishSpeciesInfo> allSpecies2 = FishDatabase.GetAllSpecies();
				for (int j = 0; j < allSpecies2.Count; j++)
				{
					FishSpeciesInfo fishSpeciesInfo2 = allSpecies2[j];
					FishRecord record2 = FishSaveData.GetRecord(fishSpeciesInfo2.Id);
					if (record2 != null && (record2.Discovered || record2.TotalCaught > 0))
					{
						num8++;
						Sprite icon2 = FishDatabase.GetSpeciesIcon(fishSpeciesInfo2) ?? GetFishMenuSprite();
						string localizedName2 = FishDatabase.GetLocalizedName(fishSpeciesInfo2);
						string baitDisplayName2 = FishDatabase.GetBaitDisplayName(fishSpeciesInfo2.FavoredBait);
						string text7 = new string('★', Mathf.Clamp(record2.MaxQuality, 1, 5));
						string titleText2 = "<size=110%><color=#FFD700>" + localizedName2 + "</color>  <color=#ECC94B>" + text7 + "</color></size>";
						string detailsText2 = string.Format("{0}: <color=#68D391>{1} pcs</color>  •  {2}: <color=#FFD700>{3:F1} kg</color>  •  {4}: <color=#63B3ED>{5}</color>\n<color=#A0AEC0>{6}: {7} {8}  •  {9}: <color=#ECC94B>{10}</color></color>", AFLocal.Get("caught"), record2.TotalCaught, AFLocal.Get("record"), record2.MaxWeight, AFLocal.Get("biome"), record2.CatchBiome, AFLocal.Get("first_caught"), AFLocal.Get("day"), record2.FirstCatchDay, AFLocal.Get("favored_bait"), baitDisplayName2);
						GameObject elem3 = CreateCompendiumCard(gui, width, 84f, num);
						FormatCardLayout(elem3, icon2, Color.white, titleText2, detailsText2);
						num -= 92f;
					}
				}
				if (num8 == 0)
				{
					GameObject elem4 = CreateCompendiumCard(gui, width, 84f, num);
					FormatCardLayout(elem4, GetFishMenuSprite(), new Color(0.6f, 0.6f, 0.6f), "<color=#ECC94B>" + AFLocal.Get("cat_logs") + "</color>", "<color=#A0AEC0>" + AFLocal.Get("no_logs_yet") + "</color>");
					num -= 92f;
				}
			}
			else if (s_currentCategory == 2)
			{
				IReadOnlyList<BaitInfo> allBaits = FishDatabase.GetAllBaits();
				for (int k = 0; k < allBaits.Count; k++)
				{
					BaitInfo baitInfo = allBaits[k];
					Sprite icon3 = baitInfo.GetIcon() ?? GetFishMenuSprite();
					string text8 = (flag ? baitInfo.BulgarianName : baitInfo.EnglishName);
					string text9 = (flag ? baitInfo.BulgarianRecipe : baitInfo.EnglishRecipe);
					string text10 = (flag ? baitInfo.BulgarianTargetFish : baitInfo.EnglishTargetFish);
					string text11 = (flag ? baitInfo.BulgarianBiomes : baitInfo.EnglishBiomes);
					string text12 = (flag ? baitInfo.BulgarianDescription : baitInfo.EnglishDescription);
					string titleText3 = "<size=110%><color=#ECC94B>" + text8 + "</color></size>";
					string detailsText3 = "<color=#68D391>" + AFLocal.Get("recipe") + ":</color> " + text9 + "\n<color=#ECC94B>" + AFLocal.Get("target_fish") + ":</color> " + text10 + "  •  <color=#63B3ED>" + text11 + "</color>\n<size=85%><color=#CBD5E0>\"" + text12 + "\"</color></size>";
					GameObject elem5 = CreateCompendiumCard(gui, width, 84f, num);
					FormatCardLayout(elem5, icon3, Color.white, titleText3, detailsText3);
					num -= 92f;
				}
			}
			num -= 20f;
			s_fishingListRoot.SetSizeWithCurrentAnchors((Axis)1, Mathf.Abs(num));
			if ((Object)(object)s_fishingScrollbar != (Object)null)
			{
				s_fishingScrollbar.value = 1f;
			}
		}

		private static void CreateCategoryHeaderButtons(InventoryGui gui, float posY)
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: 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)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Expected O, but got Unknown
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			float num = 224f;
			float num2 = 36f;
			string[] array = new string[3]
			{
				AFLocal.Get("cat_fish"),
				AFLocal.Get("cat_logs"),
				AFLocal.Get("cat_baits")
			};
			float[] array2 = new float[3] { -236f, 0f, 236f };
			for (int i = 0; i < 3; i++)
			{
				int catIndex = i;
				bool flag = s_currentCategory == catIndex;
				GameObject val = Object.Instantiate<GameObject>(gui.m_trophieElementPrefab, (Transform)(object)s_fishingListRoot);
				((Object)val).name = $"ArcadeFishing_CatBtn_{catIndex}";
				val.SetActive(true);
				s_fishingListElements.Add(val);
				RectTransform component = val.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchorMin = new Vector2(0.5f, 1f);
					component.anchorMax = new Vector2(0.5f, 1f);
					component.pivot = new Vector2(0.5f, 1f);
					component.sizeDelta = new Vector2(num, num2);
					component.anchoredPosition = new Vector2(array2[i], posY);
				}
				Transform val2 = val.transform.Find("icon_bkg");
				if ((Object)(object)val2 != (Object)null)
				{
					((Component)val2).gameObject.SetActive(false);
				}
				Transform val3 = val.transform.Find("description");
				if ((Object)(object)val3 != (Object)null)
				{
					((Component)val3).gameObject.SetActive(false);
				}
				Transform val4 = val.transform.Find("name");
				if ((Object)(object)val4 != (Object)null)
				{
					RectTransform component2 = ((Component)val4).GetComponent<RectTransform>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.anchorMin = Vector2.zero;
						component2.anchorMax = Vector2.one;
						component2.offsetMin = Vector2.zero;
						component2.offsetMax = Vector2.zero;
					}
					TMP_Text component3 = ((Component)val4).GetComponent<TMP_Text>();
					if ((Object)(object)component3 != (Object)null)
					{
						component3.alignment = (TextAlignmentOptions)514;
						component3.text = (flag ? ("<color=#FFD700><b>" + array[i] + "</b></color>") : ("<color=#A0AEC0>" + array[i] + "</color>"));
					}
					Text component4 = ((Component)val4).GetComponent<Text>();
					if ((Object)(object)component4 != (Object)null)
					{
						component4.alignment = (TextAnchor)4;
						component4.text = array[i];
						((Graphic)component4).color = (flag ? new Color(1f, 0.84f, 0f) : new Color(0.7f, 0.7f, 0.7f));
					}
				}
				Button val5 = val.GetComponent<Button>();
				if ((Object)(object)val5 == (Object)null)
				{
					val5 = val.AddComponent<Button>();
				}
				val5.onClick = new ButtonClickedEvent();
				((UnityEvent)val5.onClick).AddListener((UnityAction)delegate
				{
					s_currentCategory = catIndex;
					UpdateFishingNativePanel(gui);
				});
				Image component5 = val.GetComponent<Image>();
				if ((Object)(object)component5 != (Object)null)
				{
					((Graphic)component5).color = (flag ? new Color(0.4f, 0.32f, 0.16f, 0.95f) : new Color(0.18f, 0.16f, 0.15f, 0.85f));
				}
			}
		}

		private static GameObject CreateCompendiumCard(InventoryGui gui, float width, float height, float posY)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(gui.m_trophieElementPrefab, (Transform)(object)s_fishingListRoot);
			val.SetActive(true);
			s_fishingListElements.Add(val);
			RectTransform component = val.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.5f, 1f);
				component.anchorMax = new Vector2(0.5f, 1f);
				component.pivot = new Vector2(0.5f, 1f);
				component.sizeDelta = new Vector2(width, height);
				component.anchoredPosition = new Vector2(0f, posY);
			}
			return val;
		}

		private static void FormatCardLayout(GameObject elem, Sprite icon, Color iconColor, string titleText, string detailsText)
		{
			//IL_0046: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			Transform val = elem.transform.Find("icon_bkg");
			if ((Object)(object)val != (Object)null)
			{
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchorMin = new Vector2(0f, 0.5f);
					component.anchorMax = new Vector2(0f, 0.5f);
					component.pivot = new Vector2(0f, 0.5f);
					component.sizeDelta = new Vector2(64f, 64f);
					component.anchoredPosition = new Vector2(14f, 0f);
				}
			}
			Transform obj = elem.transform.Find("icon_bkg/icon");
			Image val2 = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				val2.sprite = icon;
				((Graphic)val2).color = iconColor;
				val2.preserveAspect = true;
			}
			Transform val3 = elem.transform.Find("name");
			if ((Object)(object)val3 != (Object)null)
			{
				RectTransform component2 = ((Component)val3).GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.anchorMin = new Vector2(0f, 1f);
					component2.anchorMax = new Vector2(1f, 1f);
					component2.pivot = new Vector2(0f, 1f);
					component2.sizeDelta = new Vector2(-105f, 26f);
					component2.anchoredPosition = new Vector2(90f, -8f);
				}
				TMP_Text component3 = ((Component)val3).GetComponent<TMP_Text>();
				if ((Object)(object)component3 != (Object)null)
				{
					component3.alignment = (TextAlignmentOptions)513;
					component3.enableWordWrapping = false;
					component3.text = titleText;
				}
				Text component4 = ((Component)val3).GetComponent<Text>();
				if ((Object)(object)component4 != (Object)null)
				{
					component4.alignment = (TextAnchor)3;
					component4.text = titleText;
				}
			}
			Transform val4 = elem.transform.Find("description");
			if ((Object)(object)val4 != (Object)null)
			{
				RectTransform component5 = ((Component)val4).GetComponent<RectTransform>();
				if ((Object)(object)component5 != (Object)null)
				{
					component5.anchorMin = new Vector2(0f, 1f);
					component5.anchorMax = new Vector2(1f, 1f);
					component5.pivot = new Vector2(0f, 1f);
					component5.sizeDelta = new Vector2(-105f, 46f);
					component5.anchoredPosition = new Vector2(90f, -34f);
				}
				TMP_Text component6 = ((Component)val4).GetComponent<TMP_Text>();
				if ((Object)(object)component6 != (Object)null)
				{
					component6.alignment = (TextAlignmentOptions)513;
					component6.enableWordWrapping = true;
					component6.text = detailsText;
				}
				Text component7 = ((Component)val4).GetComponent<Text>();
				if ((Object)(object)component7 != (Object)null)
				{
					component7.alignment = (TextAnchor)0;
					component7.text = detailsText;
				}
			}
		}

		private static GameObject CreateSectionDivider(InventoryGui gui, float width, float posY, string title)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(gui.m_trophieElementPrefab, (Transform)(object)s_fishingListRoot);
			val.SetActive(true);
			s_fishingListElements.Add(val);
			RectTransform component = val.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				component.anchorMin = new Vector2(0.5f, 1f);
				component.anchorMax = new Vector2(0.5f, 1f);
				component.pivot = new Vector2(0.5f, 1f);
				component.sizeDelta = new Vector2(width, 32f);
				component.anchoredPosition = new Vector2(0f, posY);
			}
			Transform val2 = val.transform.Find("icon_bkg");
			if ((Object)(object)val2 != (Object)null)
			{
				((Component)val2).gameObject.SetActive(false);
			}
			Transform val3 = val.transform.Find("description");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).gameObject.SetActive(false);
			}
			Transform val4 = val.transform.Find("name");
			if ((Object)(object)val4 != (Object)null)
			{
				RectTransform component2 = ((Component)val4).GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.anchorMin = new Vector2(0f, 0f);
					component2.anchorMax = new Vector2(1f, 1f);
					component2.offsetMin = Vector2.zero;
					component2.offsetMax = Vector2.zero;
				}
				TMP_Text component3 = ((Component)val4).GetComponent<TMP_Text>();
				if ((Object)(object)component3 != (Object)null)
				{
					component3.alignment = (TextAlignmentOptions)514;
					component3.text = "<color=#FFD700><size=115%><b>" + title + "</b></size></color>";
				}
				Text component4 = ((Component)val4).GetComponent<Text>();
				if ((Object)(object)component4 != (Object)null)
				{
					component4.alignment = (TextAnchor)4;
					component4.text = title;
				}
			}
			return val;
		}

		private static void SetTextOrTMP(Transform target, GameObject parent, string fallbackName, string text)
		{
			if ((Object)(object)target != (Object)null)
			{
				TMP_Text component = ((Component)target).GetComponent<TMP_Text>();
				if ((Object)(object)component != (Object)null)
				{
					component.text = text;
					return;
				}
				Text component2 = ((Component)target).GetComponent<Text>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.text = text;
					return;
				}
			}
			TMP_Text[] componentsInChildren = parent.GetComponentsInChildren<TMP_Text>(true);
			foreach (TMP_Text val in componentsInChildren)
			{
				if (((Object)((Component)val).gameObject).name.ToLower().Contains(fallbackName))
				{
					val.text = text;
					return;
				}
			}
			Text[] componentsInChildren2 = parent.GetComponentsInChildren<Text>(true);
			foreach (Text val2 in componentsInChildren2)
			{
				if (((Object)((Component)val2).gameObject).name.ToLower().Contains(fallbackName))
				{
					val2.text = text;
					break;
				}
			}
		}

		public static void ExecuteCatchSuccess(FishingFloat ff, Fish fish, Player player)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ff == (Object)null || (Object)(object)fish == (Object)null || (Object)(object)player == (Object)null)
			{
				return;
			}
			s_isMinigameCatching = true;
			try
			{
				string text = FishingFloat.Catch(fish, (Character)(object)player);
				if (!string.IsNullOrEmpty(text) && (Object)(object)MessageHud.instance != (Object)null)
				{
					MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false, true);
				}
				((Character)player).RaiseSkill((SkillType)104, 2f);
				if (ArcadeFishingPlugin.EnableSoundEffects.Value)
				{
					PlayCatchSound(player, ((Component)player).transform.position);
				}
				fish.OnHooked((FishingFloat)null);
				ZNetView component = ((Component)ff).GetComponent<ZNetView>();
				if ((Object)(object)component != (Object)null && component.IsValid())
				{
					component.Destroy();
				}
				else
				{
					Object.Destroy((Object)(object)((Component)ff).gameObject);
				}
			}
			catch (Exception ex)
			{
				ZLog.LogError((object)("[ArcadeFishing] Error during ExecuteCatchSuccess: " + ex.Message));
			}
			finally
			{
				s_isMinigameCatching = false;
			}
		}

		private static void PlayCatchSound(Player player, Vector3 pos)
		{
			//IL_0022: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)player != (Object)null && player.m_skillLevelupEffects != null)
				{
					player.m_skillLevelupEffects.Create(pos, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
				}
			}
			catch (Exception)
			{
			}
		}
	}
	[Serializable]
	public class FishRecord
	{
		public int SpeciesId;

		public bool Discovered;

		public int TotalCaught;

		public int MaxQuality;

		public float MaxWeight;

		public int FirstCatchDay;

		public string CatchBiome = "Unknown";

		public string FirstCatchDate = "";
	}
	public class PlayerFishData
	{
		public string PlayerName = "Viking";

		public long PlayerId = 0L;

		public int TotalCatches = 0;

		public List<FishRecord> Records = new List<FishRecord>();
	}
	public static class FishSaveData
	{
		private static PlayerFishData s_currentData;

		private static string s_currentSavePath;

		private static readonly Dictionary<int, FishRecord> s_recordsLookup = new Dictionary<int, FishRecord>();

		public static PlayerFishData Current => s_currentData;

		public static void InitializeForPlayer(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			string playerName = player.GetPlayerName();
			long playerID = player.GetPlayerID();
			string text = string.Join("_", playerName.Split(Path.GetInvalidFileNameChars()));
			if (string.IsNullOrEmpty(text))
			{
				text = "DefaultPlayer";
			}
			string text2 = Path.Combine(Paths.ConfigPath, "ArcadeFishing");
			try
			{
				if (!Directory.Exists(text2))
				{
					Directory.CreateDirectory(text2);
				}
			}
			catch (Exception ex)
			{
				ZLog.LogWarning((object)("[ArcadeFishing] Could not create save dir: " + ex.Message));
			}
			s_currentSavePath = Path.Combine(text2, $"logbook_{text}_{playerID}.json");
			Load();
			if (((Humanoid)player).GetInventory() != null)
			{
				SyncInventory(((Humanoid)player).GetInventory());
			}
		}

		public static void Load()
		{
			s_recordsLookup.Clear();
			s_currentData = new PlayerFishData();
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				s_currentData.PlayerName = Player.m_localPlayer.GetPlayerName();
				s_currentData.PlayerId = Player.m_localPlayer.GetPlayerID();
			}
			if (!string.IsNullOrEmpty(s_currentSavePath) && File.Exists(s_currentSavePath))
			{
				try
				{
					string input = File.ReadAllText(s_currentSavePath);
					Match match = Regex.Match(input, "\"PlayerName\"\\s*:\\s*\"(.*?)\"");
					if (match.Success)
					{
						s_currentData.PlayerName = match.Groups[1].Value;
					}
					Match match2 = Regex.Match(input, "\"PlayerId\"\\s*:\\s*(\\d+)");
					if (match2.Success && long.TryParse(match2.Groups[1].Value, out var result))
					{
						s_currentData.PlayerId = result;
					}
					Match match3 = Regex.Match(input, "\"TotalCatches\"\\s*:\\s*(\\d+)");
					if (match3.Success && int.TryParse(match3.Groups[1].Value, out var result2))
					{
						s_currentData.TotalCatches = result2;
					}
					MatchCollection matchCollection = Regex.Matches(input, "\\{[^{}]*\"SpeciesId\"[^{}]*\\}");
					foreach (Match item in matchCollection)
					{
						try
						{
							FishRecord fishRecord = JsonUtility.FromJson<FishRecord>(item.Value);
							if (fishRecord != null && fishRecord.SpeciesId > 0)
							{
								s_currentData.Records.Add(fishRecord);
								s_recordsLookup[fishRecord.SpeciesId] = fishRecord;
							}
						}
						catch
						{
						}
					}
				}
				catch (Exception ex)
				{
					ZLog.LogWarning((object)("[ArcadeFishing] Error loading save data: " + ex.Message));
				}
			}
			foreach (FishSpeciesInfo allSpecy in FishDatabase.GetAllSpecies())
			{
				if (!s_recordsLookup.TryGetValue(allSpecy.Id, out var value))
				{
					value = new FishRecord
					{
						SpeciesId = allSpecy.Id,
						Discovered = false,
						TotalCaught = 0,
						MaxQuality = 1,
						MaxWeight = 0f,
						FirstCatchDay = 0,
						CatchBiome = allSpecy.BiomeName,
						FirstCatchDate = ""
					};
					s_currentData.Records.Add(value);
					s_recordsLookup[allSpecy.Id] = value;
				}
			}
		}

		public static void Save()
		{
			if (s_currentData == null || string.IsNullOrEmpty(s_currentSavePath))
			{
				return;
			}
			try
			{
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine("{");
				stringBuilder.AppendLine("  \"PlayerName\": \"" + s_currentData.PlayerName.Replace("\"", "\\\"") + "\",");
				stringBuilder.AppendLine($"  \"PlayerId\": {s_currentData.PlayerId},");
				stringBuilder.AppendLine($"  \"TotalCatches\": {s_currentData.TotalCatches},");
				stringBuilder.AppendLine("  \"Records\": [");
				IReadOnlyList<FishSpeciesInfo> allSpecies = FishDatabase.GetAllSpecies();
				for (int i = 0; i < allSpecies.Count; i++)
				{
					FishSpeciesInfo fishSpeciesInfo = allSpecies[i];
					FishRecord record = GetRecord(fishSpeciesInfo.Id);
					if (record != null)
					{
						stringBuilder.Append("    { ");
						stringBuilder.Append($"\"SpeciesId\": {record.SpeciesId}, ");
						stringBuilder.Append("\"Discovered\": " + (record.Discovered ? "true" : "false") + ", ");
						stringBuilder.Append($"\"TotalCaught\": {record.TotalCaught}, ");
						stringBuilder.Append($"\"MaxQuality\": {record.MaxQuality}, ");
						stringBuilder.Append("\"MaxWeight\": " + record.MaxWeight.ToString("F1", CultureInfo.InvariantCulture) + ", ");
						stringBuilder.Append($"\"FirstCatchDay\": {record.FirstCatchDay}, ");
						stringBuilder.Append("\"CatchBiome\": \"" + record.CatchBiome.Replace("\"", "\\\"") + "\", ");
						stringBuilder.Append("\"FirstCatchDate\": \"" + record.FirstCatchDate.Replace("\"", "\\\"") + "\"");
						stringBuilder.Append(" }");
						if (i < allSpecies.Count - 1)
						{
							stringBuilder.Append(",");
						}
						stringBuilder.AppendLine();
					}
				}
				stringBuilder.AppendLine("  ]");
				stringBuilder.AppendLine("}");
				string text = s_currentSavePath + ".tmp";
				File.WriteAllText(text, stringBuilder.ToString());
				if (File.Exists(s_currentSavePath))
				{
					File.Delete(s_currentSavePath);
				}
				File.Move(text, s_currentSavePath);
			}
			catch (Exception ex)
			{
				ZLog.LogError((object)("[ArcadeFishing] Failed to save player fishing logbook: " + ex.Message));
			}
		}

		public static FishRecord GetRecord(int speciesId)
		{
			if (s_recordsLookup.TryGetValue(speciesId, out var value))
			{
				return value;
			}
			return null;
		}

		public static int GetDiscoveredCount()
		{
			int num = 0;
			foreach (KeyValuePair<int, FishRecord> item in s_recordsLookup)
			{
				if (item.Value.Discovered)
				{
					num++;
				}
			}
			return num;
		}

		public static bool RecordCatch(FishSpeciesInfo species, int quality, float weight, string biome, int day)
		{
			if (species == null)
			{
				return false;
			}
			if (s_currentData == null)
			{
				if (!((Object)(object)Player.m_localPlayer != (Object)null))
				{
					return false;
				}
				InitializeForPlayer(Player.m_localPlayer);
			}
			FishRecord record = GetRecord(species.Id);
			if (record == null)
			{
				record = new FishRecord
				{
					SpeciesId = species.Id,
					Discovered = true,
					TotalCaught = 1,
					MaxQuality = quality,
					MaxWeight = weight,
					FirstCatchDay = day,
					CatchBiome = biome,
					FirstCatchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm")
				};
				s_currentData.Records.Add(record);
				s_recordsLookup[species.Id] = record;
			}
			else
			{
				record.Discovered = true;
				record.TotalCaught++;
				if (record.FirstCatchDay <= 0)
				{
					record.FirstCatchDay = day;
					record.FirstCatchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
				}
				if (weight > record.MaxWeight)
				{
					record.MaxWeight = weight;
					record.MaxQuality = quality;
					record.CatchBiome = biome;
				}
				else if (quality > record.MaxQuality)
				{
					record.MaxQuality = quality;
				}
			}
			s_currentData.TotalCatches++;
			Save();
			return true;
		}

		public static void SyncInventory(Inventory inventory)
		{
			if (inventory == null)
			{
				return;
			}
			bool flag = false;
			foreach (ItemData allItem in inventory.GetAllItems())
			{
				if (allItem == null || (Object)(object)allItem.m_dropPrefab == (Object)null)
				{
					continue;
				}
				string name = ((Object)allItem.m_dropPrefab).name;
				FishSpeciesInfo fishSpeciesInfo = FishDatabase.FindSpecies(name) ?? FishDatabase.FindSpecies(allItem.m_shared.m_name);
				if (fishSpeciesInfo == null)
				{
					continue;
				}
				FishRecord record = GetRecord(fishSpeciesInfo.Id);
				if (record != null && !record.Discovered)
				{
					record.Discovered = true;
					if (record.TotalCaught == 0)
					{
						record.TotalCaught = allItem.m_stack;
					}
					record.MaxQuality = Mathf.Max(1, allItem.m_quality);
					float num = fishSpeciesInfo.BaseWeight * (0.85f + (float)record.MaxQuality * 0.4f);
					record.MaxWeight = Mathf.Round(num * 10f) / 10f;
					record.CatchBiome = fishSpeciesInfo.BiomeName;
					if ((Object)(object)EnvMan.instance != (Object)null)
					{
						record.FirstCatchDay = EnvMan.instance.GetDay();
					}
					record.FirstCatchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
					flag = true;
				}
			}
			if (flag)
			{
				Save();
			}
		}
	}
}
namespace ArcadeFishing.UI
{
	public class FishingMinigameUI : MonoBehaviour
	{
		private FishingFloat m_fishingFloat;

		private Fish m_fish;

		private Fish