using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FishNet; using FishNet.Broadcast; using FishNet.Connection; using FishNet.Object; using FishNet.Serializing; using FishNet.Transporting; using HarmonyLib; using HowtoFishIdentityAPI.Api; using HowtoFishLocalizationAPI.Api; using Newtonsoft.Json; using OwnedItemRecovery.Configuration; using OwnedItemRecovery.Localization; using OwnedItemRecovery.Runtime; using OwnedItemRecovery.UI; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("OwnedItemRecovery")] [assembly: AssemblyDescription("Owned Item Recovery for How to Fish by Ice Box Studio")] [assembly: AssemblyCompany("Ice Box Studio")] [assembly: AssemblyProduct("OwnedItemRecovery")] [assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")] [assembly: ComVisible(false)] [assembly: Guid("73f7f5bf-64e5-4e2a-9bbf-4e7a3f36dcf4")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace OwnedItemRecovery { [BepInPlugin("IceBoxStudio.HowToFish.OwnedItemRecovery", "OwnedItemRecovery", "1.0.0")] [BepInDependency("IceBoxStudio.HowToFish.LocalizationAPI", "1.0.0")] [BepInDependency("IceBoxStudio.HowToFish.IdentityAPI", "1.0.0")] public sealed class OwnedItemRecoveryPlugin : BaseUnityPlugin { private Harmony _harmony; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; try { Log.LogInfo((object)"============================================="); Log.LogInfo((object)("OwnedItemRecovery " + I18n.Text("plugin.initializing"))); Log.LogInfo((object)(I18n.Text("plugin.author_prefix") + "Ice Box Studio(https://steamcommunity.com/id/ibox666/)")); ConfigManager.Init(((BaseUnityPlugin)this).Config); OwnedItemRuntime.Init(((BaseUnityPlugin)this).Logger); _harmony = new Harmony("IceBoxStudio.HowToFish.OwnedItemRecovery"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)("OwnedItemRecovery " + I18n.Text("plugin.initialized"))); Log.LogInfo((object)"============================================="); } catch (Exception arg) { Log.LogError((object)$"Failed to initialize OwnedItemRecovery: {arg}"); } } private void Update() { OwnedItemRuntime.Update(); } } public static class PluginInfo { public const string PLUGIN_GUID = "IceBoxStudio.HowToFish.OwnedItemRecovery"; public const string PLUGIN_NAME = "OwnedItemRecovery"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace OwnedItemRecovery.UI { internal sealed class OwnedItemUi : MonoBehaviour { private static readonly BindingFlags PrivateInstance = BindingFlags.Instance | BindingFlags.NonPublic; private static OwnedItemUi _current; private GameObject _pauseHolder; private GameObject _mainScreen; private GameObject _optionsScreen; private GameObject _serverScreen; private GameObject _root; private GameObject _buttonTemplate; private Transform _rows; private TextMeshProUGUI _title; private TextMeshProUGUI _summary; private TextMeshProUGUI _allLabel; private TextMeshProUGUI _closeLabel; private Button _allButton; private bool _open; private bool _built; internal static bool IsOpen { get { if (Object.op_Implicit((Object)(object)_current)) { return _current._open; } return false; } } internal static void Attach() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_current)) { Transform fXCanvasTrans = PlayerUI.FXCanvasTrans; if (Object.op_Implicit((Object)(object)fXCanvasTrans)) { GameObject val = new GameObject("OwnedItemRecovery UI"); val.transform.SetParent(fXCanvasTrans, false); _current = val.AddComponent(); _current.TryBuild(); } } } internal static void Open() { Attach(); if (Object.op_Implicit((Object)(object)_current)) { _current.Show(); } } internal static void Toggle() { if (IsOpen) { _current.Hide(); } else { Open(); } } internal static void RefreshAll() { if (Object.op_Implicit((Object)(object)_current) && _current._open) { _current.Refresh(); } } internal static void DestroyCurrent() { if (Object.op_Implicit((Object)(object)_current)) { if (Object.op_Implicit((Object)(object)_current._root)) { Object.Destroy((Object)(object)_current._root); } Object.Destroy((Object)(object)((Component)_current).gameObject); } _current = null; } private bool Build(PauseManager pause, GameObject holder) { //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028f: 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) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: 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) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Expected O, but got Unknown //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Expected O, but got Unknown _pauseHolder = holder; _mainScreen = GetObject(pause, "_mainScreen"); _optionsScreen = GetObject(pause, "_optionsScreen"); _serverScreen = GetObject(pause, "_serverSettingsScreen"); if (!Object.op_Implicit((Object)(object)_serverScreen)) { return false; } _root = Object.Instantiate(_serverScreen, _pauseHolder.transform, false); ((Object)_root).name = "OwnedItemRecoveryScreen"; _root.SetActive(false); Transform val = _root.transform.Find("PausedText"); Transform val2 = _root.transform.Find("ServerDisplay"); Transform val3 = _root.transform.Find("LowerButtonHolder/BackButton"); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3)) { return false; } _title = ((Component)val).GetComponent(); _buttonTemplate = ((Component)val3).gameObject; Button val4 = UseButton(_buttonTemplate); _closeLabel = GetText(_buttonTemplate); if ((Object)(object)_title == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)_closeLabel == (Object)null) { return false; } ((UnityEvent)val4.onClick).AddListener(new UnityAction(Hide)); DisableForeignComponents(((Component)_title).gameObject); GameObject gameObject = ((Component)val2).gameObject; TextMeshProUGUI componentInChildren = ((Component)val2).GetComponentInChildren(true); if ((Object)(object)componentInChildren == (Object)null) { return false; } foreach (Transform item in _root.transform) { Transform val5 = item; if ((Object)(object)val5 != (Object)(object)val && (Object)(object)val5 != (Object)(object)val2 && (Object)(object)val5 != (Object)(object)val3.parent) { ((Component)val5).gameObject.SetActive(false); } } foreach (Transform item2 in val2) { Transform val6 = item2; if (((Object)val6).name != "Outline") { ((Component)val6).gameObject.SetActive(false); } } RectTransform component = gameObject.GetComponent(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = Vector2.zero; component.sizeDelta = new Vector2(860f, 580f); GameObject val7 = new GameObject("OwnedItemContent"); val7.transform.SetParent(val2, false); RectTransform val8 = val7.AddComponent(); val8.anchorMin = Vector2.zero; val8.anchorMax = Vector2.one; val8.offsetMin = new Vector2(28f, 24f); val8.offsetMax = new Vector2(-28f, -24f); ((Transform)val8).localScale = Vector3.one; ((Transform)val8).SetAsLastSibling(); VerticalLayoutGroup obj = val7.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; _summary = AddText(componentInChildren, (Transform)(object)val8, "Summary", 20f, 32f, (TextAlignmentOptions)514); BuildRows((Transform)(object)val8, componentInChildren); GameObject val9 = new GameObject("Footer"); val9.transform.SetParent((Transform)(object)val8, false); val9.AddComponent().preferredHeight = 48f; HorizontalLayoutGroup obj2 = val9.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; GameObject val10 = MakeButton(_buttonTemplate, val9.transform, "RecoverAll"); _allButton = GetButton(val10); _allLabel = GetText(val10); if ((Object)(object)_allButton == (Object)null || (Object)(object)_allLabel == (Object)null) { return false; } ConfigureButtonText(_allLabel, 12f, Mathf.Max(18f, ((TMP_Text)_allLabel).fontSize)); ((UnityEvent)_allButton.onClick).AddListener(new UnityAction(RecoverAll)); (val10.GetComponent() ?? val10.AddComponent()).preferredHeight = 48f; LocalizationApi.LanguageChanged += OnLanguageChanged; Refresh(); return true; } private void BuildRows(Transform parent, TextMeshProUGUI nativeText) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00ce: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("OwnedItemViewport"); val.transform.SetParent(parent, false); val.AddComponent().preferredHeight = 390f; RectTransform val2 = val.GetComponent() ?? val.AddComponent(); ((Transform)val2).localScale = Vector3.one; ((Graphic)val.AddComponent()).color = new Color(0f, 0f, 0f, 0.08f); val.AddComponent(); ScrollRect obj = val.AddComponent(); obj.horizontal = false; obj.vertical = true; obj.movementType = (MovementType)1; obj.scrollSensitivity = 30f; GameObject val3 = new GameObject("Rows"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.GetComponent() ?? val3.AddComponent(); val4.anchorMin = new Vector2(0f, 1f); val4.anchorMax = new Vector2(1f, 1f); val4.pivot = new Vector2(0.5f, 1f); val4.anchoredPosition = Vector2.zero; val4.sizeDelta = new Vector2(0f, 0f); ((Transform)val4).localScale = Vector3.one; VerticalLayoutGroup obj2 = val3.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f; ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ContentSizeFitter obj3 = val3.AddComponent(); obj3.horizontalFit = (FitMode)0; obj3.verticalFit = (FitMode)2; obj.viewport = val2; obj.content = val4; _rows = val3.transform; } private bool TryBuild() { if (_built) { return true; } PauseManager val = Object.FindAnyObjectByType(); GameObject val2 = (Object.op_Implicit((Object)(object)val) ? GetObject(val, "_pauseHolder") : null); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2)) { return false; } if (Object.op_Implicit((Object)(object)_root)) { Object.Destroy((Object)(object)_root); _root = null; } if (!Build(val, val2)) { if (Object.op_Implicit((Object)(object)_root)) { Object.Destroy((Object)(object)_root); _root = null; } return false; } _built = true; return true; } private void Update() { if (Object.op_Implicit((Object)(object)Player.LocalPlayer) && !MainMenuManager.IsInMenu && (_built || TryBuild()) && _open && Input.GetKeyDown((KeyCode)27)) { Hide(); } } private void OnDestroy() { LocalizationApi.LanguageChanged -= OnLanguageChanged; if ((Object)(object)_current == (Object)(object)this) { _current = null; } } private void OnLanguageChanged(string language) { Refresh(); } private void Show() { if (!_built && !TryBuild()) { return; } if (_open) { Refresh(); return; } _open = true; _root.SetActive(true); HideNativeScreens(); PauseManager.TogglePause(true); HideNativeScreens(); _root.SetActive(true); Refresh(); if ((Object)(object)EventSystem.current != (Object)null && (Object)(object)_allButton != (Object)null) { EventSystem.current.SetSelectedGameObject(((Component)_allButton).gameObject); } } private void Hide() { if (_open) { _open = false; if (Object.op_Implicit((Object)(object)_root)) { _root.SetActive(false); } PauseManager.TogglePause(false); } } private void HideNativeScreens() { if (Object.op_Implicit((Object)(object)_mainScreen)) { _mainScreen.SetActive(false); } if (Object.op_Implicit((Object)(object)_optionsScreen)) { _optionsScreen.SetActive(false); } if (Object.op_Implicit((Object)(object)_serverScreen)) { _serverScreen.SetActive(false); } } private void RecoverAll() { OwnedItemRuntime.RecoverAll(); } private void RecoverSingle(int objectId) { OwnedItemRuntime.RecoverSingle(objectId); } private void Refresh() { if ((Object)(object)_title == (Object)null || (Object)(object)_summary == (Object)null || (Object)(object)_allLabel == (Object)null || (Object)(object)_closeLabel == (Object)null || (Object)(object)_rows == (Object)null) { return; } List clientStates = OwnedItemRuntime.GetClientStates(); int num = 0; int num2 = 0; string text2 = default(string); string text = (((Object)(object)Player.LocalPlayer != (Object)null && IdentityApi.TryGetKey(Player.LocalPlayer, ref text2)) ? text2 : null); for (int i = 0; i < clientStates.Count; i++) { if (!string.IsNullOrEmpty(text) && clientStates[i].PlayerKey == text) { num++; if (clientStates[i].HolderSteamID == 0L) { num2++; } } } ((TMP_Text)_title).text = I18n.Text("owned.ui.title"); ((TMP_Text)_summary).text = I18n.Text("owned.ui.summary", num, num2); ((TMP_Text)_allLabel).text = I18n.Text("owned.ui.recover_all"); ((TMP_Text)_closeLabel).text = I18n.Text("owned.ui.close"); ((Selectable)_allButton).interactable = num2 > 0; RefreshRows(clientStates, text); } private void RefreshRows(List states, string localKey) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown for (int num = _rows.childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)_rows.GetChild(num)).gameObject); } bool flag = false; for (int i = 0; i < states.Count; i++) { OwnedItemStateBroadcast ownedItemStateBroadcast = states[i]; if (string.IsNullOrEmpty(localKey) || ownedItemStateBroadcast.PlayerKey != localKey) { continue; } flag = true; GameObject val = new GameObject("OwnedItemRow " + ownedItemStateBroadcast.ObjectId); val.transform.SetParent(_rows, false); val.AddComponent().preferredHeight = 56f; HorizontalLayoutGroup obj = val.AddComponent(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; string text = (string.IsNullOrWhiteSpace(ownedItemStateBroadcast.OwnerName) ? ownedItemStateBroadcast.PlayerKey : ownedItemStateBroadcast.OwnerName); string text2 = I18n.Text(ownedItemStateBroadcast.DeathDrop ? "owned.ui.death_drop" : "owned.ui.manual_drop"); string text3 = ((ownedItemStateBroadcast.HolderSteamID == 0L) ? I18n.Text("owned.ui.on_ground") : I18n.Text("owned.ui.on_player", string.IsNullOrWhiteSpace(ownedItemStateBroadcast.HolderName) ? ownedItemStateBroadcast.HolderSteamID.ToString() : ownedItemStateBroadcast.HolderName)); string text4 = I18n.Text("owned.ui.row", ownedItemStateBroadcast.ItemName, text, text2, text3); TextMeshProUGUI val2 = AddText(GetText(_buttonTemplate), val.transform, "Details", 17f, 56f, (TextAlignmentOptions)513); ((TMP_Text)val2).text = text4; (((Component)val2).GetComponent() ?? ((Component)val2).gameObject.AddComponent()).flexibleWidth = 1f; if (ownedItemStateBroadcast.HolderSteamID != 0L) { continue; } GameObject val3 = MakeButton(_buttonTemplate, val.transform, "Recover"); Button button = GetButton(val3); TextMeshProUGUI text5 = GetText(val3); if ((Object)(object)button == (Object)null || (Object)(object)text5 == (Object)null) { Object.Destroy((Object)(object)val3); continue; } ((TMP_Text)text5).text = I18n.Text("owned.ui.recover"); ConfigureButtonText(text5, 10f, Mathf.Max(18f, ((TMP_Text)text5).fontSize)); LayoutElement obj2 = val3.GetComponent() ?? val3.AddComponent(); obj2.preferredWidth = 120f; obj2.preferredHeight = 56f; int objectId = ownedItemStateBroadcast.ObjectId; ((UnityEvent)button.onClick).AddListener((UnityAction)delegate { RecoverSingle(objectId); }); } if (!flag) { ((TMP_Text)AddText(GetText(_buttonTemplate), _rows, "Empty", 20f, 44f, (TextAlignmentOptions)514)).text = I18n.Text("owned.ui.empty"); } } private static TextMeshProUGUI AddText(TextMeshProUGUI template, Transform parent, string name, float size, float height, TextAlignmentOptions alignment) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = Object.Instantiate(template, parent, false); ((Object)((Component)val).gameObject).name = name; ((Component)val).gameObject.SetActive(true); DisableForeignComponents(((Component)val).gameObject); ((TMP_Text)val).fontSize = size; ((TMP_Text)val).alignment = alignment; ((Graphic)val).raycastTarget = false; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)1; (((Component)val).GetComponent() ?? ((Component)val).gameObject.AddComponent()).preferredHeight = height; return val; } private static GameObject MakeButton(GameObject template, Transform parent, string name) { GameObject obj = Object.Instantiate(template, parent, false); ((Object)obj).name = name; obj.SetActive(true); UseButton(obj); TextMeshProUGUI text = GetText(obj); if ((Object)(object)text != (Object)null) { ((TMP_Text)text).text = string.Empty; } return obj; } private static void ConfigureButtonText(TextMeshProUGUI text, float minSize, float maxSize) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)text == (Object)null)) { RectTransform rectTransform = ((TMP_Text)text).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = new Vector2(4f, 2f); rectTransform.offsetMax = new Vector2(-4f, -2f); ((TMP_Text)text).alignment = (TextAlignmentOptions)514; ((TMP_Text)text).verticalAlignment = (VerticalAlignmentOptions)512; ((TMP_Text)text).enableAutoSizing = true; ((TMP_Text)text).fontSizeMin = minSize; ((TMP_Text)text).fontSizeMax = maxSize; ((TMP_Text)text).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)text).overflowMode = (TextOverflowModes)0; ((TMP_Text)text).characterSpacing = 0f; ((Graphic)text).raycastTarget = false; } } private static Button UseButton(GameObject buttonObject) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Button val = (((Object)(object)buttonObject == (Object)null) ? null : buttonObject.GetComponent