Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of BetterItemScan v3.0.2
BetterItemScan.dll
Decompiled 2 years agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("BetterItemScan")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BetterItemScan")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("04cd6816-7aba-4c14-a9a7-bf328df25692")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace BetterItemScan { [BepInPlugin("PopleZoo.BetterItemScan", "Better Item Scan", "3.0.0.2")] public class BetterItemScanModBase : BaseUnityPlugin { private const string modGUID = "PopleZoo.BetterItemScan"; private const string modName = "Better Item Scan"; private const string modVersion = "3.0.0.2"; private readonly Harmony harmony = new Harmony("PopleZoo.BetterItemScan"); public static BetterItemScanModBase Instance; public ManualLogSource mls; public static ConfigEntry<float> ItemScanRadius; public static ConfigEntry<float> AdjustScreenPositionXaxis; public static ConfigEntry<float> AdjustScreenPositionYaxis; public static ConfigEntry<float> ItemScaningUICooldown; public static ConfigEntry<float> FontSize; public static ConfigEntry<bool> ShowDebugMode; public static ConfigEntry<bool> ShowShipTotalOnShipOnly; public static ConfigEntry<bool> ShowTotalOnShipOnly; public static ConfigEntry<bool> CalculateForQuota; public static ConfigEntry<string> ItemTextColorHex; public static ConfigEntry<string> ItemTextCalculatorColorHex; public static ConfigEntry<bool> logAllScannedItems; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("PopleZoo.BetterItemScan"); mls.LogInfo((object)"Plugin BetterItemScan is loaded!"); LoadConfigs(); harmony.PatchAll(); } private void LoadConfigs() { ShowDebugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShowDebugMode", false, "Shows the change in width of the area to scan"); ShowShipTotalOnShipOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShowShipTotalOnShipOnly", false, "Whether or not to show the ship's total only in the ship"); ShowTotalOnShipOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShowTotalOnShipOnly", false, "Whether or not to show the total scanned in the ship only"); CalculateForQuota = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "CalculateForQuota", true, "Whether or not to calculate scanned items to see which meet the quota and if any do"); logAllScannedItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "logAllScannedItems", true, "outputs all scanned items and prices in the console"); ItemScanRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "ItemScanRadius", 20f, "The default width is 20"); FontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "FontSize", 20f, "The default font size is 20, to make/see this change you may have to do this manually in the config file itself in the bepinex folder"); ItemTextColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "ItemTextColorHex", "#78FFAE", "The default text color for items that have been scanned, value must be a hexadecimal"); ItemTextCalculatorColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "ItemTextCalculatorColorHex", "#FF3333", "The default text color for items that meet the criteria, value must be a hexadecimal"); ItemScaningUICooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "ItemScaningUICooldown", 3f, "The default value is 5f, how long the ui stays on screen"); AdjustScreenPositionXaxis = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "AdjustScreenPositionXaxis", 0f, "The default value is 0, you will add or take away from its original position"); AdjustScreenPositionYaxis = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "AdjustScreenPositionYaxis", 0f, "The default value is 0, you will add or take away from its original position"); } } } namespace BetterItemScan.Patches { [HarmonyPatch] internal class HudManagerPatch_UI { private static GameObject _totalCounter; private static TextMeshProUGUI _textMesh; private static float _displayTimeLeft = BetterItemScanModBase.ItemScaningUICooldown.Value; private static float Totalsum = 0f; private static float Totalship = 0f; public static List<ScanNodeProperties> scannedNodeObjects = new List<ScanNodeProperties>(); public static Dictionary<string, (float, int)> meetQuotaItemNames = new Dictionary<string, (float, int)>(); public static Dictionary<string, (float, int)> NotmeetQuotaItemNames = new Dictionary<string, (float, int)>(); public static Dictionary<ScanNodeProperties, int> ItemsDictionary = new Dictionary<ScanNodeProperties, int>(); private static List<ScanNodeProperties> items; private static MethodInfo methodInfo; [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "Awake")] private static void OnStart(HUDManager __instance) { methodInfo = typeof(HUDManager).GetMethod("CanPlayerScan", BindingFlags.Instance | BindingFlags.NonPublic); } public static int MeetQuota(List<int> items, int quota) { items = items.Where((int item) => item >= quota).ToList(); if (!items.Any()) { return -1; } return items.Aggregate((int a, int b) => (Math.Abs(quota - a) < Math.Abs(quota - b)) ? a : b); } public static List<List<int>> FindCombinations(List<int> items, int quota) { List<List<int>> list = new List<List<int>>(); int count = items.Count; int num = int.MaxValue; for (int i = 0; i < 1 << count; i++) { List<int> list2 = new List<int>(); for (int j = 0; j < count; j++) { if ((i & (1 << j)) > 0) { list2.Add(items[j]); } } int num2 = list2.Sum(); int num3 = Math.Abs(quota - num2); if (num3 < num) { num = num3; list.Clear(); list.Add(list2); } else if (num3 == num) { list.Add(list2); } } list.Sort((List<int> a, List<int> b) => a.Count.CompareTo(b.Count)); return list; } private static bool IsHexColor(string value) { string pattern = "^#(?:[0-9a-fA-F]{3}){1,2}$"; return Regex.IsMatch(value, pattern); } [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "PingScan_performed")] private static void OnScan(HUDManager __instance, CallbackContext context) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown FieldInfo field = typeof(HUDManager).GetField("playerPingingScan", BindingFlags.Instance | BindingFlags.NonPublic); float num = (float)field.GetValue(__instance); ItemsDictionary.Clear(); if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || !((CallbackContext)(ref context)).performed || !(bool)methodInfo.Invoke(__instance, null) || (double)num > -1.0) { return; } if (!Object.op_Implicit((Object)(object)_totalCounter)) { CopyValueCounter(); } if (!Object.op_Implicit((Object)(object)_textMesh)) { _textMesh = new TextMeshProUGUI(); } if (!Object.op_Implicit((Object)(object)_totalCounter) || !Object.op_Implicit((Object)(object)_textMesh)) { BetterItemScanModBase.Instance.mls.LogError((object)"Failed to find or instantiate UI objects!"); return; } meetQuotaItemNames.Clear(); NotmeetQuotaItemNames.Clear(); items = CalculateLootItems(); foreach (ScanNodeProperties item in items) { ItemsDictionary.Add(item, item.scrapValue); } int num2 = TimeOfDay.Instance.profitQuota - TimeOfDay.Instance.quotaFulfilled; List<int> list = ItemsDictionary.Values.ToList(); list.Sort(); list.Reverse(); int bestIndividualItem = MeetQuota(list, num2); List<List<int>> source = FindCombinations(list, num2); if (source.Any()) { int num3 = source.First().Sum(); if (Math.Abs(num2 - bestIndividualItem) <= Math.Abs(num2 - num3)) { if (bestIndividualItem != -1) { ScanNodeProperties key = ItemsDictionary.FirstOrDefault((KeyValuePair<ScanNodeProperties, int> x) => x.Value == bestIndividualItem).Key; if ((Object)(object)key != (Object)null) { if (!meetQuotaItemNames.ContainsKey(key.headerText)) { meetQuotaItemNames.Add(key.headerText, (key.scrapValue, 1)); } else { (float, int) tuple = meetQuotaItemNames[key.headerText]; meetQuotaItemNames[key.headerText] = (tuple.Item1 + (float)key.scrapValue, tuple.Item2 + 1); items.Remove(key); } } } } else { foreach (int combination in source.First()) { ScanNodeProperties key2 = ItemsDictionary.FirstOrDefault((KeyValuePair<ScanNodeProperties, int> x) => x.Value == combination).Key; if ((Object)(object)key2 != (Object)null) { if (!meetQuotaItemNames.ContainsKey(key2.headerText)) { meetQuotaItemNames.Add(key2.headerText, (key2.scrapValue, 1)); continue; } (float, int) tuple2 = meetQuotaItemNames[key2.headerText]; meetQuotaItemNames[key2.headerText] = (tuple2.Item1 + (float)key2.scrapValue, tuple2.Item2 + 1); items.Remove(key2); } } } } foreach (KeyValuePair<ScanNodeProperties, int> item2 in ItemsDictionary) { if (!NotmeetQuotaItemNames.ContainsKey(item2.Key.headerText)) { NotmeetQuotaItemNames.Add(item2.Key.headerText, (item2.Key.scrapValue, 1)); continue; } (float, int) tuple3 = NotmeetQuotaItemNames[item2.Key.headerText]; NotmeetQuotaItemNames[item2.Key.headerText] = (tuple3.Item1 + (float)item2.Key.scrapValue, tuple3.Item2 + 1); items.Remove(item2.Key); } ItemsDictionary.Clear(); string text = ""; string text2 = ""; foreach (ScanNodeProperties item3 in items) { if (meetQuotaItemNames.ContainsKey(item3.headerText)) { if (meetQuotaItemNames.TryGetValue(item3.headerText, out var value)) { text2 = $"{value.Item2}-{item3.headerText}: ${value.Item1}"; } if (BetterItemScanModBase.CalculateForQuota.Value) { if (IsHexColor(BetterItemScanModBase.ItemTextCalculatorColorHex.Value)) { text2 = "<color=" + BetterItemScanModBase.ItemTextCalculatorColorHex.Value + ">* " + text2 + "</color>"; } else { Debug.LogError((object)(BetterItemScanModBase.ItemTextCalculatorColorHex.Value + " is an invalid colour. Please remember the '#'")); text2 = "<color=#FF3333>* " + text2 + "</color>"; } } else if (IsHexColor(BetterItemScanModBase.ItemTextColorHex.Value)) { text2 = "<color=" + BetterItemScanModBase.ItemTextColorHex.Value + ">" + text2 + "</color>"; } else { Debug.LogError((object)(BetterItemScanModBase.ItemTextColorHex.Value + " is an invalid colour. Please remember the '#'")); text2 = "<color=#FF3333>* " + text2 + "</color>"; } } else if (NotmeetQuotaItemNames.ContainsKey(item3.headerText)) { if (NotmeetQuotaItemNames.TryGetValue(item3.headerText, out var value2)) { text2 = $"{value2.Item2}-{item3.headerText}: ${value2.Item1}"; } if (IsHexColor(BetterItemScanModBase.ItemTextColorHex.Value)) { text2 = "<color=" + BetterItemScanModBase.ItemTextColorHex.Value + ">" + text2 + "</color>"; } else { Debug.LogError((object)(BetterItemScanModBase.ItemTextColorHex.Value + " is an invalid colour. Please remember the '#'")); text2 = "<color=#FF3333>* " + text2 + "</color>"; } } text = text + text2 + "\n"; } ((TMP_Text)_textMesh).text = text; if (BetterItemScanModBase.ShowShipTotalOnShipOnly.Value) { if (!GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom) { TextMeshProUGUI textMesh = _textMesh; ((TMP_Text)textMesh).text = ((TMP_Text)textMesh).text + "\nTotal Scanned: " + Totalsum; } else { TextMeshProUGUI textMesh2 = _textMesh; ((TMP_Text)textMesh2).text = ((TMP_Text)textMesh2).text + "\nTotal Scanned: " + Totalsum + "\nShip Total: " + Totalship; } } else { TextMeshProUGUI textMesh2 = _textMesh; ((TMP_Text)textMesh2).text = ((TMP_Text)textMesh2).text + "\nTotal Scanned: " + Totalsum + "\nShip Total: " + Totalship; } if (BetterItemScanModBase.ShowTotalOnShipOnly.Value) { if (!GameNetworkManager.Instance.localPlayerController.isInHangarShipRoom) { ((Component)_textMesh).gameObject.SetActive(false); ((Component)((TMP_Text)__instance.totalValueText).transform.parent).gameObject.SetActive(true); } else { ((Component)_textMesh).gameObject.SetActive(true); ((Component)((TMP_Text)__instance.totalValueText).transform.parent).gameObject.SetActive(false); } } if (BetterItemScanModBase.logAllScannedItems.Value) { Debug.Log((object)"''''"); Debug.Log((object)("BetterItemScan - log of all items scanned\n" + ((TMP_Text)_textMesh).text)); Debug.Log((object)"''''"); } _displayTimeLeft = BetterItemScanModBase.ItemScaningUICooldown.Value; if (!_totalCounter.activeSelf) { ((MonoBehaviour)GameNetworkManager.Instance).StartCoroutine(ValueCoroutine()); } } private static List<ScanNodeProperties> CalculateLootItems() { List<GrabbableObject> source = GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>().Where(delegate(GrabbableObject obj) { if (((Object)obj).name == "ClipboardManual" || ((Object)obj).name == "StickyNoteItem") { return false; } if (((Object)obj).name == "GiftBoxItem") { GiftBoxItem component = ((Component)obj).GetComponent<GiftBoxItem>(); if ((Object)(object)component != (Object)null) { FieldInfo field = typeof(GiftBoxItem).GetField("hasUsedGift", BindingFlags.Instance | BindingFlags.NonPublic); bool flag = (bool)field.GetValue(component); return !flag; } } return true; }) .ToList(); List<ScanNodeProperties> list = scannedNodeObjects.Where((ScanNodeProperties obj) => obj.headerText != "ClipboardManual" && obj.headerText != "StickyNoteItem" && obj.scrapValue != 0).ToList(); Totalsum = list.Sum((ScanNodeProperties scrap) => scrap.scrapValue); Totalship = source.Sum((GrabbableObject scrap) => scrap.scrapValue); return list; } private static IEnumerator ValueCoroutine() { _totalCounter.SetActive(true); while ((double)_displayTimeLeft > 0.0) { float displayTimeLeft = _displayTimeLeft; _displayTimeLeft = 0f; Debug.Log((object)$"Waiting for {displayTimeLeft} seconds..."); yield return (object)new WaitForSeconds(displayTimeLeft); } _totalCounter.SetActive(false); Debug.Log((object)"Cooldown complete. Hiding UI."); } private static void CopyValueCounter() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00be: 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_0149: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.Find("/Systems/UI/Canvas/IngamePlayerHUD/BottomMiddle/ValueCounter"); if (!Object.op_Implicit((Object)(object)val)) { BetterItemScanModBase.Instance.mls.LogError((object)"Failed to find ValueCounter object to copy!"); } _totalCounter = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent, false); Vector3 localPosition = _totalCounter.transform.localPosition; float num = Mathf.Clamp(localPosition.x + BetterItemScanModBase.AdjustScreenPositionXaxis.Value + 50f, -6000f, (float)Screen.width); float num2 = Mathf.Clamp(localPosition.y + BetterItemScanModBase.AdjustScreenPositionYaxis.Value - 80f, -6000f, (float)Screen.height); _totalCounter.transform.localPosition = new Vector3(num, num2, localPosition.z); _textMesh = _totalCounter.GetComponentInChildren<TextMeshProUGUI>(); ((TMP_Text)_textMesh).fontSizeMin = 5f; ((TMP_Text)_textMesh).fontSize = BetterItemScanModBase.FontSize.Value; ((TMP_Text)_textMesh).ForceMeshUpdate(false, false); ((TMP_Text)_textMesh).alignment = (TextAlignmentOptions)1025; RectTransform rectTransform = ((TMP_Text)_textMesh).rectTransform; rectTransform.anchorMin = new Vector2(0.5f, 2f); rectTransform.anchorMax = new Vector2(0.5f, 2f); rectTransform.pivot = new Vector2(0.5f, 0f); Vector3 localPosition2 = ((Transform)rectTransform).localPosition; ((Transform)rectTransform).localPosition = new Vector3(localPosition2.x, localPosition2.y - 140f, localPosition2.z); } } [HarmonyPatch] public class PlayerControllerBPatch_A { private static LineRenderer lineRenderer; private static GameObject lineObject; private static float maxDistance = 80f; private static MethodInfo methodInfo; [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "Awake")] private static void AssignNewNodes_methodFetcher(HUDManager __instance) { methodInfo = typeof(HUDManager).GetMethod("AttemptScanNode", BindingFlags.Instance | BindingFlags.NonPublic); } [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "AssignNewNodes")] private static bool AssignNewNodes_patch(HUDManager __instance, PlayerControllerB playerScript) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019a: 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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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_01e0: Unknown result type (might be due to invalid IL or missing references) HudManagerPatch_UI.scannedNodeObjects.Clear(); if ((Object)(object)lineRenderer == (Object)null) { lineObject = new GameObject("LineObject"); lineRenderer = lineObject.AddComponent<LineRenderer>(); lineRenderer.positionCount = 2; lineObject.SetActive(false); } FieldInfo field = typeof(HUDManager).GetField("nodesOnScreen", BindingFlags.Instance | BindingFlags.NonPublic); List<ScanNodeProperties> list = field.GetValue(__instance) as List<ScanNodeProperties>; FieldInfo field2 = typeof(HUDManager).GetField("scannedScrapNum", BindingFlags.Instance | BindingFlags.NonPublic); object value = field2.GetValue(__instance); FieldInfo field3 = typeof(HUDManager).GetField("scanNodesHit", BindingFlags.Instance | BindingFlags.NonPublic); RaycastHit[] array = field3.GetValue(__instance) as RaycastHit[]; int num = Physics.SphereCastNonAlloc(new Ray(((Component)playerScript.gameplayCamera).transform.position + ((Component)playerScript.gameplayCamera).transform.forward * 20f, ((Component)playerScript.gameplayCamera).transform.forward), BetterItemScanModBase.ItemScanRadius.Value, array, maxDistance, LayerMask.GetMask(new string[1] { "ScanNode" })); Vector3 val = new Vector3(((Component)playerScript.gameplayCamera).transform.position.x, ((Component)playerScript.gameplayCamera).transform.position.y - 2f, ((Component)playerScript.gameplayCamera).transform.position.z) + ((Component)playerScript.gameplayCamera).transform.forward; Vector3 forward = ((Component)playerScript.gameplayCamera).transform.forward; if (BetterItemScanModBase.ShowDebugMode.Value) { lineObject.SetActive(true); lineRenderer.SetPosition(0, val); lineRenderer.SetPosition(1, val + forward * maxDistance); LineRenderer obj = lineRenderer; float startWidth = (lineRenderer.endWidth = BetterItemScanModBase.ItemScanRadius.Value); obj.startWidth = startWidth; } if (num > __instance.scanElements.Length) { num = __instance.scanElements.Length; } list.Clear(); value = 0; if (num > __instance.scanElements.Length) { for (int i = 0; i < num; i++) { ScanNodeProperties component = ((Component)((RaycastHit)(ref array[i])).transform).gameObject.GetComponent<ScanNodeProperties>(); GrabbableObject component2 = ((Component)((RaycastHit)(ref array[i])).transform.parent).gameObject.GetComponent<GrabbableObject>(); if (component2.itemProperties.isScrap) { HudManagerPatch_UI.scannedNodeObjects.Add(component); } if (component.nodeType == 1 || component.nodeType == 2) { object[] parameters = new object[3] { component, i, playerScript }; methodInfo.Invoke(__instance, parameters); } } } if (list.Count < __instance.scanElements.Length) { for (int j = 0; j < num; j++) { ScanNodeProperties component3 = ((Component)((RaycastHit)(ref array[j])).transform).gameObject.GetComponent<ScanNodeProperties>(); object[] parameters2 = new object[3] { component3, j, playerScript }; methodInfo.Invoke(__instance, parameters2); } } return false; } } [HarmonyPatch] public class PlayerControllerBPatch_B { [HarmonyPrefix] [HarmonyPatch(typeof(HUDManager), "AttemptScanNode")] private static bool AttemptScanNode_patch(HUDManager __instance, ScanNodeProperties node, int i, PlayerControllerB playerScript) { MethodInfo method = typeof(HUDManager).GetMethod("MeetsScanNodeRequirements", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo method2 = typeof(HUDManager).GetMethod("AssignNodeToUIElement", BindingFlags.Instance | BindingFlags.NonPublic); FieldInfo field = typeof(HUDManager).GetField("nodesOnScreen", BindingFlags.Instance | BindingFlags.NonPublic); List<ScanNodeProperties> list = field.GetValue(__instance) as List<ScanNodeProperties>; FieldInfo field2 = typeof(HUDManager).GetField("scannedScrapNum", BindingFlags.Instance | BindingFlags.NonPublic); int num = (int)field2.GetValue(__instance); FieldInfo field3 = typeof(HUDManager).GetField("playerPingingScan", BindingFlags.Instance | BindingFlags.NonPublic); float num2 = (float)field3.GetValue(__instance); object[] parameters = new object[2] { node, playerScript }; object[] parameters2 = new object[1] { node }; if (!(bool)method.Invoke(__instance, parameters)) { return false; } if (node.nodeType == 2) { num++; } if (!list.Contains(node)) { list.Add(node); } if (node.creatureScanID == -1) { HudManagerPatch_UI.scannedNodeObjects.Add(node); } if ((double)num2 < 0.0) { return false; } method2.Invoke(__instance, parameters2); return false; } } [HarmonyPatch] public class PlayerControllerBPatch_C { [HarmonyPostfix] [HarmonyPatch(typeof(HUDManager), "Update")] private static void Update_patch(HUDManager __instance) { FieldInfo field = typeof(HUDManager).GetField("addingToDisplayTotal", BindingFlags.Instance | BindingFlags.NonPublic); object value = field.GetValue(__instance); ((Component)((TMP_Text)__instance.totalValueText).transform.parent).gameObject.SetActive(false); value = false; } } }