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 BetterScrapScan v1.1.0
BetterScrapScan.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using BetterScrapScan.Patches; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace BetterScrapScan { [BepInPlugin("BetterScrapScan", "Better Scrap Scan", "1.0.0.0")] public class BetterScrapScanBase : BaseUnityPlugin { private const string modGUID = "BetterScrapScan"; private const string modName = "Better Scrap Scan"; private const string modVersion = "1.0.0.0"; private readonly Harmony harmony = new Harmony("BetterScrapScan"); private static BetterScrapScanBase modInstance; internal ManualLogSource mls; private void Awake() { if ((Object)(object)modInstance == (Object)null) { modInstance = this; } mls = Logger.CreateLogSource("BetterScrapScan"); mls.LogInfo((object)"BetterScrapScan mod has awaken"); harmony.PatchAll(typeof(BetterScrapScanBase)); harmony.PatchAll(typeof(TerminalPatch)); } } } namespace BetterScrapScan.Patches { internal class ItemCount { public int count; public string itemName; public int approximateValue; } [HarmonyPatch(typeof(Terminal))] internal class TerminalPatch { [HarmonyPatch(typeof(Terminal), "TextPostProcess")] [HarmonyPostfix] private static void ScanForItemsPatch(ref string modifiedDisplayText, ref TerminalNode node, Terminal __instance) { string displayText = modifiedDisplayText; if (!node.displayText.ToString().Contains("[scanForItems]")) { return; } List<ItemCount> list = new List<ItemCount>(); GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>(); Random random = new Random(StartOfRound.Instance.randomMapSeed + 91); int num = 0; int num2 = 0; GrabbableObject[] array2 = Object.FindObjectsOfType<GrabbableObject>(); for (int i = 0; i < array2.Length; i++) { GrabbableObject item2 = array2[i]; if (!item2.itemProperties.isScrap || item2.isInShipRoom || item2.isInElevator) { continue; } int num3 = Mathf.Clamp(random.Next(item2.itemProperties.minValue, item2.itemProperties.maxValue), item2.scrapValue - 6 * i, item2.scrapValue + 9 * i); num2 += num3; num++; if (list.Exists((ItemCount listedItem) => listedItem.itemName == item2.itemProperties.itemName)) { int num4 = list.FindIndex((ItemCount listedItem) => listedItem.itemName == item2.itemProperties.itemName); if (num4 >= 0) { ItemCount itemCount = list[num4]; itemCount.count++; itemCount.approximateValue += num3; list[num4] = itemCount; } } else { ItemCount item3 = new ItemCount { count = 1, itemName = item2.itemProperties.itemName, approximateValue = num3 }; list.Add(item3); } } if (list.Count() > 0) { displayText = $"\n\n\n\nTotal items found: {num}"; displayText += $"\nTotal approximate value: ${num2}"; displayText += "\n\nItems:"; list.ForEach(delegate(ItemCount item) { displayText += $"\n {item.itemName} x{item.count} (${item.approximateValue})"; }); } else { displayText = "\n\n\n\nNo items found."; } __instance.screenText.text = displayText; __instance.currentText = displayText; } } }