Please disclose if your mod was created primarily 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 Dynamic Scanner Range v1.0.0
DynamicScannerRange.dll
Decompiled 2 years agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("DynamicScannerRange")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("DynamicScannerRange")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6e4d356e-240a-40bd-b25a-a7fe9f8f1cdc")] [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 DynamicScannerRange; [BepInPlugin("nyoo.DynamicScannerRange", "Dynamic Scanner Range", "1.0.0")] public class DynamicScannerBase : BaseUnityPlugin { private const string modGUID = "nyoo.DynamicScannerRange"; private const string modName = "Dynamic Scanner Range"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("nyoo.DynamicScannerRange"); private static DynamicScannerBase Instance; public static ManualLogSource mls; public static ConfigEntry<int> ShipScanRadius; public static ConfigEntry<int> MainEntranceScanRadius; public static ConfigEntry<int> DataChipScanRadius; private void Awake() { mls = Logger.CreateLogSource("nyoo.DynamicScannerRange"); harmony.PatchAll(); foreach (MethodBase patchedMethod in harmony.GetPatchedMethods()) { mls.LogInfo((object)(patchedMethod.ToString() + " patched.")); } mls.LogInfo((object)"Dynamic Scanner has loaded!"); LoadConfigs(); } private void LoadConfigs() { ShipScanRadius = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "ShipScanRadius", 1000, "Vanilla Default: 110\nModded Default: 1000"); MainEntranceScanRadius = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "MainEntranceScanRadius", 1000, "Vanilla Default: 100\nModded Default: 1000"); DataChipScanRadius = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "DataChipsScanRadius", 100, "Vanilla Default: 20\nModded Default: 100"); } } [HarmonyPatch(typeof(HUDManager))] [HarmonyPatch("AttemptScanNode")] public class ScanNodePatch { [HarmonyPrefix] private static void AttemptScanNode(HUDManager __instance, ScanNodeProperties node, int i, PlayerControllerB playerScript) { switch (node.headerText) { case "Ship": node.maxRange = DynamicScannerBase.ShipScanRadius.Value; break; case "Main entrance": node.maxRange = DynamicScannerBase.MainEntranceScanRadius.Value; break; case "Data chip": node.maxRange = DynamicScannerBase.DataChipScanRadius.Value; break; } if (Traverse.Create((object)__instance).Method("MeetsScanNodeRequirements", new object[2] { node, playerScript }).GetValue<bool>()) { if (node.nodeType == 2) { Traverse.Create((object)__instance).Field("scannedScrapNum").SetValue((object)(Traverse.Create((object)__instance).Field("scannedScrapNum").GetValue<int>() + 1)); } List<ScanNodeProperties> value = Traverse.Create((object)__instance).Field<List<ScanNodeProperties>>("nodesOnScreen").Value; if (!value.Contains(node)) { value.Add(node); } if (Traverse.Create((object)__instance).Field("playerPingingScan").GetValue<float>() >= 0f) { Traverse.Create((object)__instance).Method("AssignNodeToUIElement", new object[1] { node }).GetValue(new object[1] { node }); } } } }