Decompiled source of Better Scanner v1.0.1

Better Radar.dll

Decompiled a year ago
using 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.Logging;
using GameNetcodeStuff;
using HarmonyLib;
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("Better Radar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Better Radar")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d596b1b9-93dc-453a-81c3-bf17898a40b9")]
[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 Better_Radar;

[BepInPlugin("Mink.BetterScanner", "Better_Scanner", "1.0.1")]
public class Better_Radar : BaseUnityPlugin
{
	private const string modGUID = "Mink.BetterScanner";

	private const string modName = "Better_Scanner";

	private const string modVersion = "1.0.1";

	private readonly Harmony harmony = new Harmony("Mink.BetterScanner");

	public static ManualLogSource mls;

	private void Awake()
	{
		mls = Logger.CreateLogSource("Mink.BetterScanner");
		((BaseUnityPlugin)this).Config.Save();
		harmony.PatchAll();
		foreach (MethodBase patchedMethod in harmony.GetPatchedMethods())
		{
			mls.LogInfo((object)(patchedMethod.ToString() + " patched function."));
		}
		mls.LogInfo((object)"Plugin Mink.BetterScanner is loaded!");
	}
}
[HarmonyPatch(typeof(HUDManager))]
public static class PingScanPatch
{
	[HarmonyPatch("PingScan_performed")]
	[HarmonyPrefix]
	private static bool PingScan_performed(HUDManager __instance, CallbackContext context)
	{
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
		{
			return false;
		}
		if (!((CallbackContext)(ref context)).performed || GameNetworkManager.Instance.localPlayerController.inSpecialInteractAnimation || GameNetworkManager.Instance.localPlayerController.isPlayerDead)
		{
			return false;
		}
		if (Traverse.Create((object)__instance).Field("playerPingingScan").GetValue<float>() <= -1f)
		{
			Traverse.Create((object)__instance).Field("playerPingingScan").SetValue((object)15f);
			Animator value = Traverse.Create((object)__instance).Field("scanEffectAnimator").GetValue<Animator>();
			((Component)value).transform.position = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.position;
			value.SetTrigger("scan");
			__instance.UIAudio.PlayOneShot(__instance.scanSFX);
		}
		return false;
	}
}
[HarmonyPatch(typeof(HUDManager))]
[HarmonyPatch("AttemptScanNode")]
public class ScanTimerPatch
{
	[HarmonyPrefix]
	private static bool AttemptScanNode(HUDManager __instance, ScanNodeProperties node, int i, PlayerControllerB playerScript)
	{
		bool __result = false;
		ScanNodePatch.MeetsScanNodeRequirements(node, playerScript, ref __result);
		if (!__result)
		{
			return false;
		}
		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>() >= 10f)
		{
			Traverse.Create((object)__instance).Method("AssignNodeToUIElement", new object[1] { node }).GetValue(new object[1] { node });
		}
		return false;
	}
}
[HarmonyPatch(typeof(HUDManager))]
public class ScanNodePatch
{
	[HarmonyPatch("MeetsScanNodeRequirements")]
	[HarmonyPrefix]
	public static bool MeetsScanNodeRequirements(ScanNodeProperties node, PlayerControllerB playerScript, ref bool __result)
	{
		//IL_001a: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)node == (Object)null)
		{
			__result = false;
			return false;
		}
		float num = Vector3.Distance(((Component)playerScript).transform.position, ((Component)node).transform.position);
		__result = num > (float)node.minRange && (!node.requiresLineOfSight || !Physics.Linecast(((Component)playerScript.gameplayCamera).transform.position, ((Component)node).transform.position, 256, (QueryTriggerInteraction)1));
		return false;
	}
}
internal class Patches
{
}