using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using FishNet; using FishNet.Broadcast; using FishNet.Connection; using FishNet.Managing; using FishNet.Managing.Timing; using FishNet.Object; using FishNet.Object.Synchronizing; using FishNet.Serializing; using FishNet.Transporting; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using SpongeMods.SpongeTweaks.Abilities; using SpongeMods.SpongeTweaks.Cosmetic; using SpongeMods.SpongeTweaks.Gameplay; using SpongeMods.SpongeTweaks.Hud; using SpongeMods.SpongeTweaks.Inventory; using SpongeMods.SpongeTweaks.Multiplayer; using SpongeMods.SpongeTweaks.Persistence; using SpongeMods.SpongeTweaks.Progression; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; 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: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("FishNet.Runtime")] [assembly: AssemblyCompany("Merged community mod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("All-in-one How to Fish mod merging fourteen community mods.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+dbcdd0857e7f8d44cac85cf2506353d8ac92c331")] [assembly: AssemblyProduct("SpongeTweaks")] [assembly: AssemblyTitle("SpongeMods.SpongeTweaks")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SpongeMods.SpongeTweaks { [BepInPlugin("spongemods.howtofish.spongetweaks", "SpongeMods - SpongeTweaks", "1.0.0")] [BepInProcess("How to Fish.exe")] public sealed class CompendiumPlugin : BaseUnityPlugin { public const string PluginGuid = "spongemods.howtofish.spongetweaks"; public const string PluginName = "SpongeMods - SpongeTweaks"; public const string PluginVersion = "1.0.0"; private Harmony _harmony; private FileSystemWatcher _configWatcher; private readonly List _modules = new List(); private readonly List _updating = new List(); private readonly List _lateUpdating = new List(); internal static CompendiumPlugin Instance { get; private set; } internal static ManualLogSource Log { get; private set; } internal static ConfigFile Configuration { get; private set; } private void Awake() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; Configuration = ((BaseUnityPlugin)this).Config; bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet; ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; _harmony = new Harmony("spongemods.howtofish.spongetweaks"); SpongeRegister(new GiantCatchModule()); SpongeRegister(new BossHealthModule()); SpongeRegister(new BossTimerModule()); SpongeRegister(new CreatureHealthModule()); SpongeRegister(new AmmoCounterModule()); SpongeRegister(new SwimmingModule()); SpongeRegister(new ShotgunJumpModule()); SpongeRegister(new FairSlotsModule()); SpongeRegister(new LaserSightModule()); SpongeRegister(new LobbySizeModule()); SpongeRegister(new StackingModule()); SpongeRegister(new DroppedItemModule()); SpongeRegister(new SaveBackupModule()); SpongeRegister(new VoidBeamModule()); foreach (IFeatureModule module in _modules) { if (!module.Enabled) { Log.LogInfo((object)(module.DisplayName + " is disabled by config.")); continue; } try { module.Initialise(_harmony); if (module.WantsUpdate) { _updating.Add(module); } if (module.WantsLateUpdate) { _lateUpdating.Add(module); } } catch (Exception ex) { Log.LogError((object)(module.DisplayName + " failed to start and was skipped: " + ex)); } } Log.LogInfo((object)string.Format("{0} {1} loaded {2} live and {3} total features.", "SpongeMods - SpongeTweaks", "1.0.0", _updating.Count + _lateUpdating.Count, _modules.Count)); if (saveOnConfigSet) { ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); } SetupConfigWatcher(); } private void SetupConfigWatcher() { try { string fileName = Path.GetFileName(((BaseUnityPlugin)this).Config.ConfigFilePath); string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath); if (!string.IsNullOrEmpty(directoryName) && Directory.Exists(directoryName)) { _configWatcher = new FileSystemWatcher(directoryName, fileName); _configWatcher.Changed += OnConfigFileChanged; _configWatcher.Created += OnConfigFileChanged; _configWatcher.Renamed += OnConfigFileChanged; _configWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; _configWatcher.IncludeSubdirectories = false; _configWatcher.EnableRaisingEvents = true; } } catch (Exception ex) { Log.LogWarning((object)("Could not watch the config file for changes: " + ex.Message)); } } private void OnConfigFileChanged(object sender, FileSystemEventArgs eventArgs) { if (!File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath)) { return; } try { ((BaseUnityPlugin)this).Config.Reload(); Log.LogInfo((object)"Config reloaded from disk."); } catch (Exception ex) { Log.LogError((object)("There was an issue reloading the config file: " + ex.Message)); Log.LogError((object)"Please check your config entries for spelling and format."); } } private void SpongeRegister(IFeatureModule module) { module.BindConfiguration(((BaseUnityPlugin)this).Config); _modules.Add(module); } private void Update() { for (int i = 0; i < _updating.Count; i++) { try { _updating[i].Tick(); } catch (Exception ex) { Log.LogError((object)(_updating[i].DisplayName + " threw during Update: " + ex)); } } } private void LateUpdate() { for (int i = 0; i < _lateUpdating.Count; i++) { try { _lateUpdating[i].LateTick(); } catch (Exception ex) { Log.LogError((object)(_lateUpdating[i].DisplayName + " threw during LateUpdate: " + ex)); } } } private void OnDestroy() { if (_configWatcher != null) { _configWatcher.EnableRaisingEvents = false; _configWatcher.Changed -= OnConfigFileChanged; _configWatcher.Created -= OnConfigFileChanged; _configWatcher.Renamed -= OnConfigFileChanged; _configWatcher.Dispose(); _configWatcher = null; } foreach (IFeatureModule module in _modules) { try { module.Shutdown(); } catch (Exception ex) { Log.LogWarning((object)(module.DisplayName + " threw while shutting down: " + ex)); } } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } ((BaseUnityPlugin)this).Config.Save(); Instance = null; } internal static Coroutine Run(IEnumerator routine) { if (!((Object)(object)Instance == (Object)null)) { return ((MonoBehaviour)Instance).StartCoroutine(routine); } return null; } } internal interface IFeatureModule { string DisplayName { get; } bool Enabled { get; } bool WantsUpdate { get; } bool WantsLateUpdate { get; } void BindConfiguration(ConfigFile config); void Initialise(Harmony harmony); void Tick(); void LateTick(); void Shutdown(); } internal abstract class FeatureModule : IFeatureModule { protected ConfigEntry ModuleEnabled; public abstract string DisplayName { get; } public virtual bool Enabled { get { if (ModuleEnabled != null) { return ModuleEnabled.Value; } return true; } } public virtual bool WantsUpdate => false; public virtual bool WantsLateUpdate => false; public abstract void BindConfiguration(ConfigFile config); public virtual void Initialise(Harmony harmony) { } public virtual void Tick() { } public virtual void LateTick() { } public virtual void Shutdown() { } } internal static class UiSupport { internal static readonly Vector2 TopLeft = new Vector2(0f, 1f); internal static readonly Vector2 TopCentre = new Vector2(0.5f, 1f); public static Color ResolveColour(string configured, Color fallback) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0052: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(configured) || string.IsNullOrWhiteSpace(configured)) { return fallback; } if (string.Equals(configured.Trim(), "Default", StringComparison.OrdinalIgnoreCase)) { return fallback; } string text = configured.Trim(); if (!text.StartsWith("#", StringComparison.Ordinal)) { text = "#" + text; } Color result = default(Color); if (!ColorUtility.TryParseHtmlString(text, ref result)) { return fallback; } return result; } public static string RenderHp(int value) { return value.ToString("N0", CultureInfo.InvariantCulture); } public static bool GameplayHudVisible() { if (MainMenuManager.IsInMenu || PauseManager.IsPaused) { return false; } try { return !PlayerUI.UIDisabled; } catch { return true; } } public static bool BossHudVisible() { if (MainMenuManager.IsInMenu || PauseManager.IsPaused) { return false; } try { return PlayerUI.BossCanvasActive; } catch { return false; } } public static TextMeshProUGUI FindFontDonor() { TextMeshProUGUI[] array = Resources.FindObjectsOfTypeAll(); foreach (TextMeshProUGUI val in array) { if ((Object)(object)val != (Object)null && ((TMP_Text)val).text != null && ((TMP_Text)val).text.IndexOf("Version", StringComparison.OrdinalIgnoreCase) >= 0) { return val; } } return null; } public static RectTransform MakeRect(string name, Transform parent) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent, false); return val.GetComponent(); } public static void SpongeStretchToParent(RectTransform rect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) rect.anchorMin = Vector2.zero; rect.anchorMax = Vector2.one; rect.pivot = new Vector2(0.5f, 0.5f); rect.offsetMin = Vector2.zero; rect.offsetMax = Vector2.zero; ((Transform)rect).localScale = Vector3.one; ((Transform)rect).localRotation = Quaternion.identity; } public static GameObject CreateOverlayCanvas(string name, int sortingOrder) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_007a: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[3] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler) }); Canvas component = val.GetComponent(); component.renderMode = (RenderMode)0; component.sortingOrder = sortingOrder; CanvasScaler component2 = val.GetComponent(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.screenMatchMode = (ScreenMatchMode)0; component2.matchWidthOrHeight = 0.5f; return val; } internal static GameObject InsertPanel(Transform parent, string name, Vector2 anchor, Vector2 position, Vector2 size, Color colour) { //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_003f: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0053: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_0076: 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 = anchor; val2.anchorMax = anchor; val2.pivot = anchor; val2.anchoredPosition = position; val2.sizeDelta = size; Image component = val.GetComponent(); ((Graphic)component).color = colour; ((Graphic)component).raycastTarget = false; return val; } internal static TextMeshProUGUI InsertText(Transform parent, string name, string value, Vector2 anchor, Vector2 position, Vector2 size, float fontSize, FontStyles style, Color colour, TextAlignmentOptions alignment) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = null; try { val = PlayerUI.CanvasTextPrefab; } catch { } TextMeshProUGUI val2; if ((Object)(object)val != (Object)null) { val2 = Object.Instantiate(val, parent); ((Object)((Component)val2).gameObject).name = name; } else { GameObject val3 = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val3.transform.SetParent(parent, false); val2 = val3.GetComponent(); } RectTransform rectTransform = ((TMP_Text)val2).rectTransform; rectTransform.anchorMin = anchor; rectTransform.anchorMax = anchor; rectTransform.pivot = anchor; rectTransform.anchoredPosition = position; rectTransform.sizeDelta = size; ((TMP_Text)val2).text = value; ((TMP_Text)val2).fontSize = fontSize; ((TMP_Text)val2).fontStyle = style; ((Graphic)val2).color = colour; ((TMP_Text)val2).alignment = alignment; ((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0; ((Graphic)val2).raycastTarget = false; return val2; } internal static T Ensure(GameObject target) where T : Component { return target.GetComponent() ?? target.AddComponent(); } internal static Color WithAlpha(Color colour, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) colour.a = alpha; return colour; } internal static void SetLayoutWidth(GameObject target, float width, bool flexible) { LayoutElement obj = UiSupport.Ensure(target); obj.minWidth = width; obj.preferredWidth = width; obj.flexibleWidth = (flexible ? 1f : 0f); } internal static void StripLocalisation(GameObject target) { MonoBehaviour[] componentsInChildren = target.GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if ((Object)(object)val != (Object)null && ((object)val).GetType().Name.IndexOf("Localize", StringComparison.OrdinalIgnoreCase) >= 0) { Object.Destroy((Object)(object)val); } } } } } namespace SpongeMods.SpongeTweaks.Progression { internal static class LeaderboardHud { private const int Rows = 3; 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[] MedalColours = (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 RequireVisible(IReadOnlyList entries) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) 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) { Teardown(); Build(); } string text = ComposeSignature(entries); if (text == _lastSignature) { return; } for (int i = 0; i < 3; i++) { bool flag = entries != null && i < entries.Count; string text2 = (flag ? (entries[i].DisplayName ?? "Angler") : "No catch"); 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 void Teardown() { 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0074: 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_0084: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_017f: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: 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_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_039b: 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_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: 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_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0424: 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) _canvasRoot = UiSupport.CreateOverlayCanvas("SpongeMods_RankingCanvas", 5000); _root = new GameObject("SpongeMods_RankingHud", 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 component = _root.GetComponent(); ((Graphic)component).color = new Color(0.018f, 0.048f, 0.075f, 0.94f); ((Graphic)component).raycastTarget = false; Outline component2 = _root.GetComponent(); ((Shadow)component2).effectColor = new Color(Cyan.r, Cyan.g, Cyan.b, 0.72f); ((Shadow)component2).effectDistance = new Vector2(2f, -2f); UiSupport.InsertPanel(_root.transform, "TopAccent", UiSupport.TopLeft, Vector2.zero, new Vector2(390f, 5f), Cyan); UiSupport.InsertPanel(_root.transform, "TitleMarker", UiSupport.TopLeft, new Vector2(18f, -18f), new Vector2(4f, 39f), Cyan); UiSupport.InsertText(_root.transform, "Title", "BIGGEST CATCHES", UiSupport.TopLeft, new Vector2(34f, -13f), new Vector2(330f, 27f), 19f, (FontStyles)1, Color.white, (TextAlignmentOptions)513); UiSupport.InsertText(_root.transform, "Subtitle", "RECORDS FOR THIS SAVE", UiSupport.TopLeft, new Vector2(34f, -39f), new Vector2(330f, 20f), 11f, (FontStyles)1, Muted, (TextAlignmentOptions)513); for (int i = 0; i < 3; i++) { float num = -72f - (float)i * 46f; Color colour = ((i == 0) ? new Color(0.07f, 0.16f, 0.2f, 0.92f) : new Color(0.045f, 0.105f, 0.14f, 0.86f)); Transform transform = UiSupport.InsertPanel(_root.transform, $"RankRow{i + 1}", UiSupport.TopLeft, new Vector2(18f, num), new Vector2(354f, 38f), colour).transform; UiSupport.InsertPanel(transform, "RankBadge", UiSupport.TopLeft, Vector2.zero, new Vector2(38f, 38f), new Color(MedalColours[i].r, MedalColours[i].g, MedalColours[i].b, 0.2f)); UiSupport.InsertText(transform, "Rank", (i + 1).ToString(), UiSupport.TopLeft, new Vector2(0f, -3f), new Vector2(38f, 31f), 18f, (FontStyles)1, MedalColours[i], (TextAlignmentOptions)514); RowNames[i] = UiSupport.InsertText(transform, "Player", "No catch", UiSupport.TopLeft, new Vector2(50f, -3f), new Vector2(210f, 31f), 17f, (FontStyles)0, Color.white, (TextAlignmentOptions)513); RowSizes[i] = UiSupport.InsertText(transform, "Size", "—", UiSupport.TopLeft, new Vector2(266f, -3f), new Vector2(72f, 31f), 18f, (FontStyles)1, Cyan, (TextAlignmentOptions)516); } GiantCatchModule.Instance?.SpongeLogRankingHudCreated(); } private static string ComposeSignature(IReadOnlyList entries) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < 3; i++) { if (entries != null && i < entries.Count) { stringBuilder.Append(entries[i].DisplayName).Append('|').Append(entries[i].Size.ToString("0.00")); } stringBuilder.Append(';'); } return stringBuilder.ToString(); } } internal static class CatchToast { 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 = ComposeCard(fXCanvasTrans, creature, catcherName); runner.StartCoroutine(TweenCard(_currentCard)); } } private static GameObject ComposeCard(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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: 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_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SpongeMods_CatchCard", 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()).color = new Color(0.018f, 0.048f, 0.075f, 0.96f); Outline component = val.GetComponent(); ((Shadow)component).effectColor = new Color(0.18f, 0.82f, 0.88f, 0.72f); ((Shadow)component).effectDistance = new Vector2(2f, -2f); UiSupport.InsertPanel(val.transform, "TopAccent", UiSupport.TopCentre, Vector2.zero, new Vector2(460f, 4f), new Color(0.18f, 0.82f, 0.88f, 1f)); Transform transform = UiSupport.InsertPanel(val.transform, "PreviewPanel", UiSupport.TopCentre, new Vector2(-166f, -20f), new Vector2(112f, 108f), new Color(0.045f, 0.105f, 0.14f, 0.94f)).transform; UiSupport.InsertText(val.transform, "CaptureLabel", "NEW CATCH", UiSupport.TopCentre, new Vector2(42f, -14f), new Vector2(272f, 20f), 11f, (FontStyles)1, new Color(0.62f, 0.75f, 0.81f), (TextAlignmentOptions)513); UiSupport.InsertText(val.transform, "Size", $"×{FishSizeService.ObtainDisplaySize(creature):0.00}", UiSupport.TopCentre, new Vector2(42f, -33f), new Vector2(272f, 36f), 29f, (FontStyles)1, new Color(0.38f, 0.94f, 1f), (TextAlignmentOptions)513); UiSupport.InsertText(val.transform, "Catcher", "CAUGHT BY - " + catcherName, UiSupport.TopCentre, new Vector2(42f, -72f), new Vector2(272f, 22f), 14f, (FontStyles)1, Color.white, (TextAlignmentOptions)513); UiSupport.InsertPanel(val.transform, "Divider", UiSupport.TopCentre, new Vector2(42f, -99f), new Vector2(272f, 1f), new Color(0.18f, 0.82f, 0.88f, 0.35f)); int num = (((Object)(object)creature != (Object)null) ? ((Item)creature).TotalWorth : 0); UiSupport.InsertText(val.transform, "SaleValue", $"SALE VALUE - ${num:N0}", UiSupport.TopCentre, new Vector2(42f, -108f), new Vector2(272f, 22f), 14f, (FontStyles)1, new Color(0.96f, 0.76f, 0.28f), (TextAlignmentOptions)513); Player player = RodTierService.ObtainCatcherForCreature(creature); int num2 = RodTierService.ObtainLevel(player); UiSupport.InsertText(val.transform, "RodBonuses", $"ROD {num2} - LUCK {RodTierService.ObtainLuck(player)} - " + $"REEL +{num2 * 5}% - SALE +{RodTierService.ObtainSaleBonus(player)}%", UiSupport.TopCentre, new Vector2(42f, -130f), new Vector2(272f, 16f), 9.5f, (FontStyles)1, new Color(0.62f, 0.75f, 0.81f), (TextAlignmentOptions)513); GameObject val3 = new GameObject("FishPreview", new Type[2] { typeof(RectTransform), typeof(RawImage) }); val3.transform.SetParent(transform, 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 = ComposeFishPreview(creature, out var previewUv); RawImage component2 = val3.GetComponent(); component2.texture = (Texture)(object)_currentTexture; component2.uvRect = previewUv; val.transform.localScale = Vector3.zero; return val; } private static RenderTexture ComposeFishPreview(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_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0308: 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) { GiantCatchModule.Instance?.SpongeLogPreviewWarning("Local inventory was unavailable for the catch preview."); return null; } PlayerInventory inventory = localPlayer.Inventory; Camera val = (Camera)InventoryCameraField.GetValue(inventory); List list = (List)ItemSlotsField.GetValue(inventory); if ((Object)(object)val == (Object)null || list == null) { GiantCatchModule.Instance?.SpongeLogPreviewWarning("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) { GiantCatchModule.Instance?.SpongeLogPreviewWarning("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 = "SpongeMods_CatchPreview", 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 TweenCard(GameObject card) { CanvasGroup group = card.GetComponent(); float elapsed = 0f; while (elapsed < 0.28f && (Object)(object)card != (Object)null) { elapsed += Time.unscaledDeltaTime; float num = Mathf.Clamp01(elapsed / 0.28f); card.transform.localScale = Vector3.one * (1f - Mathf.Pow(1f - num, 3f)); 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 SizeRewardToast { private static GameObject _canvasRoot; public static void Show(MonoBehaviour runner, float size) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) Cleanup(); if (!((Object)(object)runner == (Object)null) && !((Object)(object)PlayerUI.CanvasTextPrefab == (Object)null)) { _canvasRoot = UiSupport.CreateOverlayCanvas("SpongeMods_SizeRewardCanvas", 5001); TextMeshProUGUI obj = Object.Instantiate(PlayerUI.CanvasTextPrefab, _canvasRoot.transform); ((Object)((Component)obj).gameObject).name = "SizeRewardRow"; RectTransform rectTransform = ((TMP_Text)obj).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 0.5f); rectTransform.anchorMax = new Vector2(0.5f, 0.5f); rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.anchoredPosition = new Vector2(0f, -181f); rectTransform.sizeDelta = new Vector2(620f, 42f); ((TMP_Text)obj).text = $"{size:0.00}x Size"; ((TMP_Text)obj).fontSize = 27f; ((TMP_Text)obj).fontStyle = (FontStyles)0; ((Graphic)obj).color = Color.white; ((TMP_Text)obj).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).richText = true; ((Graphic)obj).raycastTarget = false; CanvasGroup val = _canvasRoot.AddComponent(); runner.StartCoroutine(ConcealAfterDelay(val)); } } private static IEnumerator ConcealAfterDelay(CanvasGroup group) { yield return (object)new WaitForSecondsRealtime(3.7f); float elapsed = 0f; while (elapsed < 0.5f && (Object)(object)group != (Object)null) { elapsed += Time.unscaledDeltaTime; group.alpha = 1f - Mathf.Clamp01(elapsed / 0.5f); yield return null; } Cleanup(); } private static void Cleanup() { if ((Object)(object)_canvasRoot != (Object)null) { Object.Destroy((Object)(object)_canvasRoot); } _canvasRoot = null; } } internal sealed class FishHealthReadout : 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 const float NearRange = 12f; private const float FarRange = 28f; private const float NearRangeSquared = 144f; private const float FarRangeSquared = 784f; private const float RendererRefreshInterval = 1.5f; private void Awake() { _creature = ((Component)this).GetComponent(); _renderers = ((Component)this).GetComponentsInChildren(true); } private void LateUpdate() { //IL_0094: 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_00a4: 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) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_creature == (Object)null || ((Object)(object)_root == (Object)null && !AttemptCreate())) { 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); if (num2 <= 0) { _root.SetActive(false); return; } Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; bool flag = num2 < num || (Object)(object)((Item)_creature).AttachedRod != (Object)null; if (sqrMagnitude > (flag ? 784f : 144f)) { _root.SetActive(false); return; } if (!AnyRendererVisible()) { _root.SetActive(false); return; } _root.SetActive(true); if (Time.unscaledTime >= _nextRendererRefresh) { _renderers = ((Component)this).GetComponentsInChildren(true); _nextRendererRefresh = Time.unscaledTime + 1.5f; } RedrawBounds(); float num3 = 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 + num3 * 0.18f, ((Bounds)(ref _bounds)).center.z); _root.transform.rotation = ((Component)val).transform.rotation; float num4 = Mathf.Clamp(Mathf.Sqrt(sqrMagnitude) * 0.00032f, 0.0024f, 0.0075f); _root.transform.localScale = Vector3.one * num4; float num5 = (float)num2 / (float)num; _displayedRatio = Mathf.MoveTowards(_displayedRatio, num5, 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 = ((num5 > 0.55f) ? new Color(0.22f, 0.86f, 0.42f, 0.96f) : ((num5 > 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 AttemptCreate() { //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("SpongeMods_CreatureHealthBar", new Type[2] { typeof(RectTransform), typeof(Canvas) }); Canvas component = _root.GetComponent(); component.renderMode = (RenderMode)2; component.sortingOrder = 45; ((RectTransform)_root.transform).sizeDelta = new Vector2(230f, 42f); AssignRect(MakeImage(_root.transform, "Shadow", new Color(0f, 0f, 0f, 0.72f)).GetComponent(), Vector2.zero, Vector2.one, new Vector2(-5f, -5f), new Vector2(5f, 5f)); GameObject obj2 = MakeImage(_root.transform, "Track", new Color(0.035f, 0.055f, 0.065f, 0.96f)); AssignRect(obj2.GetComponent(), Vector2.zero, Vector2.one, new Vector2(2f, 2f), new Vector2(-2f, -2f)); GameObject val = MakeImage(obj2.transform, "Fill", Color.green); _fillRect = val.GetComponent(); AssignRect(_fillRect, Vector2.zero, Vector2.one, new Vector2(4f, 4f), new Vector2(-4f, -4f)); _fill = val.GetComponent(); _fill.type = (Type)0; _numbers = Object.Instantiate(canvasTextPrefab, _root.transform); ((Object)((Component)_numbers).gameObject).name = "HealthNumbers"; AssignRect(((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 bool AnyRendererVisible() { if (_renderers == null || _renderers.Length == 0) { return true; } for (int i = 0; i < _renderers.Length; i++) { if ((Object)(object)_renderers[i] != (Object)null && _renderers[i].isVisible) { return true; } } return false; } private void RedrawBounds() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_002a: Unknown result type (might be due to invalid IL or missing references) bool flag = false; for (int i = 0; i < _renderers.Length; i++) { Renderer val = _renderers[i]; if (!((Object)(object)val == (Object)null) && val.enabled) { if (flag) { ((Bounds)(ref _bounds)).Encapsulate(val.bounds); continue; } _bounds = val.bounds; flag = true; } } if (!flag) { _bounds = new Bounds(((Component)this).transform.position, Vector3.one); } } private static GameObject MakeImage(Transform parent, string name, Color colour) { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(parent, false); Image component = val.GetComponent(); ((Graphic)component).color = colour; ((Graphic)component).raycastTarget = false; return val; } private static void AssignRect(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 FishHealthReadoutSystem { private static float _nextScan; public static void Tick() { if (!(Time.unscaledTime < _nextScan) && !((Object)(object)Player.LocalPlayer == (Object)null)) { _nextScan = Time.unscaledTime + 1.5f; Creature[] array = Object.FindObjectsByType(); for (int i = 0; i < array.Length; i++) { Attach(array[i]); } } } public static void Attach(Creature creature) { if (!((Object)(object)creature == (Object)null) && !FishSizeService.IsFlyingCreature(creature) && !((Object)(object)((Component)creature).GetComponent() != (Object)null)) { ((Component)creature).gameObject.AddComponent(); } } public static void Shutdown() { FishHealthReadout[] array = Object.FindObjectsByType(); foreach (FishHealthReadout fishHealthReadout in array) { if ((Object)(object)fishHealthReadout != (Object)null) { Object.Destroy((Object)(object)fishHealthReadout); } } } } internal static class UnboundedWeaponTiers { 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, SpongeSaturate(damage + num * num2)); SharpnessCost.SetValue(val, SpongeProgressiveCost(cost, step, num2)); array2[i] = val; } SharpnessTable.SetValue(melee, array2); SpongeLogOnce(); } } 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, SpongeSaturate(damage + num * num2)); BulletCost.SetValue(val, SpongeProgressiveCost(cost, step, num2)); array2[i] = val; } BulletTable.SetValue(attachments, array2); SpongeLogOnce(); } } 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 SpongeProgressiveCost(int lastCost, int step, long extra) { return SpongeSaturate(lastCost + step * extra * (extra + 1) / 2); } private static int SpongeSaturate(long value) { return (int)Math.Max(1L, Math.Min(2000000000L, value)); } private static void SpongeLogOnce() { if (!_logged) { _logged = true; GiantCatchModule.Instance?.SpongeLogInfiniteWeaponUpgrades(); } } } [HarmonyPatch] internal static class MeleeTierTablePatch { private static IEnumerable 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) { UnboundedWeaponTiers.Ensure(__instance); } } [HarmonyPatch] internal static class BulletTierTablePatch { private static IEnumerable 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) { UnboundedWeaponTiers.Ensure(__instance); } } [HarmonyPatch] internal static class SharpnessBenchCapPatch { private static IEnumerable 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) { UnboundedWeaponTiers.Unlock(__instance); } } [HarmonyPatch] internal static class BulletBenchCapPatch { private static IEnumerable 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) { UnboundedWeaponTiers.Unlock(__instance); } } internal static class FishSizeService { 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 ObtainSize(Creature creature) { if (!HasScalableCatch(creature)) { return 1f; } return Mathf.Clamp(((SyncVar)WeightField.GetValue(creature)).Value, 1f, 25f); } public static bool IsFlyingCreature(Creature creature) { if (!(creature is Bird)) { return creature is Albatross; } return true; } public static bool HasScalableCatch(Creature creature) { if ((Object)(object)creature == (Object)null || IsFlyingCreature(creature)) { return false; } if (IsBoss(creature) || (Object)(object)((Item)creature).AttachedRod != (Object)null) { return true; } FishScaleTracker component = ((Component)creature).GetComponent(); if ((Object)(object)component == (Object)null) { return false; } if (!component.WasHooked) { return component.LoadedFromSave; } 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 ObtainDisplaySize(Creature creature) { if ((Object)(object)creature == (Object)null) { return 1f; } return Mathf.Clamp(ObtainRawWeight(creature), 1f, 25f); } public static float ObtainRawWeight(Creature creature) { return ((SyncVar)WeightField.GetValue(creature)).Value; } public static void AssignSize(Creature creature, float size) { size = Mathf.Clamp(size, 1f, 25f); ((SyncVar)WeightField.GetValue(creature)).Value = size; } public static bool SpongeSkipsRandomWeight(Creature creature) { return (bool)SkipWeightField.GetValue(creature); } public static void SpongeRefillHealth(Creature creature) { SyncVar val = (SyncVar)HpField.GetValue(creature); if (val.Value > 0) { val.Value = creature.MaxHp; } } public static void SpongeMarkLoadedFromSave(Creature creature) { ObtainOrCreateState(creature).LoadedFromSave = true; } public static void SpongeRecordCatcher(Creature creature, FishingRod rod) { if (!((Object)(object)creature == (Object)null) && !((Object)(object)rod == (Object)null)) { FishScaleTracker fishScaleTracker = ObtainOrCreateState(creature); fishScaleTracker.WasHooked = true; fishScaleTracker.CatcherRod = rod; Player val = (((Object)(object)((Item)rod).SyncedHolder != (Object)null) ? ((Item)rod).SyncedHolder : ((Item)rod).Holder); if ((Object)(object)val != (Object)null) { fishScaleTracker.Catcher = val; fishScaleTracker.AnglerName = val.SteamName; } if (InstanceFinder.IsServerStarted && !fishScaleTracker.LuckRollApplied && !fishScaleTracker.LoadedFromSave && !IsBoss(creature)) { int luck = RodTierService.ObtainLuck(val); AssignSize(creature, SizeCurve.Roll(((NetworkBehaviour)creature).ObjectId, luck)); fishScaleTracker.LuckRollApplied = true; SpongeRefillHealth(creature); SetVisualScale(creature); GiantCatchModule.Instance?.SpongeLogLuckRoll(creature, val, luck); } } } public static bool AttemptClaimBossInitialRefill(Creature creature) { if ((Object)(object)creature == (Object)null || !IsBoss(creature)) { return false; } FishScaleTracker fishScaleTracker = ObtainOrCreateState(creature); if (fishScaleTracker.BossHealthInitialized) { return false; } fishScaleTracker.BossHealthInitialized = true; return true; } public static bool IsDead(Creature creature) { if ((Object)(object)creature == (Object)null) { return false; } return ((SyncVar)HpField.GetValue(creature)).Value <= 0; } public static bool AttemptClaimLocalNotification(Creature creature, out string catcherName) { catcherName = string.Empty; if ((Object)(object)creature == (Object)null) { return false; } FishScaleTracker component = ((Component)creature).GetComponent(); 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) { return false; } if ((!((Object)(object)localPlayer != (Object)null) || !((Object)(object)val == (Object)(object)localPlayer)) && !((NetworkBehaviour)val).Owner.IsLocalClient) { return false; } component.NotificationShown = true; catcherName = ((!string.IsNullOrWhiteSpace(component.AnglerName)) ? component.AnglerName : (((Object)(object)val != (Object)null) ? val.SteamName : localPlayer.SteamName)); return true; } public static bool SpongeWasLoadedFromSave(Creature creature) { FishScaleTracker component = ((Component)creature).GetComponent(); if ((Object)(object)component != (Object)null) { return component.LoadedFromSave; } return false; } public static void SetVisualScale(Creature creature) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (HasScalableCatch(creature)) { FishScaleTracker fishScaleTracker = ObtainOrCreateState(creature); ((Component)creature).transform.localScale = fishScaleTracker.OriginalScale * ObtainSize(creature); } } private static FishScaleTracker ObtainOrCreateState(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) FishScaleTracker component = ((Component)creature).GetComponent(); if ((Object)(object)component != (Object)null) { return component; } component = ((Component)creature).gameObject.AddComponent(); component.OriginalScale = ((Component)creature).transform.localScale; return component; } public static int SpongeScaledInt(int original, Creature creature) { double value = (double)original * (double)ObtainSize(creature); return (int)Math.Min(2147483647.0, Math.Max(1.0, Math.Round(value, MidpointRounding.AwayFromZero))); } } internal sealed class GiantCatchModule : FeatureModule { private ConfigEntry _healthBars; internal static GiantCatchModule Instance { get; private set; } public override string DisplayName => "Giant Catches"; public override bool WantsUpdate => true; public override void BindConfiguration(ConfigFile config) { ModuleEnabled = config.Bind("Giant Catches", "Enabled", true, "Random fish sizes, catch records, rod upgrades and creature health bars."); _healthBars = config.Bind("Giant Catches", "CreatureHealthBars", true, "Show a floating health bar above every creature."); LeaderboardService.Initialize(config); RodTierService.Initialize(config); } public override void Initialise(Harmony harmony) { Instance = this; harmony.PatchAll(typeof(FishServerStartPatch)); harmony.PatchAll(typeof(FishClientStartPatch)); harmony.PatchAll(typeof(FishMaxHpPatch)); harmony.PatchAll(typeof(FishRestorePatch)); harmony.PatchAll(typeof(CatchLeaderboardPatch)); harmony.PatchAll(typeof(CatchOwnerPatch)); harmony.PatchAll(typeof(CatchDeathAnnouncePatch)); harmony.PatchAll(typeof(AggressiveFishStrengthPatch)); harmony.PatchAll(typeof(PufferStrengthPatch)); harmony.PatchAll(typeof(BowheadStrengthPatch)); harmony.PatchAll(typeof(RodSaleValuePatch)); harmony.PatchAll(typeof(RodSaleScopePatch)); harmony.PatchAll(typeof(MeleeTierTablePatch)); harmony.PatchAll(typeof(BulletTierTablePatch)); harmony.PatchAll(typeof(SharpnessBenchCapPatch)); harmony.PatchAll(typeof(BulletBenchCapPatch)); CompendiumPlugin.Log.LogInfo((object)"Giant Catches active."); } public override void Tick() { LeaderboardService.Tick(); RodTierService.Tick(); if (_healthBars.Value) { FishHealthReadoutSystem.Tick(); } } public override void Shutdown() { LeaderboardService.Shutdown(); RodTierService.Shutdown(); FishHealthReadoutSystem.Shutdown(); Instance = null; } internal void DisplayCatchCard(Creature creature, string catcherName) { CatchToast.Show((MonoBehaviour)(object)CompendiumPlugin.Instance, creature, catcherName); SizeRewardToast.Show((MonoBehaviour)(object)CompendiumPlugin.Instance, FishSizeService.ObtainDisplaySize(creature)); } internal void DisplayGlobalRankedCatch(Creature creature, string catcherName, float size, bool isLocalCatcher) { CatchToast.Show((MonoBehaviour)(object)CompendiumPlugin.Instance, creature, catcherName); if (isLocalCatcher) { SizeRewardToast.Show((MonoBehaviour)(object)CompendiumPlugin.Instance, size); } } internal void SpongeScheduleBossHealthRefill(Creature creature) { CompendiumPlugin.Run(SpongeRefillBossHealthAfterInitialization(creature)); } private static IEnumerator SpongeRefillBossHealthAfterInitialization(Creature creature) { yield return null; yield return null; if ((Object)(object)creature != (Object)null && FishSizeService.AttemptClaimBossInitialRefill(creature)) { FishSizeService.SpongeRefillHealth(creature); } } internal void SpongeLogPreviewWarning(string message) { CompendiumPlugin.Log.LogWarning((object)message); } internal void SpongeLogCatchSize(Creature creature) { CompendiumPlugin.Log.LogInfo((object)$"Scaled catch {((Item)creature).GetName()} to x{FishSizeService.ObtainDisplaySize(creature):0.00}."); } internal void SpongeLogRankingError(string operation, Exception error) { CompendiumPlugin.Log.LogError((object)$"Ranking {operation} failed safely: {error}"); } internal void SpongeLogRankingHudCreated() { CompendiumPlugin.Log.LogInfo((object)"Ranking HUD created on its independent overlay canvas."); } internal void SpongeLogLuckRoll(Creature creature, Player catcher, int luck) { CompendiumPlugin.Log.LogInfo((object)(string.Format("Applied catcher luck {0} for {1}: ", luck, ((catcher != null) ? catcher.SteamName : null) ?? "Angler") + $"{((Item)creature).GetName()} rolled x{FishSizeService.ObtainDisplaySize(creature):0.00}.")); } internal void SpongeLogUpgradePurchase(Player player, int cost, int newLevel) { CompendiumPlugin.Log.LogInfo((object)(string.Format("Server charged ${0} to {1} ", cost, ((player != null) ? player.SteamName : null) ?? "Angler") + $"and applied rod upgrade level {newLevel}.")); } internal void SpongeLogPersonalWalletCompatibility() { CompendiumPlugin.Log.LogInfo((object)"NoSharedMoney detected: rod upgrades will use each player's personal wallet."); } internal void SpongeLogUpgradeError(string operation, Exception error) { CompendiumPlugin.Log.LogError((object)$"Rod upgrade failed while {operation}: {error}"); } internal void SpongeLogInfiniteWeaponUpgrades() { CompendiumPlugin.Log.LogInfo((object)"Expanded melee and bullet upgrade tables to 255 persistent levels."); } internal void SpongeLogUpgradeRejection(string reason) { CompendiumPlugin.Log.LogWarning((object)("Rod upgrade rejected: " + reason)); } } [HarmonyPatch(typeof(Creature), "OnStartServer")] internal static class FishServerStartPatch { private static void Prefix(Creature __instance, out byte __state) { __state = 0; if (!FishSizeService.HasScalableCatch(__instance) || (FishSizeService.SpongeSkipsRandomWeight(__instance) && !FishSizeService.IsBoss(__instance))) { return; } if (FishSizeService.IsBoss(__instance) && !FishSizeService.SpongeWasLoadedFromSave(__instance)) { __state = 3; } else if (!(Math.Abs(FishSizeService.ObtainRawWeight(__instance) - 1f) >= 0.0001f)) { if (FishSizeService.SpongeWasLoadedFromSave(__instance)) { FishSizeService.AssignSize(__instance, 1.0001f); __state = 2; } else { __state = 1; } } } private static void Postfix(Creature __instance, byte __state) { if (!FishSizeService.HasScalableCatch(__instance) || (FishSizeService.SpongeSkipsRandomWeight(__instance) && !FishSizeService.IsBoss(__instance))) { return; } switch (__state) { case 1: case 3: FishSizeService.AssignSize(__instance, SizeCurve.Roll(((NetworkBehaviour)__instance).ObjectId, RodTierService.ObtainLuckForCreature(__instance))); break; case 2: FishSizeService.AssignSize(__instance, 1f); break; default: if (FishSizeService.ObtainRawWeight(__instance) < 1f) { FishSizeService.AssignSize(__instance, 1f); } break; } FishSizeService.SpongeRefillHealth(__instance); if (FishSizeService.IsBoss(__instance)) { GiantCatchModule.Instance?.SpongeScheduleBossHealthRefill(__instance); } FishSizeService.SetVisualScale(__instance); GiantCatchModule.Instance?.SpongeLogCatchSize(__instance); LeaderboardService.SpongeRecordCatch(__instance); } } [HarmonyPatch(typeof(Creature), "OnStartClient")] internal static class FishClientStartPatch { private static void Postfix(Creature __instance) { FishSizeService.SetVisualScale(__instance); FishHealthReadoutSystem.Attach(__instance); } } [HarmonyPatch(typeof(Creature), "get_MaxHp")] internal static class FishMaxHpPatch { private static void Postfix(Creature __instance, ref int __result) { if (FishSizeService.HasScalableCatch(__instance)) { __result = FishSizeService.SpongeScaledInt(__result, __instance); } } } [HarmonyPatch(typeof(Creature), "LoadFromSave")] internal static class FishRestorePatch { private static void Prefix(Creature __instance) { if (!((Object)(object)__instance == (Object)null) && !FishSizeService.IsFlyingCreature(__instance)) { FishSizeService.SpongeMarkLoadedFromSave(__instance); } } private static void Postfix(Creature __instance) { if (FishSizeService.HasScalableCatch(__instance) && FishSizeService.ObtainRawWeight(__instance) < 1f) { FishSizeService.AssignSize(__instance, 1f); } FishSizeService.SetVisualScale(__instance); } } [HarmonyPatch(typeof(Creature), "ServerChangeHp")] internal static class CatchLeaderboardPatch { private static void Postfix(Creature __instance) { try { if (FishSizeService.IsDead(__instance)) { LeaderboardService.SpongeRecordCatch(__instance); LeaderboardService.BroadcastRankedDeath(__instance); } } catch (Exception error) { GiantCatchModule.Instance?.SpongeLogRankingError("death hook", error); } } } [HarmonyPatch(typeof(Item), "OnAttachedRodChange")] internal static class CatchOwnerPatch { 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)) { FishSizeService.SpongeRecordCatcher(__instance.Creature, next); FishSizeService.SetVisualScale(__instance.Creature); } } } [HarmonyPatch(typeof(Creature), "OnDeath")] internal static class CatchDeathAnnouncePatch { private static void Postfix(Creature __instance) { if (!LeaderboardAnnouncement.SpongeWasAnnounced(((NetworkBehaviour)__instance).ObjectId) && GiantCatchModule.Instance != null && FishSizeService.AttemptClaimLocalNotification(__instance, out var catcherName)) { GiantCatchModule.Instance.DisplayCatchCard(__instance, catcherName); } } } [HarmonyPatch(typeof(AttackingFish), "DamageOnCollision")] internal static class AggressiveFishStrengthPatch { 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, FishSizeService.SpongeScaledInt(__state, (Creature)(object)__instance)); } private static Exception Finalizer(AttackingFish __instance, int __state, Exception __exception) { DamageField.SetValue(__instance, __state); return __exception; } } [HarmonyPatch(typeof(Pufferfish), "OnCollisionEnter")] internal static class PufferStrengthPatch { 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, FishSizeService.SpongeScaledInt(__state, (Creature)(object)__instance)); } private static Exception Finalizer(Pufferfish __instance, int __state, Exception __exception) { DamageField.SetValue(__instance, __state); return __exception; } } [HarmonyPatch(typeof(BowheadWhale), "DamageOnCollision")] internal static class BowheadStrengthPatch { 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, FishSizeService.SpongeScaledInt(__state, (Creature)(object)__instance)); } private static Exception Finalizer(BowheadWhale __instance, int __state, Exception __exception) { DamageField.SetValue(__instance, __state); return __exception; } } [HarmonyPatch(typeof(Item), "get_TotalWorth")] internal static class RodSaleValuePatch { private static void Postfix(ref int __result) { __result = RodSaleBonusService.Apply(__result); } } [HarmonyPatch(typeof(MoneyManager), "SellItem")] internal static class RodSaleScopePatch { private static void Prefix() { RodSaleBonusService.Begin(Player.LocalPlayer); } private static Exception Finalizer(Exception __exception) { RodSaleBonusService.End(); return __exception; } } internal sealed class LeaderboardRow { public string World; public string SteamId; public string DisplayName; public float Size; } internal struct LeaderboardMessage : IBroadcast { public string Payload; } internal struct CatchRecordMessage : IBroadcast { public int FishNetworkId; public float Size; public ulong AnglerSteamId; public string AnglerName; } internal static class LeaderboardService { private const int RecordsPerWorld = 50; private const int DisplayedRows = 3; private const float BroadcastInterval = 4f; private static readonly List AllEntries = new List(); private static readonly List CurrentEntries = new List(); private static ConfigEntry _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("Giant Catches", "RankingRecords", string.Empty, "Persistent biggest-catch records. Managed by the mod."); SpongeLoadSavedData(); AssignupSerializers(); _initialized = true; } } public static void Tick() { RequireNetworkRegistration(); bool isServerStarted = InstanceFinder.IsServerStarted; if (isServerStarted) { SpongeSelectCurrentWorld(); if (!_wasServerStarted || Time.unscaledTime >= _nextBroadcastTime) { SpongeBroadcastCurrent(); _nextBroadcastTime = Time.unscaledTime + 4f; } } _wasServerStarted = isServerStarted; LeaderboardHud.RequireVisible(CurrentEntries); } public static void Shutdown() { if ((Object)(object)_registeredNetworkManager != (Object)null) { try { _registeredNetworkManager.ClientManager.UnregisterBroadcast((Action)SpongeOnRankingBroadcast); _registeredNetworkManager.ClientManager.UnregisterBroadcast((Action)SpongeOnRankedCatchBroadcast); } catch { } } _registeredNetworkManager = null; _wasServerStarted = false; LeaderboardHud.Teardown(); } public static void SpongeRecordCatch(Creature creature) { try { SpongeRecordCatchInternal(creature); } catch (Exception error) { GiantCatchModule.Instance?.SpongeLogRankingError("record", error); } } private static void SpongeRecordCatchInternal(Creature creature) { if (!_initialized || !InstanceFinder.IsServerStarted || (Object)(object)creature == (Object)null) { return; } FishScaleTracker component = ((Component)creature).GetComponent(); 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; } SpongeSelectCurrentWorld(); float size = FishSizeService.ObtainDisplaySize(creature); string text = ((val.SteamID != 0L) ? val.SteamID.ToString(CultureInfo.InvariantCulture) : ("connection-" + ((NetworkBehaviour)val).OwnerId.ToString(CultureInfo.InvariantCulture))); string displayName = (string.IsNullOrWhiteSpace(val.SteamName) ? "Angler" : val.SteamName.Trim()); LeaderboardRow leaderboardRow = new LeaderboardRow(); leaderboardRow.World = _currentWorld; leaderboardRow.SteamId = text + "-" + DateTime.UtcNow.Ticks.ToString(CultureInfo.InvariantCulture) + "-" + ((NetworkBehaviour)creature).ObjectId.ToString(CultureInfo.InvariantCulture); leaderboardRow.DisplayName = displayName; leaderboardRow.Size = size; LeaderboardRow leaderboardRow2 = leaderboardRow; AllEntries.Add(leaderboardRow2); component.RankingEntryId = leaderboardRow2.SteamId; foreach (LeaderboardRow item in (from candidate in AllEntries where candidate != null && candidate.World == _currentWorld orderby candidate.Size descending select candidate).Skip(50).ToList()) { AllEntries.Remove(item); } RedrawCurrentEntries(); SpongeSaveData(); SpongeBroadcastCurrent(); } public static void BroadcastRankedDeath(Creature creature) { try { if (!_initialized || !InstanceFinder.IsServerStarted || (Object)(object)creature == (Object)null) { return; } FishScaleTracker state = ((Component)creature).GetComponent(); if ((Object)(object)state == (Object)null || state.RankingAnnouncementSent || string.IsNullOrEmpty(state.RankingEntryId)) { return; } SpongeSelectCurrentWorld(); LeaderboardRow leaderboardRow = CurrentEntries.FirstOrDefault((LeaderboardRow candidate) => candidate.SteamId == state.RankingEntryId); if (leaderboardRow != null) { Player val = state.Catcher; if ((Object)(object)val == (Object)null && (Object)(object)state.CatcherRod != (Object)null) { val = (((Object)(object)((Item)state.CatcherRod).SyncedHolder != (Object)null) ? ((Item)state.CatcherRod).SyncedHolder : ((Item)state.CatcherRod).Holder); } state.RankingAnnouncementSent = true; CatchRecordMessage catchRecordMessage = new CatchRecordMessage { FishNetworkId = ((NetworkBehaviour)creature).ObjectId, Size = leaderboardRow.Size, AnglerSteamId = (((Object)(object)val != (Object)null) ? val.SteamID : 0), AnglerName = leaderboardRow.DisplayName }; if (InstanceFinder.IsClientStarted) { LeaderboardAnnouncement.SpongeReceive(catchRecordMessage); } InstanceFinder.ServerManager.Broadcast(catchRecordMessage, true, (Channel)0); } } catch (Exception error) { GiantCatchModule.Instance?.SpongeLogRankingError("global announcement", error); } } public static void SpongeBroadcastCurrent() { try { if (_initialized && InstanceFinder.IsServerStarted && !((Object)(object)InstanceFinder.ServerManager == (Object)null)) { SpongeSelectCurrentWorld(); InstanceFinder.ServerManager.Broadcast(new LeaderboardMessage { Payload = ComposeNetworkPayload(CurrentEntries) }, true, (Channel)0); } } catch (Exception error) { GiantCatchModule.Instance?.SpongeLogRankingError("broadcast", error); } } private static void AssignupSerializers() { if (!_serializersReady) { GenericWriter.SetWrite((Action)delegate(Writer writer, LeaderboardMessage value) { writer.WriteString(value.Payload); }); GenericReader.SetRead((Func)((Reader reader) => new LeaderboardMessage { Payload = reader.ReadStringAllocated() })); GenericWriter.SetWrite((Action)delegate(Writer writer, CatchRecordMessage value) { writer.WriteInt32(value.FishNetworkId); writer.WriteSingle(value.Size); writer.WriteUInt64(value.AnglerSteamId); writer.WriteString(value.AnglerName); }); GenericReader.SetRead((Func)((Reader reader) => new CatchRecordMessage { FishNetworkId = reader.ReadInt32(), Size = reader.ReadSingle(), AnglerSteamId = reader.ReadUInt64(), AnglerName = reader.ReadStringAllocated() })); _serializersReady = true; } } private static void RequireNetworkRegistration() { NetworkManager networkManager = InstanceFinder.NetworkManager; if ((Object)(object)networkManager == (Object)(object)_registeredNetworkManager) { return; } if ((Object)(object)_registeredNetworkManager != (Object)null) { try { _registeredNetworkManager.ClientManager.UnregisterBroadcast((Action)SpongeOnRankingBroadcast); _registeredNetworkManager.ClientManager.UnregisterBroadcast((Action)SpongeOnRankedCatchBroadcast); } catch { } } _registeredNetworkManager = networkManager; if (!((Object)(object)networkManager == (Object)null)) { networkManager.ClientManager.RegisterBroadcast((Action)SpongeOnRankingBroadcast); networkManager.ClientManager.RegisterBroadcast((Action)SpongeOnRankedCatchBroadcast); } } private static void SpongeOnRankingBroadcast(LeaderboardMessage message, Channel channel) { try { if (!InstanceFinder.IsServerStarted) { CurrentEntries.Clear(); SpongeParseNetworkPayload(message.Payload, CurrentEntries); } } catch (Exception error) { GiantCatchModule.Instance?.SpongeLogRankingError("receive", error); } } private static void SpongeOnRankedCatchBroadcast(CatchRecordMessage message, Channel channel) { LeaderboardAnnouncement.SpongeReceive(message); } private static void SpongeSelectCurrentWorld() { string text = ((SaveManager.CurServerSave != null && !string.IsNullOrWhiteSpace(SaveManager.CurServerSave.Name)) ? SaveManager.CurServerSave.Name.Trim() : "Current game"); if (!(text == _currentWorld)) { _currentWorld = text; RedrawCurrentEntries(); } } private static void RedrawCurrentEntries() { CurrentEntries.Clear(); CurrentEntries.AddRange((from entry in AllEntries where entry != null && entry.World == _currentWorld orderby entry.Size descending select entry).ThenBy((LeaderboardRow entry) => entry.DisplayName, StringComparer.OrdinalIgnoreCase).Take(3)); } private static void SpongeLoadSavedData() { AllEntries.Clear(); if (_savedData == null || string.IsNullOrWhiteSpace(_savedData.Value)) { return; } string[] array = _savedData.Value.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(','); if (array2.Length == 4 && float.TryParse(array2[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { try { AllEntries.Add(new LeaderboardRow { World = Decode(array2[0]), SteamId = Decode(array2[1]), DisplayName = Decode(array2[2]), Size = result }); } catch (FormatException) { } } } } private static void SpongeSaveData() { if (_savedData != null) { _savedData.Value = string.Join(";", from entry in AllEntries where entry != null select Encode(entry.World) + "," + Encode(entry.SteamId) + "," + Encode(entry.DisplayName) + "," + entry.Size.ToString("0.00", CultureInfo.InvariantCulture)); } } private static string ComposeNetworkPayload(IEnumerable entries) { return string.Join(";", from entry in entries where entry != null select Encode(entry.DisplayName) + "," + entry.Size.ToString("0.00", CultureInfo.InvariantCulture)); } private static void SpongeParseNetworkPayload(string payload, List destination) { if (string.IsNullOrWhiteSpace(payload)) { return; } string[] array = payload.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(','); if (array2.Length == 2 && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { try { destination.Add(new LeaderboardRow { DisplayName = Decode(array2[0]), Size = result }); } catch (FormatException) { } } } } private static string Encode(string value) { return Convert.ToBase64String(Encoding.UTF8.GetBytes(value ?? string.Empty)); } private static string Decode(string value) { return Encoding.UTF8.GetString(Convert.FromBase64String(value)); } } internal static class LeaderboardAnnouncement { private static readonly Dictionary AnnouncedObjects = new Dictionary(); public static void SpongeReceive(CatchRecordMessage message) { if (GiantCatchModule.Instance != null && !SpongeWasAnnounced(message.FishNetworkId)) { AnnouncedObjects[message.FishNetworkId] = Time.unscaledTime + 12f; CompendiumPlugin.Run(DisplayWhenAvailable(message)); } } public static bool SpongeWasAnnounced(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 DisplayWhenAvailable(CatchRecordMessage message) { float deadline = Time.unscaledTime + 2f; Creature found = null; while ((Object)(object)found == (Object)null && Time.unscaledTime < deadline) { Creature[] array = Object.FindObjectsByType(); foreach (Creature val in array) { if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).ObjectId == message.FishNetworkId) { found = val; break; } } if ((Object)(object)found == (Object)null) { yield return null; } } if (!((Object)(object)found == (Object)null) && GiantCatchModule.Instance != null) { Player localPlayer = Player.LocalPlayer; bool isLocalCatcher = (Object)(object)localPlayer != (Object)null && message.AnglerSteamId != 0L && localPlayer.SteamID == message.AnglerSteamId; GiantCatchModule.Instance.DisplayGlobalRankedCatch(found, string.IsNullOrWhiteSpace(message.AnglerName) ? "Angler" : message.AnglerName, message.Size, isLocalCatcher); } } } internal sealed class RodTierBench : MonoBehaviour { private static readonly Color Wood = new Color(0.34f, 0.19f, 0.1f); private static readonly Color DarkWood = new Color(0.19f, 0.09f, 0.045f); private static Material _sceneMaterial; private float _nextNativeRodRetry; public static RodTierBench Create(Vector3 position, float yaw) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) GameObject val = new GameObject("SpongeMods_RodUpgradeTable"); val.SetActive(false); RodTierBench result = val.AddComponent(); val.transform.position = position; val.transform.rotation = Quaternion.Euler(0f, yaw, 0f); ComposeFurniture(val.transform); val.SetActive(true); return result; } private static GameObject ComposeFurniture(Transform root) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) LookupSceneMaterial(); GameObject result = MakePart(root, "WorkbenchTop", new Vector3(0f, 1.05f, 0f), new Vector3(2.7f, 0.2f, 1.25f), Wood); MakePart(root, "Apron", new Vector3(0f, 0.84f, 0f), new Vector3(2.45f, 0.24f, 1.02f), DarkWood); float[] array = new float[2] { -1.05f, 1.05f }; foreach (float num in array) { float[] array2 = new float[2] { -0.42f, 0.42f }; foreach (float num2 in array2) { MakePart(root, "Leg", new Vector3(num, 0.46f, num2), new Vector3(0.22f, 0.92f, 0.22f), DarkWood); } } MakePart(root, "LowerBrace", new Vector3(0f, 0.3f, 0f), new Vector3(2.15f, 0.12f, 0.18f), Wood); MakeRodModel(root); return result; } private void Update() { if ((Object)(object)((Component)this).transform.Find("NativeFishingRodDisplay") != (Object)null || Time.unscaledTime < _nextNativeRodRetry) { return; } _nextNativeRodRetry = Time.unscaledTime + 1f; if (AttemptCreateNativeRodModel(((Component)this).transform)) { Transform val = ((Component)this).transform.Find("DisplayFishingRod"); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } } private static GameObject MakePart(Transform parent, string name, Vector3 localPosition, Vector3 localScale, Color colour) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = localPosition; obj.transform.localScale = localScale; obj.GetComponent().sharedMaterial = MakeTintedMaterial(colour); return obj; } private static void MakeRodModel(Transform parent) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0054: 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_0069: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) if (!AttemptCreateNativeRodModel(parent)) { GameObject val = new GameObject("DisplayFishingRod"); val.transform.SetParent(parent, false); val.transform.localPosition = new Vector3(0f, 1.28f, 0f); val.transform.localRotation = Quaternion.Euler(0f, 18f, -4f); MakeCylinder(val.transform, "RodBlank", Vector3.zero, new Vector3(0.045f, 1.05f, 0.045f), new Color(0.08f, 0.28f, 0.18f), Quaternion.Euler(0f, 0f, 90f)); MakeCylinder(val.transform, "Handle", new Vector3(-1f, 0f, 0f), new Vector3(0.09f, 0.33f, 0.09f), new Color(0.18f, 0.08f, 0.04f), Quaternion.Euler(0f, 0f, 90f)); MakeCylinder(val.transform, "Reel", new Vector3(-0.55f, -0.12f, 0f), new Vector3(0.16f, 0.08f, 0.16f), new Color(0.16f, 0.62f, 0.48f), Quaternion.Euler(90f, 0f, 0f)); } } private static void MakeCylinder(Transform parent, string name, Vector3 position, Vector3 scale, Color colour, Quaternion rotation) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = position; obj.transform.localScale = scale; obj.transform.localRotation = rotation; obj.GetComponent().sharedMaterial = MakeTintedMaterial(colour); Object.Destroy((Object)(object)obj.GetComponent()); } private static bool AttemptCreateNativeRodModel(Transform parent) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: 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_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: 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_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01b9: 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_0480: 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_048a: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) FishingRod val = ((IEnumerable)Object.FindObjectsByType()).FirstOrDefault((Func)((FishingRod rod) => (Object)(object)rod != (Object)null && ((Object)(object)((Item)rod).Mesh != (Object)null || ((Component)rod).GetComponentsInChildren(true).Length != 0))); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = new GameObject("NativeFishingRodDisplay"); val2.transform.SetParent(parent, false); val2.transform.localPosition = new Vector3(0f, 1.3f, 0f); if ((Object)(object)((Item)val).Mesh != (Object)null) { GameObject val3 = new GameObject("NativeRodMesh", new Type[2] { typeof(MeshFilter), typeof(MeshRenderer) }); val3.transform.SetParent(val2.transform, false); val3.GetComponent().sharedMesh = ((Item)val).Mesh; Renderer val4 = ((IEnumerable)((Component)val).GetComponentsInChildren(true)).FirstOrDefault((Func)((Renderer renderer) => (Object)(object)renderer != (Object)null && renderer.sharedMaterials.Length != 0)); ((Renderer)val3.GetComponent()).sharedMaterials = (Material[])(((Object)(object)val4 != (Object)null) ? ((Array)val4.sharedMaterials) : ((Array)new Material[1] { MakeTintedMaterial(new Color(0.08f, 0.28f, 0.18f)) })); Bounds bounds = ((Item)val).Mesh.bounds; float num = Mathf.Max(new float[3] { ((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z }); float num2 = ((num > 0.001f) ? (2.25f / num) : 1f); Quaternion val5 = ((((Bounds)(ref bounds)).size.y >= ((Bounds)(ref bounds)).size.x && ((Bounds)(ref bounds)).size.y >= ((Bounds)(ref bounds)).size.z) ? Quaternion.Euler(0f, 0f, -90f) : ((!(((Bounds)(ref bounds)).size.z >= ((Bounds)(ref bounds)).size.x) || !(((Bounds)(ref bounds)).size.z >= ((Bounds)(ref bounds)).size.y)) ? Quaternion.identity : Quaternion.Euler(0f, 90f, 0f))); Quaternion val6 = Quaternion.Euler(0f, 12f, 0f) * val5; val3.transform.localRotation = val6; val3.transform.localScale = Vector3.one * num2; val3.transform.localPosition = -(val6 * (((Bounds)(ref bounds)).center * num2)); return true; } val2.transform.localRotation = Quaternion.Euler(0f, 18f, -4f); GameObject val7 = new GameObject("Visuals"); val7.transform.SetParent(val2.transform, false); int num3 = 0; MeshFilter[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (MeshFilter val8 in componentsInChildren) { MeshRenderer component = ((Component)val8).GetComponent(); if (!((Object)(object)component == (Object)null) && !((Object)(object)val8.sharedMesh == (Object)null)) { GameObject val9 = new GameObject("Rod_" + ((Object)((Component)val8).gameObject).name, new Type[2] { typeof(MeshFilter), typeof(MeshRenderer) }); val9.transform.SetParent(val7.transform, false); val9.transform.localPosition = ((Component)val).transform.InverseTransformPoint(((Component)val8).transform.position); val9.transform.localRotation = Quaternion.Inverse(((Component)val).transform.rotation) * ((Component)val8).transform.rotation; val9.transform.localScale = SpongeDivideScale(((Component)val8).transform.lossyScale, ((Component)val).transform.lossyScale); val9.GetComponent().sharedMesh = val8.sharedMesh; ((Renderer)val9.GetComponent()).sharedMaterials = ((Renderer)component).sharedMaterials; num3++; } } if (num3 == 0) { Object.Destroy((Object)(object)val2); return false; } Renderer[] componentsInChildren2 = val7.GetComponentsInChildren(true); Bounds bounds2 = componentsInChildren2[0].bounds; foreach (Renderer item in componentsInChildren2.Skip(1)) { ((Bounds)(ref bounds2)).Encapsulate(item.bounds); } Vector3 val10 = val2.transform.InverseTransformPoint(((Bounds)(ref bounds2)).center); float num5 = Mathf.Max(new float[3] { ((Bounds)(ref bounds2)).size.x, ((Bounds)(ref bounds2)).size.y, ((Bounds)(ref bounds2)).size.z }); float num6 = ((num5 > 0.001f) ? (2.25f / num5) : 1f); val7.transform.localScale = Vector3.one * num6; val7.transform.localPosition = -val10 * num6; return true; } private static Vector3 SpongeDivideScale(Vector3 value, Vector3 divisor) { //IL_0000: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0047: 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_004e: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) return new Vector3((Mathf.Abs(divisor.x) > 0.0001f) ? (value.x / divisor.x) : value.x, (Mathf.Abs(divisor.y) > 0.0001f) ? (value.y / divisor.y) : value.y, (Mathf.Abs(divisor.z) > 0.0001f) ? (value.z / divisor.z) : value.z); } private static void LookupSceneMaterial() { if (!((Object)(object)_sceneMaterial != (Object)null) || !((Object)(object)_sceneMaterial.shader != (Object)null) || !_sceneMaterial.shader.isSupported) { Renderer val = (from renderer in Object.FindObjectsByType() where (Object)(object)renderer != (Object)null && (Object)(object)renderer.sharedMaterial != (Object)null && (Object)(object)renderer.sharedMaterial.shader != (Object)null && renderer.sharedMaterial.shader.isSupported && ((object)renderer).GetType().Name != "ParticleSystemRenderer" && !(renderer is LineRenderer) orderby SpongeMaterialScore(((Object)((Component)renderer).gameObject).name + " " + ((Object)renderer.sharedMaterial).name) descending select renderer).FirstOrDefault(); if ((Object)(object)val != (Object)null) { _sceneMaterial = val.sharedMaterial; } } } private static int SpongeMaterialScore(string value) { string text = value.ToLowerInvariant(); int num = 0; if (text.Contains("wood") || text.Contains("plank")) { num += 100; } if (text.Contains("dock") || text.Contains("pier")) { num += 80; } if (text.Contains("table") || text.Contains("bench")) { num += 70; } if (text.Contains("rock") || text.Contains("ground")) { num += 10; } if (text.Contains("water") || text.Contains("sky") || text.Contains("glass")) { num -= 100; } return num; } private static Material MakeTintedMaterial(Color colour) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0059: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0092: 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_009a: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Invalid comparison between Unknown and I4 //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Invalid comparison between Unknown and I4 //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) Material val = (((Object)(object)_sceneMaterial != (Object)null) ? new Material(_sceneMaterial.shader) : new Material(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Sprites/Default"))); ((Object)val).name = "SpongeMods_TableMaterial"; Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false) { name = "SpongeMods_SolidWood", wrapMode = (TextureWrapMode)0, filterMode = (FilterMode)1 }; val2.SetPixels((Color[])(object)new Color[4] { colour, colour, colour, colour }); val2.Apply(false, true); string[] array = new string[4] { "_BaseMap", "_MainTex", "_BaseColorMap", "_Albedo" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)(object)val2); } } val.mainTexture = (Texture)(object)val2; array = new string[4] { "_BumpMap", "_NormalMap", "_MaskMap", "_MetallicGlossMap" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetTexture(text2, (Texture)null); } } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", colour); } if (val.HasProperty("_Color")) { val.SetColor("_Color", colour); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0.18f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.18f); } Shader shader = val.shader; int num = 0; while ((Object)(object)shader != (Object)null && num < shader.GetPropertyCount()) { string propertyName = shader.GetPropertyName(num); string text3 = propertyName.ToLowerInvariant(); ShaderPropertyType propertyType = shader.GetPropertyType(num); if ((int)propertyType == 0) { val.SetColor(propertyName, colour); } else if ((int)propertyType == 1) { if (text3.Contains("color") || text3.Contains("tint")) { val.SetVector(propertyName, new Vector4(colour.r, colour.g, colour.b, colour.a)); } } else if ((int)propertyType == 4) { bool flag = text3.Contains("normal") || text3.Contains("bump") || text3.Contains("mask") || text3.Contains("metal") || text3.Contains("rough"); val.SetTexture(propertyName, (Texture)(object)(flag ? null : val2)); } num++; } return val; } } internal static class RodTierHud { private static readonly Color Cyan = new Color(0.18f, 0.82f, 0.88f, 1f); private static GameObject _canvasRoot; private static GameObject _panel; private static TextMeshProUGUI _text; public static void AssignVisible(bool visible, string message) { if (!visible) { if ((Object)(object)_canvasRoot != (Object)null) { _canvasRoot.SetActive(false); } return; } TextMeshProUGUI canvasTextPrefab; try { canvasTextPrefab = PlayerUI.CanvasTextPrefab; } catch { return; } if (!((Object)(object)canvasTextPrefab == (Object)null)) { if ((Object)(object)_canvasRoot == (Object)null || (Object)(object)_panel == (Object)null || (Object)(object)_text == (Object)null) { Teardown(); Build(); } _canvasRoot.SetActive(true); ((TMP_Text)_text).text = message; } } public static void Teardown() { if ((Object)(object)_canvasRoot != (Object)null) { Object.Destroy((Object)(object)_canvasRoot); } _canvasRoot = null; _panel = null; _text = null; } private static void Build() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0074: 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_0084: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: 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_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) _canvasRoot = UiSupport.CreateOverlayCanvas("SpongeMods_UpgradeCanvas", 5200); _panel = new GameObject("RodUpgradePanel", new Type[3] { typeof(RectTransform), typeof(Image), typeof(Outline) }); _panel.transform.SetParent(_canvasRoot.transform, false); RectTransform val = (RectTransform)_panel.transform; val.anchorMin = new Vector2(0.5f, 0f); val.anchorMax = new Vector2(0.5f, 0f); val.pivot = new Vector2(0.5f, 0f); val.anchoredPosition = new Vector2(0f, 185f); val.sizeDelta = new Vector2(800f, 150f); Image component = _panel.GetComponent(); ((Graphic)component).color = new Color(0.018f, 0.065f, 0.08f, 0.97f); ((Graphic)component).raycastTarget = false; Outline component2 = _panel.GetComponent(); ((Shadow)component2).effectColor = new Color(Cyan.r, Cyan.g, Cyan.b, 0.85f); ((Shadow)component2).effectDistance = new Vector2(3f, -3f); GameObject val2 = new GameObject("Accent", new Type[2] { typeof(RectTransform), typeof(Image) }); val2.transform.SetParent(_panel.transform, false); RectTransform val3 = (RectTransform)val2.transform; val3.anchorMin = new Vector2(0f, 1f); val3.anchorMax = new Vector2(1f, 1f); val3.pivot = new Vector2(0.5f, 1f); val3.anchoredPosition = Vector2.zero; val3.sizeDelta = new Vector2(0f, 5f); Image component3 = val2.GetComponent(); ((Graphic)component3).color = Cyan; ((Graphic)component3).raycastTarget = false; _text = Object.Instantiate(PlayerUI.CanvasTextPrefab, _panel.transform); ((Object)((Component)_text).gameObject).name = "UpgradeMessage"; RectTransform rectTransform = ((TMP_Text)_text).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = new Vector2(18f, 10f); rectTransform.offsetMax = new Vector2(-18f, -10f); ((TMP_Text)_text).fontSize = 19f; ((TMP_Text)_text).fontStyle = (FontStyles)1; ((TMP_Text)_text).alignment = (TextAlignmentOptions)514; ((Graphic)_text).color = Color.white; ((TMP_Text)_text).textWrappingMode = (TextWrappingModes)1; ((Graphic)_text).raycastTarget = false; } } internal struct RodTierUpdate : IBroadcast { public ulong OwnerSteamId; public int Tier; } internal struct RodTierPurchaseRequest : IBroadcast { public ulong OwnerSteamId; } internal sealed class RodReelTierState : MonoBehaviour { public float BaseSpeed; public int AppliedLevel = -1; } internal static class RodTierService { private sealed class BenchPlacement { public Vector3 Position; public float Yaw; } public const int MaxLevel = 25; private static readonly int[] Costs = new int[25] { 10, 35, 75, 175, 300, 1000, 2500, 4900, 10000, 17500, 39000, 85000, 175000, 405000, 900000, 2000000, 4500000, 10000000, 22000000, 50000000, 110000000, 250000000, 550000000, 1200000000, 2000000000 }; private static readonly int[] LuckGain = new int[25] { 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8 }; private static readonly int[] SaleGain = new int[25] { 0, 10, 10, 10, 15, 15, 15, 20, 20, 25, 25, 25, 30, 30, 35, 35, 40, 40, 45, 45, 50, 50, 60, 75, 100 }; private const float InteractionRange = 4.5f; private const float InteractionRangeSquared = 20.25f; private const float SyncInterval = 4f; private const float RodApplyInterval = 1f; private const float TableSearchInterval = 2f; private const float ReelSpeedPerLevel = 0.05f; private static readonly Dictionary Levels = new Dictionary(); private static readonly PropertyInfo SyncedCurItemProperty = AccessTools.Property(typeof(PlayerInventory), "SyncedCurItem"); private static readonly FieldInfo ReelSpeedField = AccessTools.Field(typeof(FishingRod), "_holdReelSpeed"); private static bool _personalWalletResolved; private static MethodInfo _personalWalletGet; private static MethodInfo _personalWalletRemove; private static ConfigEntry _savedLevels; private static ConfigEntry _savedPlacements; private static readonly Dictionary Placements = new Dictionary(); private static NetworkManager _registeredManager; private static int _islandId = int.MinValue; private static RodTierBench _table; private static float _nextAutomaticPlacementAttempt; private static float _nextTableSearch; private static float _nextSync; private static float _nextRodApply; private static float _interactionReadyTime; private static string _currentPlacementKey; public static void Initialize(ConfigFile config) { _savedLevels = config.Bind("Giant Catches", "RodUpgradeLevels", string.Empty, "Persistent fishing rod upgrade levels by Steam account. Managed by the mod."); _savedPlacements = config.Bind("Giant Catches", "RodUpgradeTablePlacements", string.Empty, "Saved workbench coordinates by saved game and island. Managed by the mod."); Load(); SpongeLoadPlacements(); GenericWriter.SetWrite((Action)delegate(Writer writer, RodTierUpdate value) { writer.WriteUInt64(value.OwnerSteamId); writer.WriteInt32(value.Tier); }); GenericReader.SetRead((Func)((Reader reader) => new RodTierUpdate { OwnerSteamId = reader.ReadUInt64(), Tier = reader.ReadInt32() })); GenericWriter.SetWrite((Action)delegate(Writer writer, RodTierPurchaseRequest value) { writer.WriteUInt64(value.OwnerSteamId); }); GenericReader.SetRead((Func)((Reader reader) => new RodTierPurchaseRequest { OwnerSteamId = reader.ReadUInt64() })); } public static void Tick() { RequireNetworkHandlers(); RequireTable(); Player player; bool nearby = AttemptGetNearbyPlayer(out player); OnLocalInteraction(nearby, player); SyncInteractionHud(nearby, player); if (Time.unscaledTime >= _nextSync) { SpongeSyncLocalLevel(); _nextSync = Time.unscaledTime + 4f; } if (Time.unscaledTime >= _nextRodApply) { SetReelSpeeds(); _nextRodApply = Time.unscaledTime + 1f; } } public static void Shutdown() { if ((Object)(object)_registeredManager != (Object)null) { TryUnregister(delegate { _registeredManager.ServerManager.UnregisterBroadcast((Action)SpongeOnServerSync); }); TryUnregister(delegate { _registeredManager.ServerManager.UnregisterBroadcast((Action)SpongeOnServerPurchase); }); TryUnregister(delegate { _registeredManager.ClientManager.UnregisterBroadcast((Action)SpongeOnClientSync); }); } if ((Object)(object)_table != (Object)null) { Object.Destroy((Object)(object)((Component)_table).gameObject); } _table = null; _registeredManager = null; RodTierHud.Teardown(); } private static void TryUnregister(Action action) { try { action(); } catch { } } public static int ObtainLevel(Player player) { if ((Object)(object)player == (Object)null) { return 0; } if (!Levels.TryGetValue(player.SteamID, out var value)) { return 0; } return Mathf.Clamp(value, 0, 25); } public static int ObtainLuck(Player player) { return SpongeSumThrough(LuckGain, ObtainLevel(player)); } public static int ObtainSaleBonus(Player player) { return SpongeSumThrough(SaleGain, ObtainLevel(player)); } public static float ObtainReelMultiplier(Player player) { return 1f + (float)ObtainLevel(player) * 0.05f; } public static Player ObtainCatcherForCreature(Creature creature) { FishScaleTracker fishScaleTracker = (((Object)(object)creature != (Object)null) ? ((Component)creature).GetComponent() : null); if ((Object)(object)fishScaleTracker == (Object)null) { return null; } Player val = fishScaleTracker.Catcher; if ((Object)(object)val == (Object)null && (Object)(object)fishScaleTracker.CatcherRod != (Object)null) { val = (((Object)(object)((Item)fishScaleTracker.CatcherRod).SyncedHolder != (Object)null) ? ((Item)fishScaleTracker.CatcherRod).SyncedHolder : ((Item)fishScaleTracker.CatcherRod).Holder); } return val; } public static int ObtainLuckForCreature(Creature creature) { return ObtainLuck(ObtainCatcherForCreature(creature)); } public static bool HasHoldingRod(Player player) { if ((Object)(object)player == (Object)null || (Object)(object)player.Inventory == (Object)null || SyncedCurItemProperty == null) { return false; } return SyncedCurItemProperty.GetValue(player.Inventory) is FishingRod; } public static int ObtainNextCost(Player player) { int num = ObtainLevel(player); if (num >= 25) { return 0; } return Costs[num]; } public static string ObtainUpgradeDescription(Player player) { int num = ObtainLevel(player); if (num >= 25) { return "ROD AT MAXIMUM LEVEL\n" + $"CURRENT - Luck {ObtainLuck(player)} - Reel +{num * 5}% - Sale +{ObtainSaleBonus(player)}%"; } string arg = (((Object)(object)MoneyManager.Instance != (Object)null && MoneyManager.CanAfford(Costs[num])) ? "Press [E] to upgrade" : $"NOT ENOUGH MONEY - You need ${Costs[num]:N0}"); return $"CURRENT - Level {num} - Luck {ObtainLuck(player)} - " + $"Reel +{num * 5}% - Sale +{ObtainSaleBonus(player)}%\n" + $"UPGRADE {num + 1} - ${Costs[num]:N0}\n" + $"+{LuckGain[num]} luck +5% reel +{SaleGain[num]}% sale\n{arg}"; } public static void AttemptPurchase(Player player) { if (!((Object)(object)player == (Object)null) && HasHoldingRod(player)) { if (InstanceFinder.IsServerStarted) { SpongePurchaseOnServer(player); } else if (InstanceFinder.IsClientStarted && (Object)(object)InstanceFinder.ClientManager != (Object)null) { InstanceFinder.ClientManager.Broadcast(new RodTierPurchaseRequest { OwnerSteamId = player.SteamID }, (Channel)0); } } } private static void RequireNetworkHandlers() { NetworkManager networkManager = InstanceFinder.NetworkManager; if ((Object)(object)networkManager == (Object)(object)_registeredManager) { return; } if ((Object)(object)_registeredManager != (Object)null) { TryUnregister(delegate { _registeredManager.ServerManager.UnregisterBroadcast((Action)SpongeOnServerSync); }); TryUnregister(delegate { _registeredManager.ServerManager.UnregisterBroadcast((Action)SpongeOnServerPurchase); }); TryUnregister(delegate { _registeredManager.ClientManager.UnregisterBroadcast((Action)SpongeOnClientSync); }); } _registeredManager = networkManager; if (!((Object)(object)networkManager == (Object)null)) { networkManager.ServerManager.RegisterBroadcast((Action)SpongeOnServerSync, true); networkManager.ServerManager.RegisterBroadcast((Action)SpongeOnServerPurchase, true); networkManager.ClientManager.RegisterBroadcast((Action)SpongeOnClientSync); } } private static void SpongeOnServerSync(NetworkConnection connection, RodTierUpdate message, Channel channel) { if (message.OwnerSteamId != 0L) { int num = Mathf.Clamp(message.Tier, 0, 25); int value; int num2 = (Levels.TryGetValue(message.OwnerSteamId, out value) ? value : 0); Levels[message.OwnerSteamId] = Mathf.Max(num2, num); } } private static void SpongeOnServerPurchase(NetworkConnection connection, RodTierPurchaseRequest message, Channel channel) { Player[] source = Object.FindObjectsByType(); Player val = ((IEnumerable)source).FirstOrDefault((Func)((Player candidate) => (Object)(object)candidate != (Object)null && ((NetworkBehaviour)candidate).Owner == connection)) ?? ((IEnumerable)source).FirstOrDefault((Func)((Player candidate) => (Object)(object)candidate != (Object)null && ((NetworkBehaviour)candidate).OwnerId == connection.ClientId)) ?? ((IEnumerable)source).FirstOrDefault((Func)((Player candidate) => (Object)(object)candidate != (Object)null && message.OwnerSteamId != 0L && candidate.SteamID == message.OwnerSteamId)); if ((Object)(object)val == (Object)null) { GiantCatchModule.Instance?.SpongeLogUpgradeRejection($"No player found for connection {connection.ClientId} (Steam {message.OwnerSteamId})."); } else if (message.OwnerSteamId != 0L && val.SteamID != 0L && val.SteamID != message.OwnerSteamId) { GiantCatchModule.Instance?.SpongeLogUpgradeRejection("The Steam identity received does not match " + val.SteamName + "."); } else { SpongePurchaseOnServer(val); } } private static void SpongePurchaseOnServer(Player player) { if ((Object)(object)player == (Object)null) { return; } if (!HasHoldingRod(player)) { GiantCatchModule.Instance?.SpongeLogUpgradeRejection(player.SteamName + " does not have a rod selected according to the server."); return; } int num = ObtainLevel(player); if (num >= 25) { return; } int num2 = Costs[num]; if (!AllowsPlayerAfford(player, num2)) { GiantCatchModule.Instance?.SpongeLogUpgradeRejection($"{player.SteamName} does not have ${num2:N0} for upgrade {num + 1}."); } else if (SpongeChargePlayer(player, num2)) { int num3 = num + 1; Levels[player.SteamID] = num3; Save(); GiantCatchModule.Instance?.SpongeLogUpgradePurchase(player, num2, num3); RodTierUpdate rodTierUpdate = new RodTierUpdate { OwnerSteamId = player.SteamID, Tier = num3 }; if ((Object)(object)InstanceFinder.ServerManager != (Object)null) { InstanceFinder.ServerManager.Broadcast(rodTierUpdate, true, (Channel)0); } SpongeOnClientSync(rodTierUpdate, (Channel)0); } } private static bool AllowsPlayerAfford(Player player, int cost) { LookupPersonalWallet(); if (_personalWalletGet != null) { try { return (int)_personalWalletGet.Invoke(null, new object[1] { player }) >= cost; } catch (Exception error) { GiantCatchModule.Instance?.SpongeLogUpgradeError("reading NoSharedMoney wallet", error); return false; } } if ((Object)(object)MoneyManager.Instance != (Object)null) { return MoneyManager.CanAfford(cost); } return false; } private static bool SpongeChargePlayer(Player player, int cost) { LookupPersonalWallet(); if (_personalWalletRemove != null) { try { _personalWalletRemove.Invoke(null, new object[2] { player, cost }); return true; } catch (Exception error) { GiantCatchModule.Instance?.SpongeLogUpgradeError("charging NoSharedMoney wallet", error); return false; } } if ((Object)(object)MoneyManager.Instance == (Object)null) { return false; } MoneyManager.RemoveMoney(cost, player); return true; } private static void LookupPersonalWallet() { if (_personalWalletResolved) { return; } _personalWalletResolved = true; Type type = Type.GetType("NoSharedMoney.Wallets, NoSharedMoney", throwOnError: false); if (!(type == null)) { _personalWalletGet = type.GetMethod("Get", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Player) }, null); _personalWalletRemove = type.GetMethod("Remove", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { typeof(Player), typeof(int) }, null); if (_personalWalletGet != null && _personalWalletRemove != null) { GiantCatchModule.Instance?.SpongeLogPersonalWalletCompatibility(); } } } private static void SpongeOnClientSync(RodTierUpdate message, Channel channel) { if (message.OwnerSteamId != 0L) { Levels[message.OwnerSteamId] = Mathf.Clamp(message.Tier, 0, 25); if ((Object)(object)Player.LocalPlayer != (Object)null && Player.LocalPlayer.SteamID == message.OwnerSteamId) { Save(); } } } private static void SpongeSyncLocalLevel() { Player localPlayer = Player.LocalPlayer; if (!((Object)(object)localPlayer == (Object)null) && localPlayer.SteamID != 0L) { RodTierUpdate rodTierUpdate = new RodTierUpdate { OwnerSteamId = localPlayer.SteamID, Tier = ObtainLevel(localPlayer) }; if (InstanceFinder.IsServerStarted) { Levels[rodTierUpdate.OwnerSteamId] = rodTierUpdate.Tier; } else if (InstanceFinder.IsClientStarted && (Object)(object)InstanceFinder.ClientManager != (Object)null) { InstanceFinder.ClientManager.Broadcast(rodTierUpdate, (Channel)0); } } } private static void RequireTable() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.LocalPlayer; Island curIsland = Island.CurIsland; if ((Object)(object)localPlayer == (Object)null || (Object)(object)curIsland == (Object)null) { return; } int num = ((Object)curIsland).name.GetHashCode() ^ ((object)((Component)curIsland).transform.position/*cast due to .constrained prefix*/).GetHashCode(); if (num != _islandId) { if ((Object)(object)_table != (Object)null) { Object.Destroy((Object)(object)((Component)_table).gameObject); } _table = null; _islandId = num; _currentPlacementKey = ComposePlacementKey(curIsland); BenchPlacement placement; if (Placements.TryGetValue(_currentPlacementKey, out var value)) { _table = RodTierBench.Create(value.Position, value.Yaw); } else if (AttemptGetBuiltInPlacement(curIsland, out placement)) { _table = RodTierBench.Create(placement.Position, placement.Yaw); } } if (!((Object)(object)_table != (Object)null) && !(Time.unscaledTime < _nextAutomaticPlacementAttempt)) { _nextAutomaticPlacementAttempt = Time.unscaledTime + 1f; if (AttemptFindAutomaticPlacement(localPlayer, out var placement2)) { Placements[_currentPlacementKey] = placement2; SpongeSavePlacements(); _table = RodTierBench.Create(placement2.Position, placement2.Yaw); _interactionReadyTime = Time.unscaledTime + 0.4f; } } } private static void OnLocalInteraction(bool nearby, Player player) { if (nearby && !(Time.unscaledTime < _interactionReadyTime) && Keyboard.current != null && ((ButtonControl)Keyboard.current.eKey).wasPressedThisFrame) { AttemptPurchase(player); } } private static void SyncInteractionHud(bool nearby, Player player) { if (!nearby) { RodTierHud.AssignVisible(visible: false, string.Empty); return; } string message = (HasHoldingRod(player) ? ObtainUpgradeDescription(player) : "ROD UPGRADE BENCH\nEquip a fishing rod or a crab rod"); RodTierHud.AssignVisible(visible: true, message); } private static bool AttemptGetNearbyPlayer(out Player player) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0074: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00a9: Unknown result type (might be due to invalid IL or missing references) player = Player.LocalPlayer; if ((Object)(object)player == (Object)null) { return false; } if ((Object)(object)_table == (Object)null) { if (Time.unscaledTime < _nextTableSearch) { return false; } _nextTableSearch = Time.unscaledTime + 2f; _table = Object.FindAnyObjectByType(); if ((Object)(object)_table == (Object)null) { return false; } } Vector3 position = ((Component)_table).transform.position; Vector3 val = ((Component)player).transform.position - position; float num = ((Vector3)(ref val)).sqrMagnitude; if ((Object)(object)player.CurCam != (Object)null) { float num2 = num; val = ((Component)player.CurCam).transform.position - position; num = Mathf.Min(num2, ((Vector3)(ref val)).sqrMagnitude); } return num <= 20.25f; } private static bool AttemptFindAutomaticPlacement(Player player, out BenchPlacement placement) { //IL_0106: 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_0125: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //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_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_01f5: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0322: 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_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) placement = null; Transform anchor = (from box in Object.FindObjectsByType() where (Object)(object)box != (Object)null && ((Component)box).gameObject.activeInHierarchy orderby SpongeHorizontalSqrDistance(((Component)box).transform.position, ((Component)player).transform.position) select ((Component)box).transform).FirstOrDefault(); if ((Object)(object)anchor == (Object)null) { anchor = (from npc in Object.FindObjectsByType() where (Object)(object)npc != (Object)null && ((Component)npc).gameObject.activeInHierarchy orderby SpongeHorizontalSqrDistance(((Component)npc).transform.position, ((Component)player).transform.position) select ((Component)npc).transform).FirstOrDefault(); } if ((Object)(object)anchor == (Object)null) { return false; } Vector3 right = anchor.right; right.y = 0f; ((Vector3)(ref right)).Normalize(); Vector3 forward = anchor.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); if (((Vector3)(ref right)).sqrMagnitude < 0.5f) { right = Vector3.right; } if (((Vector3)(ref forward)).sqrMagnitude < 0.5f) { forward = Vector3.forward; } Vector3[] obj = new Vector3[8] { right * 3.6f, -right * 3.6f, -forward * 3.8f, default(Vector3), default(Vector3), default(Vector3), default(Vector3), default(Vector3) }; Vector3 val = right - forward; obj[3] = ((Vector3)(ref val)).normalized * 4.2f; val = -right - forward; obj[4] = ((Vector3)(ref val)).normalized * 4.2f; obj[5] = forward * 4.5f; obj[6] = right * 5.2f; obj[7] = -right * 5.2f; int num = int.MaxValue; Vector3 val2 = default(Vector3); bool flag = false; Vector3[] array = (Vector3[])(object)obj; RaycastHit hit = default(RaycastHit); foreach (Vector3 val3 in array) { if (!Physics.Raycast(anchor.position + val3 + Vector3.up * 12f, Vector3.down, ref hit, 30f, -5, (QueryTriggerInteraction)1)) { continue; } string text = (((Object)(object)((RaycastHit)(ref hit)).collider != (Object)null) ? ((Object)((Component)((RaycastHit)(ref hit)).collider).gameObject).name.ToLowerInvariant() : string.Empty); if (text.Contains("water") || text.Contains("ocean") || text.Contains("sea")) { continue; } Vector3 point = ((RaycastHit)(ref hit)).point; int num3 = Physics.OverlapBox(point + Vector3.up * 0.68f, new Vector3(1.55f, 0.52f, 0.82f), Quaternion.identity, -5, (QueryTriggerInteraction)1).Count((Collider collider) => (Object)(object)collider != (Object)null && (Object)(object)collider != (Object)(object)((RaycastHit)(ref hit)).collider && !((Component)collider).transform.IsChildOf(anchor) && !anchor.IsChildOf(((Component)collider).transform)); if (num3 < num) { num = num3; val2 = point; flag = true; if (num3 == 0) { break; } } } if (!flag) { return false; } Vector3 val4 = anchor.position - val2; val4.y = 0f; float y; if (!(((Vector3)(ref val4)).sqrMagnitude > 0.01f)) { y = anchor.eulerAngles.y; } else { Quaternion val5 = Quaternion.LookRotation(val4); y = ((Quaternion)(ref val5)).eulerAngles.y; } float yaw = y; placement = new BenchPlacement { Position = val2, Yaw = yaw }; return true; } private static float SpongeHorizontalSqrDistance(Vector3 first, Vector3 second) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) float num = first.x - second.x; float num2 = first.z - second.z; return num * num + num2 * num2; } private static string ComposePlacementKey(Island island) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) string text = ((SaveManager.CurServerSave != null) ? SaveManager.CurServerSave.Name : "Current game"); Vector3 position = ((Component)island).transform.position; return text + "|" + ((Object)island).name + "|" + position.x.ToString("0.0", CultureInfo.InvariantCulture) + "|" + position.z.ToString("0.0", CultureInfo.InvariantCulture); } private static bool AttemptGetBuiltInPlacement(Island island, out BenchPlacement placement) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)island).transform.position; if (Mathf.Abs(position.x - -200f) <= 2f && Mathf.Abs(position.z - 600f) <= 2f) { placement = new BenchPlacement { Position = new Vector3(-191.137f, 0.075f, 601.352f), Yaw = 180f }; return true; } placement = null; return false; } private static void SetReelSpeeds() { if (ReelSpeedField == null) { return; } FishingRod[] array = Object.FindObjectsByType(); foreach (FishingRod val in array) { Player player = (((Object)(object)((Item)val).SyncedHolder != (Object)null) ? ((Item)val).SyncedHolder : ((Item)val).Holder); RodReelTierState rodReelTierState = ((Component)val).GetComponent(); if ((Object)(object)rodReelTierState == (Object)null) { rodReelTierState = ((Component)val).gameObject.AddComponent(); rodReelTierState.BaseSpeed = (float)ReelSpeedField.GetValue(val); } int num = ObtainLevel(player); if (rodReelTierState.AppliedLevel != num) { ReelSpeedField.SetValue(val, rodReelTierState.BaseSpeed * (1f + (float)num * 0.05f)); rodReelTierState.AppliedLevel = num; } } } private static int SpongeSumThrough(int[] values, int level) { int num = 0; for (int i = 0; i < Mathf.Min(level, values.Length); i++) { num += values[i]; } return num; } private static void Load() { Levels.Clear(); if (_savedLevels == null || string.IsNullOrWhiteSpace(_savedLevels.Value)) { return; } string[] array = _savedLevels.Value.Split(';'); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(':'); if (array2.Length == 2 && ulong.TryParse(array2[0], out var result) && int.TryParse(array2[1], out var result2)) { Levels[result] = Mathf.Clamp(result2, 0, 25); } } } private static void Save() { if (_savedLevels != null) { _savedLevels.Value = string.Join(";", Levels.Select((KeyValuePair pair) => pair.Key.ToString(CultureInfo.InvariantCulture) + ":" + pair.Value.ToString(CultureInfo.InvariantCulture))); } } private static void SpongeLoadPlacements() { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) Placements.Clear(); if (_savedPlacements == null || string.IsNullOrWhiteSpace(_savedPlacements.Value)) { return; } string[] array = _savedPlacements.Value.Split(';'); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(','); if (array2.Length != 5) { continue; } try { string key = Encoding.UTF8.GetString(Convert.FromBase64String(array2[0])); if (float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array2[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array2[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3) && float.TryParse(array2[4], NumberStyles.Float, CultureInfo.InvariantCulture, out var result4)) { Placements[key] = new BenchPlacement { Position = new Vector3(result, result2, result3), Yaw = result4 }; } } catch (FormatException) { } } } private static void SpongeSavePlacements() { if (_savedPlacements != null) { _savedPlacements.Value = string.Join(";", Placements.Select((KeyValuePair pair) => Convert.ToBase64String(Encoding.UTF8.GetBytes(pair.Key)) + "," + pair.Value.Position.x.ToString("0.000", CultureInfo.InvariantCulture) + "," + pair.Value.Position.y.ToString("0.000", CultureInfo.InvariantCulture) + "," + pair.Value.Position.z.ToString("0.000", CultureInfo.InvariantCulture) + "," + pair.Value.Yaw.ToString("0.0", CultureInfo.InvariantCulture))); } } } internal static class RodSaleBonusService { [ThreadStatic] private static int _bonusPercent; public static void Begin(Player seller) { _bonusPercent = RodTierService.ObtainSaleBonus(seller); } public static void End() { _bonusPercent = 0; } public static int Apply(int original) { if (_bonusPercent <= 0 || original <= 0) { return original; } double value = (double)original * (1.0 + (double)_bonusPercent / 100.0); return (int)Math.Min(2147483647.0, Math.Round(value, MidpointRounding.AwayFromZero)); } } internal sealed class FishScaleTracker : MonoBehaviour { public Vector3 OriginalScale; public bool LoadedFromSave; public bool WasHooked; public FishingRod CatcherRod; public Player Catcher; public string AnglerName; public bool NotificationShown; public bool RankingSubmitted; public string RankingEntryId; public bool RankingAnnouncementSent; public bool LuckRollApplied; public bool BossHealthInitialized; private Creature _creature; private bool? _isScalable; private const float ScaleEpsilon = 1E-06f; internal void InvalidateScalableCache() { _isScalable = null; } 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(); OriginalScale = ((Component)this).transform.localScale; } private void LateUpdate() { //IL_004e: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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) if ((Object)(object)_creature == (Object)null) { return; } if (!_isScalable.HasValue || !_isScalable.Value) { _isScalable = FishSizeService.HasScalableCatch(_creature); } if (_isScalable.Value) { Vector3 val = OriginalScale * FishSizeService.ObtainSize(_creature); Vector3 val2 = ((Component)this).transform.localScale - val; if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f) { ((Component)this).transform.localScale = val; } } } } public static class SizeCurve { public const float MinimumSize = 1f; public const float MaximumSize = 25f; private const double ProbabilityEpsilon = 1E-09; private static readonly double[] TailPercent = new double[5] { 30.0, 12.0, 1.0, 0.03, 0.0007 }; private static readonly double[] Size = new double[5] { 1.01, 1.34, 2.0, 7.0, 25.0 }; public static float Roll(int networkObjectId, int luck = 0) { return SpongeFromUnitRoll(new Random((networkObjectId * 397) ^ Environment.TickCount).NextDouble(), luck); } public static float SpongeFromUnitRoll(double roll, int luck = 0) { if (roll < 0.0 || roll >= 1.0) { throw new ArgumentOutOfRangeException("roll"); } luck = Math.Max(0, luck); double num = Math.Max(0.05, 0.7 - (double)luck * 0.03); if (roll < num) { return 1f; } double num2 = (1.0 - num) / 0.3; double num3 = (1.0 - roll) * 100.0; double[] array = new double[5] { TailPercent[0] * num2, Math.Min(29.99 * num2, TailPercent[1] * (1.0 + (double)luck * 0.12)), TailPercent[2] * (1.0 + (double)luck * 0.25), TailPercent[3] * (1.0 + (double)luck * 0.9), TailPercent[4] * (1.0 + (double)luck * 1.2) }; if (num3 <= array[^1] + 1E-09) { return 25f; } for (int i = 0; i < array.Length - 1; i++) { double num4 = array[i]; double num5 = array[i + 1]; if (!(num3 > num4 + 1E-09) && !(num3 <= num5 + 1E-09)) { double num6 = (Math.Log(num4) - Math.Log(num3)) / (Math.Log(num4) - Math.Log(num5)); return SpongeRoundInsideBand(Size[i] + (Size[i + 1] - Size[i]) * num6, Size[i], Size[i + 1] - 0.01); } } return 1f; } private static float SpongeRoundInsideBand(double value, double minimum, double maximum) { value = Math.Max(minimum, Math.Min(maximum, value)); return (float)Math.Round(value, 2, MidpointRounding.AwayFromZero); } } } namespace SpongeMods.SpongeTweaks.Persistence { internal static class BackupBrowser { private const float StarWidth = 26f; private const float TakenWidth = 116f; private const float NameWidth = 150f; private const float IslandWidth = 56f; private const float MoneyWidth = 74f; private const float PlayedWidth = 82f; private const float ModsWidth = 52f; private const float ActionsWidth = 112f; private static bool _failed; private static bool _built; private static ButtonManager _buttons; private static GameObject _infoHolder; private static Transform _screenParent; private static GameObject _buttonTemplate; private static GameObject _labelTemplate; private static GameObject _openButton; private static GameObject _panel; private static TMP_InputField _inputTemplate; private static Transform _content; private static TextMeshProUGUI _status; private static TextMeshProUGUI _pageLabel; private static string _selectedSave; private static bool _refreshing; private static int _page; private static string _armedPath; private static string _armedCompanion; public static void SpongeOnSaveSelected(string saveName) { if (_refreshing) { return; } _selectedSave = saveName; _page = 0; if (_failed) { return; } try { if (RequireBuilt()) { _openButton.SetActive(!string.IsNullOrEmpty(saveName)); Close(); } } catch (Exception ex) { _failed = true; CompendiumPlugin.Log.LogError((object)("Backup UI failed, falling back to no UI: " + ex)); } } public static void Close() { if (!_refreshing) { _armedPath = null; if ((Object)(object)_panel != (Object)null) { _panel.SetActive(false); } if ((Object)(object)_infoHolder != (Object)null && !string.IsNullOrEmpty(_selectedSave) && SaveManager.CurServerSave != null) { _infoHolder.SetActive(true); } } } public static void Tick() { if (!((Object)(object)_panel == (Object)null) && _panel.activeSelf && ((Object)(object)_infoHolder == (Object)null || !((Component)_infoHolder.transform.parent).gameObject.activeInHierarchy)) { Close(); } } public static void SpongeOnListRefreshed() { if (!_refreshing) { if (SaveManager.CurServerSave == null) { _selectedSave = null; } Close(); } } private static bool RequireBuilt() { if (_built && (Object)(object)_openButton != (Object)null && (Object)(object)_panel != (Object)null) { return true; } _buttons = Object.FindAnyObjectByType(); if ((Object)(object)_buttons == (Object)null) { return false; } object? obj = AccessTools.Field(typeof(ButtonManager), "_selectedSaveInfoHolder")?.GetValue(_buttons); _infoHolder = (GameObject)((obj is GameObject) ? obj : null); if ((Object)(object)_infoHolder == (Object)null) { CompendiumPlugin.Log.LogError((object)"Could not find the save info panel in the load game screen."); _failed = true; return false; } _screenParent = _infoHolder.transform.parent; _buttonTemplate = LocateButtonTemplate(((Object)(object)_screenParent != (Object)null) ? _screenParent : _infoHolder.transform); if ((Object)(object)_buttonTemplate == (Object)null) { CompendiumPlugin.Log.LogError((object)"Could not find a menu button to copy the style from."); _failed = true; return false; } TextMeshProUGUI componentInChildren = _buttonTemplate.GetComponentInChildren(true); _labelTemplate = (((Object)(object)componentInChildren != (Object)null) ? ((Component)componentInChildren).gameObject : null); _openButton = SpongeCloneButton(_infoHolder.transform, "Backups", Open); SpongePlaceOpenButton(); _panel = ComposePanel(); _built = true; CompendiumPlugin.Log.LogInfo((object)"Backups button added to the load game screen."); return true; } private static void SpongePlaceOpenButton() { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Transform val = null; Button[] componentsInChildren = _infoHolder.GetComponentsInChildren