Decompiled source of ScanLock v2.0.0

ScanLock.dll

Decompiled a month ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[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.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: AssemblyCompany("ScanLock")]
[assembly: AssemblyConfiguration("b")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ScanLock")]
[assembly: AssemblyTitle("ScanLock")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.tawoly.ScanLock", "ScanLock", "2.0.0")]
[BepInIncompatibility("ContiScan")]
public class ScanLockMod : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("com.tawoly.ScanLock");
		val.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"ScanLockMod: Loaded and Harmony-Patches active");
	}
}
[HarmonyPatch]
public static class ScannerControllerPatch
{
	private static bool isScanning;

	public static bool skipPatch;

	public static Sprite scannerIcon;

	private static TextMeshProUGUI dotText;

	[HarmonyPrefix]
	[HarmonyPatch(typeof(ScannerController), "Update")]
	public static void UpdatePatch(ScannerController __instance)
	{
		//IL_004e: 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)
		if (!skipPatch)
		{
			SetDot();
			if (PlayerInputController.instance.useEquipmentPress)
			{
				isScanning = !isScanning;
			}
			if (isScanning)
			{
				__instance.Scan();
				SetDotColor(Color.green);
			}
			else
			{
				SetDotColor(Color.red);
			}
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(PlayerItemManager), "DropEquipment")]
	public static void DropEquipmentPatch(PlayerItemManager __instance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		SetDotColor(Color.red);
	}

	private static void SetDot()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: 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_00c4: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)dotText != (Object)null))
		{
			GameObject val = new GameObject("StatusDot");
			val.transform.SetParent(((Component)UIHealthBar.instance).transform, false);
			dotText = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)dotText).text = "●";
			((TMP_Text)dotText).fontSize = 32f;
			((Graphic)dotText).color = Color.red;
			((TMP_Text)dotText).alignment = (TextAlignmentOptions)514;
			RectTransform rectTransform = ((TMP_Text)dotText).rectTransform;
			rectTransform.sizeDelta = new Vector2(40f, 40f);
			rectTransform.anchorMin = new Vector2(1f, 1f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.pivot = new Vector2(1f, 1f);
			rectTransform.anchoredPosition = new Vector2(-20f, -20f);
		}
	}

	public static void SetDotColor(Color c)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)dotText != (Object)null)
		{
			((Graphic)dotText).color = c;
		}
	}
}