Decompiled source of Better How To Fish v1.1.7
BepInEx/plugins/GiantFish/GiantFish.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using FishNet; using FishNet.Broadcast; using FishNet.Connection; using FishNet.Managing; using FishNet.Object; using FishNet.Object.Synchronizing; using FishNet.Serializing; using FishNet.Transporting; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("GiantFish")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.7.0")] [assembly: AssemblyInformationalVersion("1.1.7+d903d85356ebf0aefcde6d03d1ad4fd1229e60c1")] [assembly: AssemblyProduct("GiantFish")] [assembly: AssemblyTitle("GiantFish")] [assembly: AssemblyVersion("1.1.7.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace GiantFishMod { internal static class CatchNotification { private static GameObject _currentCard; private static RenderTexture _currentTexture; private static readonly FieldInfo InventoryCameraField = AccessTools.Field(typeof(PlayerInventory), "_inventoryCamera"); private static readonly FieldInfo ItemSlotsField = AccessTools.Field(typeof(PlayerInventory), "_itemSlots"); private static readonly FieldInfo SlotFilterField = AccessTools.Field(typeof(InventorySlot), "_filter"); private static readonly FieldInfo SlotRendererField = AccessTools.Field(typeof(InventorySlot), "_renderer"); private static readonly FieldInfo SlotImageField = AccessTools.Field(typeof(InventorySlot), "_itemImage"); public static void Show(MonoBehaviour runner, Creature creature, string catcherName) { Cleanup(); Transform fXCanvasTrans = PlayerUI.FXCanvasTrans; if (!((Object)(object)fXCanvasTrans == (Object)null)) { _currentCard = BuildCard(fXCanvasTrans, creature, catcherName); runner.StartCoroutine(AnimateCard(_currentCard)); } } public static bool HandleResizeInput() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_currentCard == (Object)null || !_currentCard.activeInHierarchy || Keyboard.current == null) { return false; } if (((ButtonControl)Keyboard.current.minusKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.numpadMinusKey).wasPressedThisFrame) { Plugin.AdjustCatchCardScale(-0.1f); _currentCard.transform.localScale = Vector3.one * Plugin.CatchCardScale; return true; } if (((ButtonControl)Keyboard.current.equalsKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.numpadPlusKey).wasPressedThisFrame) { Plugin.AdjustCatchCardScale(0.1f); _currentCard.transform.localScale = Vector3.one * Plugin.CatchCardScale; return true; } return false; } private static GameObject BuildCard(Transform parent, Creature creature, string catcherName) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0288: 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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("GiantFishCatchCard", new Type[4] { typeof(RectTransform), typeof(CanvasGroup), typeof(Image), typeof(Outline) }); val.transform.SetParent(parent, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0.5f, 1f); val2.anchorMax = new Vector2(0.5f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.anchoredPosition = new Vector2(0f, -28f); val2.sizeDelta = new Vector2(460f, 148f); ((Graphic)val.GetComponent<Image>()).color = new Color(0.04f, 0.025f, 0.075f, 0.9f); Outline component = val.GetComponent<Outline>(); ((Shadow)component).effectColor = new Color(1f, 1f, 1f, 0.3f); ((Shadow)component).effectDistance = new Vector2(1f, -1f); AddPanel(val.transform, "TopAccent", new Vector2(0f, 0f), new Vector2(460f, 4f), new Color(1f, 1f, 1f, 0.72f)); AddPanel(val.transform, "PreviewPanel", new Vector2(-166f, -20f), new Vector2(112f, 108f), new Color(0.045f, 0.105f, 0.14f, 0.94f), out var panelTransform); AddText(val.transform, "CaptureLabel", "NEW CATCH", new Vector2(42f, -14f), new Vector2(180f, 20f), 11f, (FontStyles)0, new Color(0.82f, 0.82f, 0.86f), (TextAlignmentOptions)513); AddText(val.transform, "Size", $"×{FishSizeRuntime.GetDisplaySize(creature):0.00}", new Vector2(42f, -33f), new Vector2(272f, 36f), 29f, (FontStyles)1, new Color(0.74f, 0.2f, 1f), (TextAlignmentOptions)513); AddText(val.transform, "Catcher", "CAUGHT BY · " + catcherName, new Vector2(42f, -72f), new Vector2(272f, 22f), 14f, (FontStyles)1, Color.white, (TextAlignmentOptions)513); AddPanel(val.transform, "Divider", new Vector2(42f, -99f), new Vector2(272f, 1f), new Color(1f, 1f, 1f, 0.22f), out var _); Player catcherForCreature = RodUpgradeSystem.GetCatcherForCreature(creature); int num = (((Object)(object)creature != (Object)null) ? RodSaleBonusRuntime.ApplyForPlayer(((Item)creature).TotalWorth, catcherForCreature ?? Player.LocalPlayer) : 0); AddText(val.transform, "SaleValue", $"SALE VALUE · ${num:N0}", new Vector2(42f, -108f), new Vector2(272f, 22f), 14f, (FontStyles)1, new Color(0.96f, 0.76f, 0.28f), (TextAlignmentOptions)513); int level = RodUpgradeSystem.GetLevel(catcherForCreature); AddText(val.transform, "RodBonuses", $"ROD {level} · LUCK {RodUpgradeSystem.GetLuck(catcherForCreature)} · " + $"REEL +{level * 5}% · SALE +{RodUpgradeSystem.GetSaleBonus(catcherForCreature)}%", new Vector2(42f, -130f), new Vector2(272f, 16f), 9.5f, (FontStyles)1, new Color(0.76f, 0.76f, 0.8f), (TextAlignmentOptions)513); AddText(val.transform, "ResizeLabel", "SIZE - / +", new Vector2(116f, -11f), new Vector2(90f, 24f), 10f, (FontStyles)1, Color.white, (TextAlignmentOptions)514); AddButton(val.transform, "CatchCardSmaller", "-", new Vector2(165f, -9f), new Vector2(30f, 27f), delegate { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Plugin.AdjustCatchCardScale(-0.1f); if ((Object)(object)_currentCard != (Object)null) { _currentCard.transform.localScale = Vector3.one * Plugin.CatchCardScale; } }); AddButton(val.transform, "CatchCardLarger", "+", new Vector2(201f, -9f), new Vector2(30f, 27f), delegate { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Plugin.AdjustCatchCardScale(0.1f); if ((Object)(object)_currentCard != (Object)null) { _currentCard.transform.localScale = Vector3.one * Plugin.CatchCardScale; } }); GameObject val3 = new GameObject("FishPreview", new Type[2] { typeof(RectTransform), typeof(RawImage) }); val3.transform.SetParent(panelTransform, false); RectTransform val4 = (RectTransform)val3.transform; val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = new Vector2(6f, 6f); val4.offsetMax = new Vector2(-6f, -6f); _currentTexture = BuildFishPreview(creature, out var previewUv); RawImage component2 = val3.GetComponent<RawImage>(); component2.texture = (Texture)(object)_currentTexture; component2.uvRect = previewUv; val.transform.localScale = Vector3.zero; return val; } private static GameObject AddPanel(Transform parent, string objectName, Vector2 position, Vector2 size, Color color, out Transform panelTransform) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(objectName, new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(parent, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0.5f, 1f); val2.anchorMax = new Vector2(0.5f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.anchoredPosition = position; val2.sizeDelta = size; Image component = val.GetComponent<Image>(); ((Graphic)component).color = color; ((Graphic)component).raycastTarget = false; panelTransform = val.transform; return val; } private static GameObject AddPanel(Transform parent, string objectName, Vector2 position, Vector2 size, Color color) { //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) Transform panelTransform; return AddPanel(parent, objectName, position, size, color, out panelTransform); } private static void AddText(Transform parent, string objectName, string value, Vector2 position, Vector2 size, float fontSize, FontStyles style, Color color, TextAlignmentOptions alignment = (TextAlignmentOptions)514) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val; if ((Object)(object)PlayerUI.CanvasTextPrefab != (Object)null) { val = Object.Instantiate<TextMeshProUGUI>(PlayerUI.CanvasTextPrefab, parent); ((Object)((Component)val).gameObject).name = objectName; } else { GameObject val2 = new GameObject(objectName, new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val2.transform.SetParent(parent, false); val = val2.GetComponent<TextMeshProUGUI>(); } RectTransform rectTransform = ((TMP_Text)val).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 1f); rectTransform.anchorMax = new Vector2(0.5f, 1f); rectTransform.pivot = new Vector2(0.5f, 1f); rectTransform.anchoredPosition = position; rectTransform.sizeDelta = size; ((TMP_Text)val).text = value; ((TMP_Text)val).fontSize = fontSize; ((TMP_Text)val).enableAutoSizing = true; ((TMP_Text)val).fontSizeMax = fontSize; ((TMP_Text)val).fontSizeMin = fontSize * 0.8f; ((TMP_Text)val).overflowMode = (TextOverflowModes)1; ((TMP_Text)val).fontStyle = style; ((Graphic)val).color = color; ((TMP_Text)val).alignment = alignment; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)0; ((Graphic)val).raycastTarget = false; } private static void AddButton(Transform parent, string objectName, string label, Vector2 position, Vector2 size, Action action) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0118: 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_0125: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(objectName, new Type[3] { typeof(RectTransform), typeof(Image), typeof(Button) }); val.transform.SetParent(parent, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0.5f, 1f); val2.anchorMax = new Vector2(0.5f, 1f); val2.pivot = new Vector2(0.5f, 1f); val2.anchoredPosition = position; val2.sizeDelta = size; Image component = val.GetComponent<Image>(); ((Graphic)component).color = new Color(0.48f, 0.18f, 0.72f, 1f); ((Graphic)component).raycastTarget = true; Button component2 = val.GetComponent<Button>(); ((Selectable)component2).targetGraphic = (Graphic)(object)component; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)component2).navigation = navigation; ((UnityEvent)component2.onClick).AddListener((UnityAction)delegate { action(); }); AddText(val.transform, "Label", label, Vector2.zero, size, 14f, (FontStyles)1, Color.white, (TextAlignmentOptions)514); } private static RenderTexture BuildFishPreview(Creature creature, out Rect previewUv) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0242: 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_026a: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) previewUv = new Rect(0f, 0f, 1f, 1f); Player localPlayer = Player.LocalPlayer; if ((Object)(object)localPlayer == (Object)null || (Object)(object)localPlayer.Inventory == (Object)null) { Plugin.Instance?.LogPreviewWarning("Local inventory was unavailable for the catch preview."); return null; } PlayerInventory inventory = localPlayer.Inventory; Camera val = (Camera)InventoryCameraField.GetValue(inventory); List<InventorySlot> list = (List<InventorySlot>)ItemSlotsField.GetValue(inventory); if ((Object)(object)val == (Object)null || list == null) { Plugin.Instance?.LogPreviewWarning("Inventory camera or slots were unavailable for the catch preview."); return null; } InventorySlot val2 = null; MeshFilter val3 = null; Renderer val4 = null; RawImage val5 = null; foreach (InventorySlot item in list) { if (!((Object)(object)item == (Object)null)) { MeshFilter val6 = (MeshFilter)SlotFilterField.GetValue(item); Renderer val7 = (Renderer)SlotRendererField.GetValue(item); RawImage val8 = (RawImage)SlotImageField.GetValue(item); if ((Object)(object)val6 != (Object)null && (Object)(object)val7 != (Object)null && (Object)(object)val8 != (Object)null) { val2 = item; val3 = val6; val4 = val7; val5 = val8; break; } } } RenderTexture targetTexture = val.targetTexture; Mesh val9 = ((creature.IsDrip && (Object)(object)((Item)creature).DripMesh != (Object)null) ? ((Item)creature).DripMesh : ((Item)creature).Mesh); if ((Object)(object)val2 == (Object)null || (Object)(object)targetTexture == (Object)null || (Object)(object)val9 == (Object)null) { Plugin.Instance?.LogPreviewWarning("Inventory preview resources were incomplete for " + ((Item)creature).GetName() + "."); return null; } previewUv = val5.uvRect; RenderTexture val10 = new RenderTexture(((Texture)targetTexture).width, ((Texture)targetTexture).height, targetTexture.depth, targetTexture.format) { name = "GiantFishCatchPreview", antiAliasing = Mathf.Max(1, targetTexture.antiAliasing) }; val10.Create(); Mesh sharedMesh = val3.sharedMesh; Vector3 localPosition = ((Component)val3).transform.localPosition; Quaternion localRotation = ((Component)val3).transform.localRotation; Vector3 localScale = ((Component)val3).transform.localScale; bool enabled = val4.enabled; bool fog = RenderSettings.fog; try { val3.sharedMesh = val9; ((Component)val3).transform.localPosition = ((Item)creature).InventoryMeshPos; ((Component)val3).transform.localEulerAngles = ((Item)creature).InventoryMeshRot; ((Component)val3).transform.localScale = Vector3.one * ((Item)creature).InventoryMeshScale; val4.enabled = true; RenderSettings.fog = false; val.targetTexture = val10; val.Render(); return val10; } finally { val.targetTexture = targetTexture; RenderSettings.fog = fog; val4.enabled = enabled; val3.sharedMesh = sharedMesh; ((Component)val3).transform.localPosition = localPosition; ((Component)val3).transform.localRotation = localRotation; ((Component)val3).transform.localScale = localScale; } } private static IEnumerator AnimateCard(GameObject card) { CanvasGroup group = card.GetComponent<CanvasGroup>(); float elapsed = 0f; while (elapsed < 0.28f && (Object)(object)card != (Object)null) { elapsed += Time.unscaledDeltaTime; float num = Mathf.Clamp01(elapsed / 0.28f); float num2 = 1f - Mathf.Pow(1f - num, 3f); card.transform.localScale = Vector3.one * (num2 * Plugin.CatchCardScale); yield return null; } yield return (object)new WaitForSecondsRealtime(4.5f); elapsed = 0f; while (elapsed < 0.6f && (Object)(object)card != (Object)null) { elapsed += Time.unscaledDeltaTime; group.alpha = 1f - Mathf.Clamp01(elapsed / 0.6f); yield return null; } if ((Object)(object)card == (Object)(object)_currentCard) { Cleanup(); } } private static void Cleanup() { if ((Object)(object)_currentCard != (Object)null) { Object.Destroy((Object)(object)_currentCard); } if ((Object)(object)_currentTexture != (Object)null) { _currentTexture.Release(); Object.Destroy((Object)(object)_currentTexture); } _currentCard = null; _currentTexture = null; } } internal static class CreatureHealthBarSystem { private static float _nextScan; public static void Tick() { if (!Plugin.CreatureHealthBarsEnabled) { if (Time.unscaledTime >= _nextScan) { _nextScan = Time.unscaledTime + 1.5f; Shutdown(); } } else if (!(Time.unscaledTime < _nextScan) && !((Object)(object)Player.LocalPlayer == (Object)null)) { _nextScan = Time.unscaledTime + 1.5f; Creature[] array = Object.FindObjectsByType<Creature>(); for (int i = 0; i < array.Length; i++) { Attach(array[i]); } } } public static void Attach(Creature creature) { if (Plugin.CreatureHealthBarsEnabled && !((Object)(object)creature == (Object)null) && !(creature is Bird) && !(((object)creature).GetType().Name == "Albatross") && !((Object)(object)((Component)creature).GetComponent<CreatureHealthBar>() != (Object)null)) { ((Component)creature).gameObject.AddComponent<CreatureHealthBar>(); } } public static void Shutdown() { CreatureHealthBar[] array = Object.FindObjectsByType<CreatureHealthBar>(); foreach (CreatureHealthBar creatureHealthBar in array) { if ((Object)(object)creatureHealthBar != (Object)null) { Object.Destroy((Object)(object)creatureHealthBar); } } } } internal sealed class CreatureHealthBar : MonoBehaviour { private Creature _creature; private GameObject _root; private Image _fill; private RectTransform _fillRect; private TextMeshProUGUI _numbers; private Renderer[] _renderers; private float _nextRendererRefresh; private Bounds _bounds; private float _displayedRatio = 1f; private void Awake() { _creature = ((Component)this).GetComponent<Creature>(); _renderers = ((Component)this).GetComponentsInChildren<Renderer>(true); } private void LateUpdate() { //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.CreatureHealthBarsEnabled) { if ((Object)(object)_root != (Object)null) { _root.SetActive(false); } } else { if ((Object)(object)_creature == (Object)null || ((Object)(object)_root == (Object)null && !TryCreate())) { return; } Player localPlayer = Player.LocalPlayer; Camera val = (((Object)(object)localPlayer != (Object)null) ? localPlayer.CurCam : Camera.main); if ((Object)(object)val == (Object)null) { _root.SetActive(false); return; } int num = Mathf.Max(1, _creature.MaxHp); int num2 = Mathf.Clamp(_creature.Hp, 0, num); float num3 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position); bool flag = num2 < num || (Object)(object)((Item)_creature).AttachedRod != (Object)null; bool flag2 = _renderers == null || _renderers.Length == 0 || _renderers.Any((Renderer renderer) => (Object)(object)renderer != (Object)null && renderer.isVisible); bool flag3 = num2 > 0 && flag2 && num3 <= (flag ? 28f : 12f); _root.SetActive(flag3); if (flag3) { if (Time.unscaledTime >= _nextRendererRefresh) { _renderers = ((Component)this).GetComponentsInChildren<Renderer>(true); _nextRendererRefresh = Time.unscaledTime + 1.5f; } RefreshBounds(); float num4 = Mathf.Clamp(((Bounds)(ref _bounds)).extents.y + 0.28f, 0.45f, 4.5f); _root.transform.position = new Vector3(((Bounds)(ref _bounds)).center.x, ((Bounds)(ref _bounds)).max.y + num4 * 0.18f, ((Bounds)(ref _bounds)).center.z); _root.transform.rotation = ((Component)val).transform.rotation; float num5 = Mathf.Clamp(num3 * 0.00032f, 0.0024f, 0.0075f); _root.transform.localScale = Vector3.one * num5; float num6 = (float)num2 / (float)num; _displayedRatio = Mathf.MoveTowards(_displayedRatio, num6, Time.unscaledDeltaTime * 2.5f); _fillRect.anchorMax = new Vector2(_displayedRatio, 1f); _fillRect.offsetMax = new Vector2((_displayedRatio > 0.025f) ? (-4f) : 0f, -4f); ((Behaviour)_fill).enabled = _displayedRatio > 0.001f; ((Graphic)_fill).color = ((num6 > 0.55f) ? new Color(0.22f, 0.86f, 0.42f, 0.96f) : ((num6 > 0.25f) ? new Color(1f, 0.7f, 0.16f, 0.96f) : new Color(0.95f, 0.2f, 0.18f, 0.96f))); ((TMP_Text)_numbers).text = num2 + " / " + num; } } } private bool TryCreate() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_006f: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI canvasTextPrefab; try { canvasTextPrefab = PlayerUI.CanvasTextPrefab; } catch { return false; } if ((Object)(object)canvasTextPrefab == (Object)null) { return false; } _root = new GameObject("GiantFishHealthBar", new Type[2] { typeof(RectTransform), typeof(Canvas) }); Canvas component = _root.GetComponent<Canvas>(); component.renderMode = (RenderMode)2; component.sortingOrder = 45; ((RectTransform)_root.transform).sizeDelta = new Vector2(230f, 42f); SetRect(CreateImage(_root.transform, "Shadow", new Color(0f, 0f, 0f, 0.72f)).GetComponent<RectTransform>(), Vector2.zero, Vector2.one, new Vector2(-5f, -5f), new Vector2(5f, 5f)); GameObject obj2 = CreateImage(_root.transform, "Track", new Color(0.035f, 0.055f, 0.065f, 0.96f)); SetRect(obj2.GetComponent<RectTransform>(), Vector2.zero, Vector2.one, new Vector2(2f, 2f), new Vector2(-2f, -2f)); GameObject val = CreateImage(obj2.transform, "Fill", Color.green); _fillRect = val.GetComponent<RectTransform>(); SetRect(_fillRect, Vector2.zero, Vector2.one, new Vector2(4f, 4f), new Vector2(-4f, -4f)); _fill = val.GetComponent<Image>(); _fill.type = (Type)0; _numbers = Object.Instantiate<TextMeshProUGUI>(canvasTextPrefab, _root.transform); ((Object)((Component)_numbers).gameObject).name = "HealthNumbers"; SetRect(((TMP_Text)_numbers).rectTransform, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero); ((TMP_Text)_numbers).fontSize = 24f; ((TMP_Text)_numbers).fontStyle = (FontStyles)1; ((TMP_Text)_numbers).alignment = (TextAlignmentOptions)514; ((Graphic)_numbers).color = Color.white; ((TMP_Text)_numbers).textWrappingMode = (TextWrappingModes)0; ((Graphic)_numbers).raycastTarget = false; return true; } private void RefreshBounds() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Renderer val = ((IEnumerable<Renderer>)_renderers).FirstOrDefault((Func<Renderer, bool>)((Renderer renderer) => (Object)(object)renderer != (Object)null && renderer.enabled)); if ((Object)(object)val == (Object)null) { _bounds = new Bounds(((Component)this).transform.position, Vector3.one); return; } _bounds = val.bounds; Renderer[] renderers = _renderers; foreach (Renderer val2 in renderers) { if ((Object)(object)val2 != (Object)null && val2.enabled) { ((Bounds)(ref _bounds)).Encapsulate(val2.bounds); } } } private static GameObject CreateImage(Transform parent, string name, Color color) { //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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(parent, false); ((Graphic)val.GetComponent<Image>()).color = color; ((Graphic)val.GetComponent<Image>()).raycastTarget = false; return val; } private static void SetRect(RectTransform rect, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; rect.offsetMin = offsetMin; rect.offsetMax = offsetMax; } private void OnDestroy() { if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } } } internal static class FishSizeRuntime { private static readonly FieldInfo WeightField = AccessTools.Field(typeof(Item), "_syncedRandomWeight"); private static readonly FieldInfo HpField = AccessTools.Field(typeof(Creature), "_hp"); private static readonly FieldInfo SkipWeightField = AccessTools.Field(typeof(Creature), "_skipRandomizedWeight"); public static float GetSize(Creature creature) { if (!IsScalableCatch(creature)) { return 1f; } return Mathf.Clamp(((SyncVar<float>)WeightField.GetValue(creature)).Value, 1f, 25f); } public static bool IsScalableCatch(Creature creature) { if ((Object)(object)creature == (Object)null || creature is Bird || ((object)creature).GetType().Name == "Albatross") { return false; } FishScaleState component = ((Component)creature).GetComponent<FishScaleState>(); if (!IsBoss(creature) && !((Object)(object)((Item)creature).AttachedRod != (Object)null)) { if ((Object)(object)component != (Object)null) { if (!component.WasHooked) { return component.LoadedFromSave; } return true; } return false; } return true; } public static bool IsBoss(Creature creature) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if ((Object)(object)creature != (Object)null) { return (int)creature.BossType > 0; } return false; } public static float GetDisplaySize(Creature creature) { if ((Object)(object)creature == (Object)null) { return 1f; } return Mathf.Clamp(GetRawWeight(creature), 1f, 25f); } public static float GetRawWeight(Creature creature) { return ((SyncVar<float>)WeightField.GetValue(creature)).Value; } public static void SetSize(Creature creature, float size) { size = Mathf.Clamp(size, 1f, 25f); ((SyncVar<float>)WeightField.GetValue(creature)).Value = size; } public static bool SkipsRandomWeight(Creature creature) { return (bool)SkipWeightField.GetValue(creature); } public static void RefillHealth(Creature creature) { SyncVar<int> val = (SyncVar<int>)HpField.GetValue(creature); if (val.Value > 0) { val.Value = creature.MaxHp; } } public static void MarkLoadedFromSave(Creature creature) { GetOrCreateState(creature).LoadedFromSave = true; } public static void RecordCatcher(Creature creature, FishingRod rod) { if (!((Object)(object)creature == (Object)null) && !((Object)(object)rod == (Object)null)) { FishScaleState orCreateState = GetOrCreateState(creature); orCreateState.WasHooked = true; orCreateState.CatcherRod = rod; Player val = (((Object)(object)((Item)rod).SyncedHolder != (Object)null) ? ((Item)rod).SyncedHolder : ((Item)rod).Holder); if ((Object)(object)val != (Object)null) { orCreateState.Catcher = val; orCreateState.CatcherName = val.SteamName; } if (InstanceFinder.IsServerStarted && !orCreateState.LuckRollApplied && !orCreateState.LoadedFromSave && !IsBoss(creature)) { SetSize(creature, SizeDistribution.Roll(((NetworkBehaviour)creature).ObjectId, RodUpgradeSystem.GetLuck(val))); orCreateState.LuckRollApplied = true; RefillHealth(creature); ApplyVisualScale(creature); Plugin.Instance?.LogLuckRoll(creature, val, RodUpgradeSystem.GetLuck(val)); } } } public static bool TryClaimBossInitialRefill(Creature creature) { if ((Object)(object)creature == (Object)null || !IsBoss(creature)) { return false; } FishScaleState orCreateState = GetOrCreateState(creature); if (orCreateState.BossHealthInitialized) { return false; } orCreateState.BossHealthInitialized = true; return true; } public static bool IsDead(Creature creature) { if ((Object)(object)creature == (Object)null) { return false; } return ((SyncVar<int>)HpField.GetValue(creature)).Value <= 0; } public static bool TryClaimLocalNotification(Creature creature, out string catcherName) { catcherName = string.Empty; if ((Object)(object)creature == (Object)null) { return false; } FishScaleState component = ((Component)creature).GetComponent<FishScaleState>(); if ((Object)(object)component == (Object)null || component.NotificationShown || (Object)(object)component.CatcherRod == (Object)null) { return false; } Player val = component.Catcher; if ((Object)(object)val == (Object)null) { val = (((Object)(object)((Item)component.CatcherRod).SyncedHolder != (Object)null) ? ((Item)component.CatcherRod).SyncedHolder : ((Item)component.CatcherRod).Holder); } Player localPlayer = Player.LocalPlayer; if (!((Object)(object)val != (Object)null) || ((!((Object)(object)localPlayer != (Object)null) || !((Object)(object)val == (Object)(object)localPlayer)) && !((NetworkBehaviour)val).Owner.IsLocalClient)) { return false; } component.NotificationShown = true; catcherName = ((!string.IsNullOrWhiteSpace(component.CatcherName)) ? component.CatcherName : (((Object)(object)val != (Object)null) ? val.SteamName : localPlayer.SteamName)); return true; } public static bool WasLoadedFromSave(Creature creature) { FishScaleState component = ((Component)creature).GetComponent<FishScaleState>(); if ((Object)(object)component != (Object)null) { return component.LoadedFromSave; } return false; } public static void ApplyVisualScale(Creature creature) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (IsScalableCatch(creature)) { FishScaleState orCreateState = GetOrCreateState(creature); Vector3 variantBaseScale = MoreFishCompatibility.GetVariantBaseScale(creature, orCreateState.OriginalScale); ((Component)creature).transform.localScale = variantBaseScale * GetSize(creature); } } private static FishScaleState GetOrCreateState(Creature creature) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) FishScaleState component = ((Component)creature).GetComponent<FishScaleState>(); if ((Object)(object)component != (Object)null) { return component; } component = ((Component)creature).gameObject.AddComponent<FishScaleState>(); component.OriginalScale = ((Component)creature).transform.localScale; return component; } public static int ScaledInt(int original, Creature creature) { double value = (double)original * (double)GetSize(creature); return (int)Math.Min(2147483647.0, Math.Max(1.0, Math.Round(value, MidpointRounding.AwayFromZero))); } } internal sealed class FishScaleState : MonoBehaviour { public Vector3 OriginalScale; public bool LoadedFromSave; public bool WasHooked; public FishingRod CatcherRod; public Player Catcher; public string CatcherName; public bool NotificationShown; public bool RankingSubmitted; public string RankingEntryId; public bool RankingAnnouncementSent; public bool LuckRollApplied; public bool BossHealthInitialized; private Creature _creature; private void Awake() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) _creature = ((Component)this).GetComponent<Creature>(); OriginalScale = ((Component)this).transform.localScale; } private void LateUpdate() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_creature == (Object)null) && FishSizeRuntime.IsScalableCatch(_creature)) { Vector3 val = MoreFishCompatibility.GetVariantBaseScale(_creature, OriginalScale) * FishSizeRuntime.GetSize(_creature); Vector3 val2 = ((Component)this).transform.localScale - val; if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f) { ((Component)this).transform.localScale = val; } } } } internal static class HudVisibility { private static readonly FieldInfo CurrentKillScoreField = AccessTools.Field(typeof(PlayerKillScore), "_curKillScore"); public static bool ShouldHideInteractionHud() { if (PauseManager.IsPaused) { return true; } PlayerKillScore val = (((Object)(object)Player.LocalPlayer != (Object)null) ? Player.LocalPlayer.KillScore : null); if ((Object)(object)val != (Object)null && CurrentKillScoreField != null) { return CurrentKillScoreField.GetValue(val) != null; } return false; } } internal static class InfiniteWeaponUpgrades { public const int MaximumIndex = 255; private const int TableLength = 256; private static readonly FieldInfo SharpnessTable = AccessTools.Field(typeof(Melee), "_sharpnessUpgrades"); private static readonly FieldInfo BulletTable = AccessTools.Field(typeof(Attachments), "_bulletUpgrades"); private static readonly FieldInfo SharpnessDamage = AccessTools.Field(typeof(SharpnessUpgrade), "_damage"); private static readonly FieldInfo SharpnessCost = AccessTools.Field(typeof(SharpnessUpgrade), "_cost"); private static readonly FieldInfo BulletDamage = AccessTools.Field(typeof(BulletUpgrade), "_damage"); private static readonly FieldInfo BulletCost = AccessTools.Field(typeof(BulletUpgrade), "_cost"); private static readonly FieldInfo MaximumSharpness = AccessTools.Field(typeof(SharpnessPurchasable), "_maxSharpnessUpgrade"); private static readonly FieldInfo MaximumBullets = AccessTools.Field(typeof(BulletPurchasable), "_maxBulletUpgrade"); private static bool _logged; public static void Ensure(Melee melee) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if ((Object)(object)melee == (Object)null || SharpnessTable == null) { return; } SharpnessUpgrade[] array = (SharpnessUpgrade[])SharpnessTable.GetValue(melee); if (array != null && array.Length != 0 && array.Length < 256) { int damage = array[^1].Damage; int cost = array[^1].Cost; int num = ((array.Length > 1) ? Math.Max(1, damage - array[^2].Damage) : Math.Max(1, damage / 4)); int step = ((array.Length > 1) ? Math.Max(10, cost - array[^2].Cost) : Math.Max(10, cost / 2)); SharpnessUpgrade[] array2 = (SharpnessUpgrade[])(object)new SharpnessUpgrade[256]; Array.Copy(array, array2, array.Length); for (int i = array.Length; i < array2.Length; i++) { long num2 = i - ((long)array.Length - 1L); SharpnessUpgrade val = new SharpnessUpgrade(); SharpnessDamage.SetValue(val, Saturate(damage + num * num2)); SharpnessCost.SetValue(val, ProgressiveCost(cost, step, num2)); array2[i] = val; } SharpnessTable.SetValue(melee, array2); LogOnce(); } } public static void Ensure(Attachments attachments) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if ((Object)(object)attachments == (Object)null || BulletTable == null) { return; } BulletUpgrade[] array = (BulletUpgrade[])BulletTable.GetValue(attachments); if (array != null && array.Length != 0 && array.Length < 256) { int damage = array[^1].Damage; int cost = array[^1].Cost; int num = ((array.Length > 1) ? Math.Max(1, damage - array[^2].Damage) : Math.Max(1, damage / 4)); int step = ((array.Length > 1) ? Math.Max(10, cost - array[^2].Cost) : Math.Max(10, cost / 2)); BulletUpgrade[] array2 = (BulletUpgrade[])(object)new BulletUpgrade[256]; Array.Copy(array, array2, array.Length); for (int i = array.Length; i < array2.Length; i++) { long num2 = i - ((long)array.Length - 1L); BulletUpgrade val = new BulletUpgrade(); BulletDamage.SetValue(val, Saturate(damage + num * num2)); BulletCost.SetValue(val, ProgressiveCost(cost, step, num2)); array2[i] = val; } BulletTable.SetValue(attachments, array2); LogOnce(); } } public static void Unlock(SharpnessPurchasable purchasable) { if ((Object)(object)purchasable != (Object)null && MaximumSharpness != null) { MaximumSharpness.SetValue(purchasable, byte.MaxValue); } } public static void Unlock(BulletPurchasable purchasable) { if ((Object)(object)purchasable != (Object)null && MaximumBullets != null) { MaximumBullets.SetValue(purchasable, byte.MaxValue); } } private static int ProgressiveCost(int lastCost, int step, long extra) { return Saturate(lastCost + step * extra * (extra + 1) / 2); } private static int Saturate(long value) { return (int)Math.Max(1L, Math.Min(2000000000L, value)); } private static void LogOnce() { if (!_logged) { _logged = true; Plugin.Instance?.LogInfiniteWeaponUpgrades(); } } } [HarmonyPatch] internal static class MeleeUpgradeTablePatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(Melee), "Awake", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Melee), "GetCurSharpness", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Melee), "GetNextSharpnessUpgrade", (Type[])null, (Type[])null); } private static void Prefix(Melee __instance) { InfiniteWeaponUpgrades.Ensure(__instance); } } [HarmonyPatch] internal static class BulletUpgradeTablePatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(Attachments), "Awake", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Attachments), "GetCurBulletUpgrade", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(Attachments), "GetNextBulletUpgrade", (Type[])null, (Type[])null); } private static void Prefix(Attachments __instance) { InfiniteWeaponUpgrades.Ensure(__instance); } } [HarmonyPatch] internal static class SharpnessWorkbenchLimitPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(SharpnessPurchasable), "Hover", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(SharpnessPurchasable), "OnStartHover", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(SharpnessPurchasable), "Interact", (Type[])null, (Type[])null); } private static void Prefix(SharpnessPurchasable __instance) { InfiniteWeaponUpgrades.Unlock(__instance); } } [HarmonyPatch] internal static class BulletWorkbenchLimitPatch { private static IEnumerable<MethodBase> TargetMethods() { yield return AccessTools.Method(typeof(BulletPurchasable), "Hover", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(BulletPurchasable), "OnStartHover", (Type[])null, (Type[])null); yield return AccessTools.Method(typeof(BulletPurchasable), "Interact", (Type[])null, (Type[])null); } private static void Prefix(BulletPurchasable __instance) { InfiniteWeaponUpgrades.Unlock(__instance); } } internal static class MoreFishCompatibility { public const string PluginGuid = "com.scarletttech.howtofish.morefish"; private static MethodInfo _morphOfMethod; private static FieldInfo _morphScaleField; private static Type _customSpeciesTagType; private static FieldInfo _customSpeciesBodyScaleField; private static bool _initialized; private static bool _active; private static bool _reflectionWarningLogged; public static bool IsActive => _active; public static void Initialize(Harmony harmony) { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown if (_initialized || harmony == null || !Chainloader.PluginInfos.ContainsKey("com.scarletttech.howtofish.morefish")) { return; } _initialized = true; Type type = AccessTools.TypeByName("MoreFish.MorphState"); Type type2 = AccessTools.TypeByName("MoreFish.Morph"); _customSpeciesTagType = AccessTools.TypeByName("MoreFish.CustomSpeciesTag"); if (type == null || type2 == null) { Plugin.Instance?.LogMoreFishCompatibility("MoreFish was detected, but its variant API was not found."); return; } _morphOfMethod = AccessTools.Method(type, "Of", new Type[1] { typeof(Item) }, (Type[])null); _morphScaleField = AccessTools.Field(type2, "Scale"); _customSpeciesBodyScaleField = ((_customSpeciesTagType != null) ? AccessTools.Field(_customSpeciesTagType, "BodyScale") : null); MethodInfo methodInfo = AccessTools.Method(type, "Apply", new Type[1] { typeof(Creature) }, (Type[])null); if (_morphOfMethod == null || _morphScaleField == null || methodInfo == null) { Plugin.Instance?.LogMoreFishCompatibility("MoreFish was detected, but its scaling hooks were not found."); return; } harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(MoreFishCompatibility), "AfterMoreFishApply", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _active = true; Plugin.Instance?.LogMoreFishCompatibility("MoreFish compatibility enabled: variants and custom species preserve Better sizes."); } public static Vector3 GetVariantBaseScale(Creature creature, Vector3 fallback) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!_active || (Object)(object)creature == (Object)null) { return fallback; } try { float num = 1f; object obj = _morphOfMethod.Invoke(null, new object[1] { creature }); if (obj != null) { num *= Convert.ToSingle(_morphScaleField.GetValue(obj)); } if (_customSpeciesTagType != null && _customSpeciesBodyScaleField != null) { Component component = ((Component)creature).GetComponent(_customSpeciesTagType); if ((Object)(object)component != (Object)null) { num *= Convert.ToSingle(_customSpeciesBodyScaleField.GetValue(component)); } } return Vector3.one * Mathf.Max(0.01f, num); } catch (Exception ex) { if (!_reflectionWarningLogged) { _reflectionWarningLogged = true; Plugin.Instance?.LogMoreFishCompatibility("Could not read a MoreFish variant scale; using the original scale safely. " + ex.Message); } return fallback; } } private static void AfterMoreFishApply(Creature __0) { if ((Object)(object)__0 != (Object)null && FishSizeRuntime.IsScalableCatch(__0)) { FishSizeRuntime.ApplyVisualScale(__0); } } } [HarmonyPatch(typeof(Creature), "OnStartServer")] internal static class CreatureStartServerPatch { private static void Prefix(Creature __instance, out byte __state) { __state = 0; if (!FishSizeRuntime.IsScalableCatch(__instance) || (FishSizeRuntime.SkipsRandomWeight(__instance) && !FishSizeRuntime.IsBoss(__instance))) { return; } if (FishSizeRuntime.IsBoss(__instance) && !FishSizeRuntime.WasLoadedFromSave(__instance)) { __state = 3; } else if (Math.Abs(FishSizeRuntime.GetRawWeight(__instance) - 1f) < 0.0001f) { if (FishSizeRuntime.WasLoadedFromSave(__instance)) { FishSizeRuntime.SetSize(__instance, 1.0001f); __state = 2; } else { __state = 1; } } } private static void Postfix(Creature __instance, byte __state) { if (!FishSizeRuntime.IsScalableCatch(__instance) || (FishSizeRuntime.SkipsRandomWeight(__instance) && !FishSizeRuntime.IsBoss(__instance))) { return; } switch (__state) { case 1: case 3: FishSizeRuntime.SetSize(__instance, SizeDistribution.Roll(((NetworkBehaviour)__instance).ObjectId, RodUpgradeSystem.GetLuckForCreature(__instance))); break; case 2: FishSizeRuntime.SetSize(__instance, 1f); break; default: if (FishSizeRuntime.GetRawWeight(__instance) < 1f) { FishSizeRuntime.SetSize(__instance, 1f); } break; } FishSizeRuntime.RefillHealth(__instance); if (FishSizeRuntime.IsBoss(__instance)) { Plugin.Instance?.ScheduleBossHealthRefill(__instance); } FishSizeRuntime.ApplyVisualScale(__instance); Plugin.Instance?.LogCatchSize(__instance); RankingManager.RecordCatch(__instance); } } [HarmonyPatch(typeof(Creature), "get_MaxHp")] internal static class CreatureMaxHpPatch { private static void Postfix(Creature __instance, ref int __result) { if (FishSizeRuntime.IsScalableCatch(__instance)) { __result = FishSizeRuntime.ScaledInt(__result, __instance); } } } [HarmonyPatch(typeof(Creature), "OnStartClient")] internal static class CreatureStartClientPatch { private static void Postfix(Creature __instance) { FishSizeRuntime.ApplyVisualScale(__instance); CreatureHealthBarSystem.Attach(__instance); } } [HarmonyPatch(typeof(Creature), "LoadFromSave")] internal static class CreatureLoadFromSavePatch { private static void Prefix(Creature __instance) { if ((Object)(object)__instance != (Object)null && !(__instance is Bird) && ((object)__instance).GetType().Name != "Albatross") { FishSizeRuntime.MarkLoadedFromSave(__instance); } } private static void Postfix(Creature __instance) { if (FishSizeRuntime.IsScalableCatch(__instance) && FishSizeRuntime.GetRawWeight(__instance) < 1f) { FishSizeRuntime.SetSize(__instance, 1f); } FishSizeRuntime.ApplyVisualScale(__instance); } } [HarmonyPatch(typeof(AttackingFish), "DamageOnCollision")] internal static class AttackingFishDamagePatch { private static readonly FieldInfo DamageField = AccessTools.Field(typeof(AttackingFish), "_onHitDamage"); private static void Prefix(AttackingFish __instance, out int __state) { __state = (int)DamageField.GetValue(__instance); DamageField.SetValue(__instance, FishSizeRuntime.ScaledInt(__state, (Creature)(object)__instance)); } private static Exception Finalizer(AttackingFish __instance, int __state, Exception __exception) { DamageField.SetValue(__instance, __state); return __exception; } } [HarmonyPatch(typeof(BowheadWhale), "DamageOnCollision")] internal static class BowheadWhaleSizeDamagePatch { private static readonly FieldInfo DamageField = AccessTools.Field(typeof(AttackingFish), "_onHitDamage"); private static void Prefix(BowheadWhale __instance, out int __state) { __state = (int)DamageField.GetValue(__instance); DamageField.SetValue(__instance, FishSizeRuntime.ScaledInt(__state, (Creature)(object)__instance)); } private static Exception Finalizer(BowheadWhale __instance, int __state, Exception __exception) { DamageField.SetValue(__instance, __state); return __exception; } } [HarmonyPatch(typeof(Pufferfish), "OnCollisionEnter")] internal static class PufferfishSizeDamagePatch { private static readonly FieldInfo DamageField = AccessTools.Field(typeof(Pufferfish), "_onHitDamage"); private static void Prefix(Pufferfish __instance, out int __state) { __state = (int)DamageField.GetValue(__instance); DamageField.SetValue(__instance, FishSizeRuntime.ScaledInt(__state, (Creature)(object)__instance)); } private static Exception Finalizer(Pufferfish __instance, int __state, Exception __exception) { DamageField.SetValue(__instance, __state); return __exception; } } [HarmonyPatch(typeof(Item), "OnAttachedRodChange")] internal static class CatchOwnershipPatch { private static void Postfix(Item __instance, FishingRod next) { if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.Creature != (Object)null && (Object)(object)next != (Object)null) { FishSizeRuntime.RecordCatcher(__instance.Creature, next); FishSizeRuntime.ApplyVisualScale(__instance.Creature); } } } [HarmonyPatch(typeof(Creature), "OnDeath")] internal static class CatchDeathNotificationPatch { private static void Postfix(Creature __instance) { if (!RankedCatchAnnouncement.WasAnnounced(((NetworkBehaviour)__instance).ObjectId) && (Object)(object)Plugin.Instance != (Object)null && FishSizeRuntime.TryClaimLocalNotification(__instance, out var catcherName)) { Plugin.Instance.ShowCatchCard(__instance, catcherName); } } } [HarmonyPatch(typeof(Creature), "ServerChangeHp")] internal static class CatchRankingPatch { private static void Postfix(Creature __instance) { try { if (FishSizeRuntime.IsDead(__instance)) { RankingManager.RecordCatch(__instance); RankingManager.AnnounceRankedDeath(__instance); } } catch (Exception exception) { Plugin.Instance?.LogRankingError("death hook", exception); } } } [HarmonyPatch(typeof(MoneyManager), "SellItem")] internal static class RodSaleContextPatch { private static void Prefix(object[] __args) { RodSaleBonusRuntime.Begin(__args?.OfType<Player>().FirstOrDefault() ?? Player.LocalPlayer); } private static Exception Finalizer(Exception __exception) { RodSaleBonusRuntime.End(); return __exception; } } [HarmonyPatch(typeof(Item), "get_TotalWorth")] internal static class RodSaleWorthPatch { private static void Postfix(ref int __result) { __result = RodSaleBonusRuntime.Apply(__result); } } [HarmonyPatch(typeof(PlayerUI), "ShowInspectInfo", new Type[] { typeof(Item), typeof(string) })] internal static class CreatureInspectSizePatch { private static void Prefix(Item item, ref string description) { Creature val = (Creature)(((object)((item is Creature) ? item : null)) ?? ((object)((item != null) ? item.Creature : null))); if (!((Object)(object)val == (Object)null) && !(val is Bird) && !(((object)val).GetType().Name == "Albatross")) { string text = FishSizeRuntime.GetDisplaySize(val).ToString("0.00"); string text2 = (Plugin.VanillaInspectSizeStyle ? ("Size: " + text + "x") : ("<color=#61F0FF>SIZE: " + text + "x</color>")); description = (string.IsNullOrEmpty(description) ? text2 : (description + "\n" + text2)); } } } [HarmonyPatch(typeof(WeaponUI), "UpdateInspectedItemText")] internal static class WeaponInspectSaleValuePatch { private static readonly FieldInfo InspectedItemField = AccessTools.Field(typeof(WeaponUI), "_inspectedItem"); private static void Prefix(WeaponUI __instance) { object? obj = InspectedItemField?.GetValue(__instance); Item val = (Item)((obj is Item) ? obj : null); Creature val2 = (Creature)(((object)((val is Creature) ? val : null)) ?? ((object)((val != null) ? val.Creature : null))); RodSaleBonusRuntime.Begin(((Object)(object)val2 != (Object)null && !(val2 is Bird) && ((object)val2).GetType().Name != "Albatross") ? Player.LocalPlayer : null); } private static Exception Finalizer(Exception __exception) { RodSaleBonusRuntime.End(); return __exception; } } internal static class KillScoreSizeContext { [ThreadStatic] private static float _size; public static void Begin(Creature creature) { _size = (FishSizeRuntime.IsScalableCatch(creature) ? FishSizeRuntime.GetDisplaySize(creature) : 0f); } public static float ConsumeSize() { return _size; } public static void End() { _size = 0f; } } [HarmonyPatch(typeof(Creature), "LocalHit")] internal static class CreatureKillScoreContextPatch { private static void Prefix(Creature __instance) { KillScoreSizeContext.Begin(__instance); } private static Exception Finalizer(Exception __exception) { KillScoreSizeContext.End(); return __exception; } } [HarmonyPatch(typeof(PlayerKillScore), "AddKillScore")] internal static class VanillaKillScoreDetailsPatch { private static void Prefix(ref string killed, ref int worth) { float num = KillScoreSizeContext.ConsumeSize(); if (num > 0f) { killed += $" {num:0.00}x"; } worth = RodSaleBonusRuntime.ApplyForPlayer(worth, Player.LocalPlayer); } } [BepInPlugin("com.reysher.howtofish.giantfish", "Better How to Fish", "1.1.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.reysher.howtofish.giantfish"; public const string PluginName = "Better How to Fish"; public const string PluginVersion = "1.1.7"; private Harmony _harmony; private static ConfigEntry<bool> _creatureHealthBarsEnabled; private static ConfigEntry<float> _rankingHudScale; private static ConfigEntry<float> _catchCardScale; private static ConfigEntry<float> _workbenchHudScale; private static ConfigEntry<bool> _vanillaInspectSizeStyle; internal static Plugin Instance { get; private set; } internal static bool CreatureHealthBarsEnabled => _creatureHealthBarsEnabled?.Value ?? true; internal static float RankingHudScale => Mathf.Clamp(_rankingHudScale?.Value ?? 1f, 0.5f, 2f); internal static float CatchCardScale => Mathf.Clamp(_catchCardScale?.Value ?? 1f, 0.5f, 2f); internal static float WorkbenchHudScale => Mathf.Clamp(_workbenchHudScale?.Value ?? 1f, 0.5f, 2f); internal static bool VanillaInspectSizeStyle => _vanillaInspectSizeStyle?.Value ?? true; internal static void AdjustRankingHudScale(float amount) { if (_rankingHudScale != null) { _rankingHudScale.Value = Mathf.Round(Mathf.Clamp(_rankingHudScale.Value + amount, 0.5f, 2f) * 10f) / 10f; } } internal static void AdjustCatchCardScale(float amount) { if (_catchCardScale != null) { _catchCardScale.Value = Mathf.Round(Mathf.Clamp(_catchCardScale.Value + amount, 0.5f, 2f) * 10f) / 10f; } } internal static void ToggleCreatureHealthBars() { if (_creatureHealthBarsEnabled != null) { _creatureHealthBarsEnabled.Value = !_creatureHealthBarsEnabled.Value; } } internal static void AdjustWorkbenchHudScale(float amount) { if (_workbenchHudScale != null) { _workbenchHudScale.Value = Mathf.Round(Mathf.Clamp(_workbenchHudScale.Value + amount, 0.5f, 2f) * 10f) / 10f; } } private void Awake() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown Instance = this; _creatureHealthBarsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowCreatureHealthBars", true, "Show synchronized health bars above creatures."); _rankingHudScale = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "RankingHudScale", 1f, "Scale of the Biggest Catches HUD. Valid range: 0.5 to 2.0."); _catchCardScale = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "CatchCardScale", 1f, "Scale of the New Catch card. Valid range: 0.5 to 2.0."); _workbenchHudScale = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "WorkbenchHudScale", 1f, "Scale of the rod-upgrade workbench prompt. Valid range: 0.5 to 2.0."); _vanillaInspectSizeStyle = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "VanillaInspectSizeStyle", true, "Display creature size like a normal vanilla inspection statistic."); RankingManager.Initialize(((BaseUnityPlugin)this).Config); RodUpgradeSystem.Initialize(((BaseUnityPlugin)this).Config); _harmony = new Harmony("com.reysher.howtofish.giantfish"); _harmony.PatchAll(); MoreFishCompatibility.Initialize(_harmony); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Better How to Fish 1.1.7 loaded."); } private void Update() { RankingManager.Tick(); RodUpgradeSystem.Tick(); CreatureHealthBarSystem.Tick(); if (!CatchNotification.HandleResizeInput() && !RodUpgradeHud.HandleResizeInput()) { RankingHud.HandleResizeInput(); } } private void OnDestroy() { RankingManager.Shutdown(); RodUpgradeSystem.Shutdown(); CreatureHealthBarSystem.Shutdown(); Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } Instance = null; } internal void ShowCatchCard(Creature creature, string catcherName) { CatchNotification.Show((MonoBehaviour)(object)this, creature, catcherName); } internal void ShowGlobalRankedCatch(Creature creature, string catcherName, float size, bool isLocalCatcher) { CatchNotification.Show((MonoBehaviour)(object)this, creature, catcherName); } internal void LogPreviewWarning(string message) { ((BaseUnityPlugin)this).Logger.LogWarning((object)message); } internal void LogCatchSize(Creature creature) { ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Scaled catch {((Item)creature).GetName()} to x{FishSizeRuntime.GetDisplaySize(creature):0.00}."); } internal void LogRankingError(string operation, Exception exception) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Ranking {operation} failed safely: {exception}"); } internal void LogRankingHudCreated() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Ranking HUD created on its independent overlay canvas."); } internal void LogLuckRoll(Creature creature, Player catcher, int luck) { ((BaseUnityPlugin)this).Logger.LogInfo((object)(string.Format("Applied catcher luck {0} for {1}: ", luck, ((catcher != null) ? catcher.SteamName : null) ?? "Angler") + $"{((Item)creature).GetName()} rolled x{FishSizeRuntime.GetDisplaySize(creature):0.00}.")); } internal void LogUpgradePurchase(Player player, int cost, int newLevel) { ((BaseUnityPlugin)this).Logger.LogInfo((object)(string.Format("Server charged ${0} to {1} ", cost, ((player != null) ? player.SteamName : null) ?? "Angler") + $"and applied rod upgrade level {newLevel}.")); } internal void LogPersonalWalletCompatibility() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"NoSharedMoney detected: rod upgrades will use each player's personal wallet."); } internal void LogMoreFishCompatibility(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } internal void LogUpgradeError(string operation, Exception exception) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Rod upgrade failed while {operation}: {exception}"); } internal void LogInfiniteWeaponUpgrades() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Expanded melee and bullet upgrade tables to 255 persistent levels."); } internal void LogUpgradeRejection(string reason) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Rod upgrade rejected: " + reason)); } internal void ScheduleBossHealthRefill(Creature creature) { ((MonoBehaviour)this).StartCoroutine(RefillBossHealthAfterInitialization(creature)); } private static IEnumerator RefillBossHealthAfterInitialization(Creature creature) { yield return null; yield return null; if ((Object)(object)creature != (Object)null && FishSizeRuntime.TryClaimBossInitialRefill(creature)) { FishSizeRuntime.RefillHealth(creature); } } } internal static class RankedCatchAnnouncement { private static readonly Dictionary<int, float> AnnouncedObjects = new Dictionary<int, float>(); public static void Receive(RankedCatchBroadcast message) { if (!((Object)(object)Plugin.Instance == (Object)null) && !WasAnnounced(message.ObjectId)) { AnnouncedObjects[message.ObjectId] = Time.unscaledTime + 12f; ((MonoBehaviour)Plugin.Instance).StartCoroutine(ShowWhenAvailable(message)); } } public static bool WasAnnounced(int objectId) { if (!AnnouncedObjects.TryGetValue(objectId, out var value)) { return false; } if (Time.unscaledTime <= value) { return true; } AnnouncedObjects.Remove(objectId); return false; } private static IEnumerator ShowWhenAvailable(RankedCatchBroadcast message) { float deadline = Time.unscaledTime + 2f; Creature creature = null; while ((Object)(object)creature == (Object)null && Time.unscaledTime < deadline) { Creature[] array = Object.FindObjectsByType<Creature>(); foreach (Creature val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).ObjectId == message.ObjectId) { creature = val; break; } } if ((Object)(object)creature == (Object)null) { yield return null; } } if (!((Object)(object)creature == (Object)null) && !((Object)(object)Plugin.Instance == (Object)null)) { Player localPlayer = Player.LocalPlayer; bool isLocalCatcher = (Object)(object)localPlayer != (Object)null && message.CatcherId != 0L && localPlayer.SteamID == message.CatcherId; Plugin.Instance.ShowGlobalRankedCatch(creature, string.IsNullOrWhiteSpace(message.CatcherName) ? "Angler" : message.CatcherName, message.Size, isLocalCatcher); } } } internal static class RankingHud { private static readonly Color Cyan = new Color(0.18f, 0.82f, 0.88f, 1f); private static readonly Color Muted = new Color(0.66f, 0.75f, 0.8f, 1f); private static readonly Color[] MedalColors = (Color[])(object)new Color[3] { new Color(1f, 0.72f, 0.22f, 1f), new Color(0.73f, 0.8f, 0.86f, 1f), new Color(0.8f, 0.48f, 0.27f, 1f) }; private static GameObject _root; private static GameObject _canvasRoot; private static readonly TextMeshProUGUI[] RowNames = (TextMeshProUGUI[])(object)new TextMeshProUGUI[3]; private static readonly TextMeshProUGUI[] RowSizes = (TextMeshProUGUI[])(object)new TextMeshProUGUI[3]; private static string _lastSignature = string.Empty; public static void EnsureVisible(IReadOnlyList<RankingEntry> entries) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) if (MainMenuManager.IsInMenu) { Destroy(); return; } TextMeshProUGUI canvasTextPrefab; try { canvasTextPrefab = PlayerUI.CanvasTextPrefab; } catch { return; } if ((Object)(object)Player.LocalPlayer == (Object)null || (Object)(object)canvasTextPrefab == (Object)null) { return; } if ((Object)(object)_root == (Object)null || (Object)(object)_canvasRoot == (Object)null) { Destroy(); Build(); } _root.transform.localScale = Vector3.one * Plugin.RankingHudScale; string text = BuildSignature(entries); if (text == _lastSignature) { return; } for (int i = 0; i < 3; i++) { bool flag = entries != null && i < entries.Count; string text2 = (flag ? (entries[i].PlayerName ?? "Angler") : "No catches"); if (text2.Length > 18) { text2 = text2.Substring(0, 17) + "…"; } ((TMP_Text)RowNames[i]).text = text2; ((Graphic)RowNames[i]).color = (Color)(flag ? Color.white : new Color(Muted.r, Muted.g, Muted.b, 0.65f)); ((TMP_Text)RowSizes[i]).text = (flag ? $"×{entries[i].Size:0.00}" : "—"); ((Graphic)RowSizes[i]).color = (Color)(flag ? Cyan : new Color(Muted.r, Muted.g, Muted.b, 0.65f)); } _lastSignature = text; } public static bool HandleResizeInput() { //IL_0053: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_root == (Object)null || MainMenuManager.IsInMenu || Keyboard.current == null) { return false; } if (((ButtonControl)Keyboard.current.minusKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.numpadMinusKey).wasPressedThisFrame) { Plugin.AdjustRankingHudScale(-0.1f); _root.transform.localScale = Vector3.one * Plugin.RankingHudScale; return true; } if (((ButtonControl)Keyboard.current.equalsKey).wasPressedThisFrame || ((ButtonControl)Keyboard.current.numpadPlusKey).wasPressedThisFrame) { Plugin.AdjustRankingHudScale(0.1f); _root.transform.localScale = Vector3.one * Plugin.RankingHudScale; return true; } return false; } public static void Destroy() { if ((Object)(object)_canvasRoot != (Object)null) { Object.Destroy((Object)(object)_canvasRoot); } _root = null; _canvasRoot = null; for (int i = 0; i < 3; i++) { RowNames[i] = null; RowSizes[i] = null; } _lastSignature = string.Empty; } private static void Build() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04f5: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) _canvasRoot = new GameObject("GiantFishRankingCanvas", new Type[4] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); Canvas component = _canvasRoot.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 5000; CanvasScaler component2 = _canvasRoot.GetComponent<CanvasScaler>(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.screenMatchMode = (ScreenMatchMode)0; component2.matchWidthOrHeight = 0.5f; _root = new GameObject("GiantFishRankingHud", new Type[3] { typeof(RectTransform), typeof(Image), typeof(Outline) }); _root.transform.SetParent(_canvasRoot.transform, false); RectTransform val = (RectTransform)_root.transform; val.anchorMin = new Vector2(1f, 1f); val.anchorMax = new Vector2(1f, 1f); val.pivot = new Vector2(1f, 1f); val.anchoredPosition = new Vector2(-28f, -28f); val.sizeDelta = new Vector2(390f, 218f); Image component3 = _root.GetComponent<Image>(); ((Graphic)component3).color = new Color(0.018f, 0.048f, 0.075f, 0.94f); ((Graphic)component3).raycastTarget = false; Outline component4 = _root.GetComponent<Outline>(); ((Shadow)component4).effectColor = new Color(Cyan.r, Cyan.g, Cyan.b, 0.72f); ((Shadow)component4).effectDistance = new Vector2(2f, -2f); AddPanel(_root.transform, "TopAccent", new Vector2(0f, 0f), new Vector2(390f, 5f), Cyan); AddPanel(_root.transform, "TitleMarker", new Vector2(18f, -18f), new Vector2(4f, 39f), Cyan); AddText(_root.transform, "Title", "BIGGEST CATCHES", new Vector2(34f, -13f), new Vector2(225f, 27f), 19f, (FontStyles)1, Color.white, (TextAlignmentOptions)513); AddText(_root.transform, "Subtitle", "SESSION RECORDS", new Vector2(34f, -39f), new Vector2(330f, 20f), 11f, (FontStyles)1, Muted, (TextAlignmentOptions)513); AddButton(_root.transform, "RankingSmaller", "-", new Vector2(270f, -13f), new Vector2(27f, 27f), delegate { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Plugin.AdjustRankingHudScale(-0.1f); if ((Object)(object)_root != (Object)null) { _root.transform.localScale = Vector3.one * Plugin.RankingHudScale; } }); AddButton(_root.transform, "RankingLarger", "+", new Vector2(301f, -13f), new Vector2(27f, 27f), delegate { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Plugin.AdjustRankingHudScale(0.1f); if ((Object)(object)_root != (Object)null) { _root.transform.localScale = Vector3.one * Plugin.RankingHudScale; } }); AddButton(_root.transform, "HealthBarsToggle", "HP", new Vector2(332f, -13f), new Vector2(40f, 27f), delegate { Plugin.ToggleCreatureHealthBars(); }); for (int num = 0; num < 3; num++) { float num2 = -72f - (float)num * 46f; Color color = ((num == 0) ? new Color(0.07f, 0.16f, 0.2f, 0.92f) : new Color(0.045f, 0.105f, 0.14f, 0.86f)); Transform transform = AddPanel(_root.transform, $"RankRow{num + 1}", new Vector2(18f, num2), new Vector2(354f, 38f), color).transform; AddPanel(transform, "RankBadge", new Vector2(0f, 0f), new Vector2(38f, 38f), new Color(MedalColors[num].r, MedalColors[num].g, MedalColors[num].b, 0.2f)); AddText(transform, "Rank", (num + 1).ToString(), new Vector2(0f, -3f), new Vector2(38f, 31f), 18f, (FontStyles)1, MedalColors[num], (TextAlignmentOptions)514); RowNames[num] = AddText(transform, "Player", "No catches", new Vector2(50f, -3f), new Vector2(210f, 31f), 17f, (FontStyles)0, Color.white, (TextAlignmentOptions)513); RowSizes[num] = AddText(transform, "Size", "—", new Vector2(266f, -3f), new Vector2(72f, 31f), 18f, (FontStyles)1, Cyan, (TextAlignmentOptions)516); } Plugin.Instance?.LogRankingHudCreated(); } private static GameObject AddPanel(Transform parent, string name, Vector2 position, Vector2 size, Color color) { //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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(parent, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(0f, 1f); val2.pivot = new Vector2(0f, 1f); val2.anchoredPosition = position; val2.sizeDelta = size; Image component = val.GetComponent<Image>(); ((Graphic)component).color = color; ((Graphic)component).raycastTarget = false; return val; } private static TextMeshProUGUI AddText(Transform parent, string name, string value, Vector2 position, Vector2 size, float fontSize, FontStyles style, Color color, TextAlignmentOptions alignment) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(PlayerUI.CanvasTextPrefab, parent); ((Object)((Component)obj).gameObject).name = name; RectTransform rectTransform = ((TMP_Text)obj).rectTransform; rectTransform.anchorMin = new Vector2(0f, 1f); rectTransform.anchorMax = new Vector2(0f, 1f); rectTransform.pivot = new Vector2(0f, 1f); rectTransform.anchoredPosition = position; rectTransform.sizeDelta = size; ((TMP_Text)obj).text = value; ((TMP_Text)obj).fontSize = fontSize; ((TMP_Text)obj).fontStyle = style; ((Graphic)obj).color = color; ((TMP_Text)obj).alignment = alignment; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((Graphic)obj).raycastTarget = false; return obj; } private static void AddButton(Transform parent, string name, string label, Vector2 position, Vector2 size, Action action) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown //IL_0118: 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_0125: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(Image), typeof(Button) }); val.transform.SetParent(parent, false); RectTransform val2 = (RectTransform)val.transform; val2.anchorMin = new Vector2(0f, 1f); val2.anchorMax = new Vector2(0f, 1f); val2.pivot = new Vector2(0f, 1f); val2.anchoredPosition = position; val2.sizeDelta = size; Image component = val.GetComponent<Image>(); ((Graphic)component).color = new Color(0.07f, 0.2f, 0.25f, 0.96f); ((Graphic)component).raycastTarget = true; Button component2 = val.GetComponent<Button>(); ((Selectable)component2).targetGraphic = (Graphic)(object)component; Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)component2).navigation = navigation; ((UnityEvent)component2.onClick).AddListener((UnityAction)delegate { action(); }); AddText(val.transform, "Label", label, Vector2.zero, size, 14f, (FontStyles)1, Cyan, (TextAlignmentOptions)514); } private static string BuildSignature(IReadOnlyList<RankingEntry> entries) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 3; i++) { if (entries != null && i < entries.Count) { stringBuilder.Append(entries[i].PlayerName).Append('|').Append(entries[i].Size.ToString("0.00")); } stringBuilder.Append(';'); } return stringBuilder.ToString(); } } internal struct RankingBroadcast : IBroadcast { public string Payload; } internal struct RankedCatchBroadcast : IBroadcast { public int ObjectId; public float Size; public ulong CatcherId; public string CatcherName; } internal sealed class RankingEntry { public string World; public string PlayerId; public string PlayerName; public float Size; } internal static class RankingManager { private static readonly List<RankingEntry> AllEntries = new List<RankingEntry>(); private static readonly List<RankingEntry> CurrentEntries = new List<RankingEntry>(); private static ConfigEntry<string> _savedData; private static NetworkManager _registeredNetworkManager; private static string _currentWorld = string.Empty; private static bool _serializersReady; private static bool _initialized; private static bool _wasServerStarted; private static float _nextBroadcastTime; public static void Initialize(ConfigFile config) { if (!_initialized) { _savedData = config.Bind<string>("Ranking", "Records", string.Empty, "Persistent Giant Fish records. This value is managed by the mod."); LoadSavedData(); SetupSerializers(); _initialized = true; } } public static void Tick() { EnsureNetworkRegistration(); bool isServerStarted = InstanceFinder.IsServerStarted; if (isServerStarted) { SelectCurrentWorld(); if (!_wasServerStarted || Time.unscaledTime >= _nextBroadcastTime) { BroadcastCurrent(); _nextBroadcastTime = Time.unscaledTime + 4f; } } _wasServerStarted = isServerStarted; RankingHud.EnsureVisible(CurrentEntries); } public static void Shutdown() { if ((Object)(object)_registeredNetworkManager != (Object)null) { try { _registeredNetworkManager.ClientManager.UnregisterBroadcast<RankingBroadcast>((Action<RankingBroadcast, Channel>)OnRankingBroadcast); _registeredNetworkManager.ClientManager.UnregisterBroadcast<RankedCatchBroadcast>((Action<RankedCatchBroadcast, Channel>)OnRankedCatchBroadcast); } catch { } } _registeredNetworkManager = null; _wasServerStarted = false; RankingHud.Destroy(); } public static void RecordCatch(Creature creature) { try { RecordCatchInternal(creature); } catch (Exception exception) { Plugin.Instance?.LogRankingError("record", exception); } } private static void RecordCatchInternal(Creature creature) { if (!_initialized || !InstanceFinder.IsServerStarted || (Object)(object)creature == (Object)null) { return; } FishScaleState component = ((Component)creature).GetComponent<FishScaleState>(); if ((Object)(object)component == (Object)null || !component.WasHooked || component.RankingSubmitted) { return; } component.RankingSubmitted = true; Player val = component.Catcher; if ((Object)(object)val == (Object)null && (Object)(object)component.CatcherRod != (Object)null) { val = (((Object)(object)((Item)component.CatcherRod).SyncedHolder != (Object)null) ? ((Item)component.CatcherRod).SyncedHolder : ((Item)component.CatcherRod).Holder); } if ((Object)(object)val == (Object)null) { return; } SelectCurrentWorld(); float displaySize = FishSizeRuntime.GetDisplaySize(creature); string text = ((val.SteamID != 0L) ? val.SteamID.ToString(CultureInfo.InvariantCulture) : ("connection-" + ((NetworkBehaviour)val).OwnerId.ToString(CultureInfo.InvariantCulture))); string playerName = (string.IsNullOrWhiteSpace(val.SteamName) ? "Angler" : val.SteamName.Trim()); RankingEntry rankingEntry = new RankingEntry(); rankingEntry.World = _currentWorld; rankingEntry.PlayerId = text + "-" + DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture) + "-" + ((NetworkBehaviour)creature).ObjectId.ToString(CultureInfo.InvariantCulture); rankingEntry.PlayerName = playerName; rankingEntry.Size = displaySize; RankingEntry rankingEntry2 = rankingEntry; AllEntries.Add(rankingEntry2); component.RankingEntryId = rankingEntry2.PlayerId; foreach (RankingEntry item in (from e in AllEntries where e != null && e.World == _currentWorld orderby e.Size des