Decompiled source of Unlimited Scan v1.1.0

unlimited_radar.dll

Decompiled 5 months ago
using System;
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 TMPro;
using UnityEngine;
using unlimited_radar.Paches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("unlimited_radar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("unlimited_radar")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5f1957c2-8bf0-4d81-b7cb-7db9b04e1c0f")]
[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 unlimited_radar
{
	[BepInPlugin("TSD.unlimitedRadar", "Unlimited Radar", "1.1.0")]
	public class UnlimitedRadarBase : BaseUnityPlugin
	{
		private const string modGUID = "TSD.unlimitedRadar";

		private const string modName = "Unlimited Radar";

		private const string modVersion = "1.1.0";

		private readonly Harmony harmony = new Harmony("TSD.unlimitedRadar");

		private static UnlimitedRadarBase Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("TSD.unlimitedRadar");
			mls.LogInfo((object)"Unlimited Radar");
			harmony.PatchAll(typeof(UnlimitedRadarBase));
			harmony.PatchAll(typeof(AssignNewNodesPatch));
			harmony.PatchAll(typeof(AddNewScrapFoundToDisplayPatch));
			harmony.PatchAll(typeof(UpdateScanNodesPatch));
		}
	}
}
namespace unlimited_radar.Paches
{
	internal class AddNewScrapFoundToDisplayPatch
	{
		[HarmonyPatch(typeof(HUDManager), "AddNewScrapFoundToDisplay")]
		[HarmonyPrefix]
		public static void AddNewScapFoundToDisplayOverride(HUDManager __instance, GrabbableObject GObject)
		{
			__instance.itemsToBeDisplayed.Add(GObject);
		}
	}
	internal class AssignNewNodesPatch
	{
		[HarmonyPatch(typeof(HUDManager), "AssignNewNodes")]
		[HarmonyPrefix]
		private static bool AssignNewNodesOverride(HUDManager __instance, PlayerControllerB playerScript, ref RectTransform[] ___scanElements, ref List<ScanNodeProperties> ___nodesOnScreen, ref int ___scannedScrapNum, ref RaycastHit[] ___scanNodesHit)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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)
			int num = Physics.SphereCastNonAlloc(new Ray(((Component)playerScript.gameplayCamera).transform.position + ((Component)playerScript.gameplayCamera).transform.forward * 20f, ((Component)playerScript.gameplayCamera).transform.forward), 20f, ___scanNodesHit, 100000f, 4194304);
			if (num > ___scanElements.Length)
			{
				num = ___scanElements.Length;
			}
			___nodesOnScreen.Clear();
			___scannedScrapNum = 0;
			MethodInfo methodInfo = AccessTools.Method(typeof(HUDManager), "AttemptScanNode", (Type[])null, (Type[])null);
			RaycastHit val;
			if (num > ___scanElements.Length)
			{
				for (int i = 0; i < num; i++)
				{
					val = ___scanNodesHit[i];
					ScanNodeProperties component = ((Component)((RaycastHit)(ref val)).transform).gameObject.GetComponent<ScanNodeProperties>();
					if (component.nodeType == 1 || component.nodeType == 2)
					{
						methodInfo?.Invoke(__instance, new object[3] { component, i, playerScript });
					}
				}
			}
			if (___nodesOnScreen.Count < ___scanElements.Length)
			{
				for (int j = 0; j < num; j++)
				{
					val = ___scanNodesHit[j];
					ScanNodeProperties component2 = ((Component)((RaycastHit)(ref val)).transform).gameObject.GetComponent<ScanNodeProperties>();
					methodInfo?.Invoke(__instance, new object[3] { component2, j, playerScript });
				}
			}
			return false;
		}
	}
	internal class UpdateScanNodesPatch
	{
		[HarmonyPatch(typeof(HUDManager), "UpdateScanNodes")]
		[HarmonyPrefix]
		private static void UpdateScanNodesOverride(HUDManager __instance, PlayerControllerB playerScript, ref float ___updateScanInterval, ref RectTransform[] ___scanElements, ref Dictionary<RectTransform, ScanNodeProperties> ___scanNodes, ref TextMeshProUGUI[] ___scanElementText, ref int ___totalScrapScannedDisplayNum, ref float ___addToDisplayTotalInterval, ref int ___scannedScrapNum)
		{
			//IL_0001: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			Vector3 zero = Vector3.zero;
			Type type = ((object)__instance).GetType();
			if (___updateScanInterval <= 0f)
			{
				___updateScanInterval = 0.25f;
				type.InvokeMember("AssignNewNodes", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { playerScript });
			}
			___updateScanInterval -= Time.deltaTime;
			bool flag = false;
			for (int i = 0; i < ___scanElements.Length; i++)
			{
				if (___scanNodes.Count > 0 && ___scanNodes.TryGetValue(___scanElements[i], out var value) && (Object)(object)value != (Object)null)
				{
					try
					{
						if (!((Component)___scanElements[i]).gameObject.activeSelf)
						{
							((Component)___scanElements[i]).gameObject.SetActive(true);
							((Component)___scanElements[i]).GetComponent<Animator>().SetInteger("colorNumber", value.nodeType);
							if (value.creatureScanID != -1)
							{
								type.InvokeMember("AttemptScanNewCreature", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { value.creatureScanID });
							}
						}
					}
					catch (Exception arg)
					{
						Debug.LogError((object)$"Error in updatescanNodes A: {arg}");
					}
					try
					{
						___scanElementText = ((Component)___scanElements[i]).gameObject.GetComponentsInChildren<TextMeshProUGUI>();
						if (___scanElementText.Length > 1)
						{
							((TMP_Text)___scanElementText[0]).text = value.headerText;
							((TMP_Text)___scanElementText[1]).text = value.subText;
						}
						if (value.nodeType == 2)
						{
							flag = true;
						}
						zero = playerScript.gameplayCamera.WorldToScreenPoint(((Component)value).transform.position);
						___scanElements[i].anchoredPosition = new Vector2(zero.x - 439.48f, zero.y - 244.8f);
					}
					catch (Exception arg2)
					{
						Debug.LogError((object)$"Error in updatescannodes B: {arg2}");
					}
				}
				else
				{
					___scanNodes.Remove(___scanElements[i]);
					((Component)___scanElements[i]).gameObject.SetActive(false);
				}
			}
			try
			{
				if (!flag)
				{
					__instance.totalScrapScanned = 0;
					___totalScrapScannedDisplayNum = 0;
					___addToDisplayTotalInterval = 0.35f;
				}
				__instance.scanInfoAnimator.SetBool("display", ___scannedScrapNum >= 2 && flag);
			}
			catch (Exception arg3)
			{
				Debug.LogError((object)$"Error in updatescannodes C: {arg3}");
			}
		}
	}
}