Decompiled source of MoreScanNodes v1.0.0

PlayerScanNode.dll

Decompiled a day ago
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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PlayerScanNode")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PlayerScanNode")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eddef2b8-546f-4419-ac1e-ece0665d4e31")]
[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 PlayerScanNode;

[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
	[HarmonyPostfix]
	[HarmonyPatch("Start")]
	private static void Postfix(ref StartOfRound __instance)
	{
		Utils.AddScannerNodeToAllPlayers(ref __instance);
	}
}
[BepInPlugin("com.kroes.playerscannode", "Player Scan Node", "1.0.0")]
public class ScanPlugin : BaseUnityPlugin
{
	private const string GUID = "com.kroes.playerscannode";

	private const string NAME = "Player Scan Node";

	private const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	private Harmony harmony = new Harmony("com.kroes.playerscannode");

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		harmony.PatchAll(typeof(StartOfRoundPatch));
		Log.LogInfo((object)"Loaded successfully!");
	}
}
internal class Utils
{
	internal enum NodeType
	{
		GENERAL,
		DANGER,
		SCRAP
	}

	private static GameObject CreateCanvasScanNode(ref GameObject objectToAddScanNode)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Object.Instantiate<GameObject>(GameObject.CreatePrimitive((PrimitiveType)3), objectToAddScanNode.transform.position, Quaternion.Euler(Vector3.zero), objectToAddScanNode.transform);
		((Object)val).name = "ScanNode";
		val.layer = LayerMask.NameToLayer("ScanNode");
		Object.Destroy((Object)(object)val.GetComponent<MeshRenderer>());
		Object.Destroy((Object)(object)val.GetComponent<MeshFilter>());
		return val;
	}

	public static void ChangeScanNode(ref ScanNodeProperties scanNodeProperties, NodeType nodeType, string header = "KROES Scan Node", string subText = "SUBTEXT", int creatureScanID = -1, int scrapValue = 0, int minRange = 2, int maxRange = 7)
	{
		scanNodeProperties.headerText = header;
		scanNodeProperties.subText = subText;
		scanNodeProperties.nodeType = (int)nodeType;
		scanNodeProperties.creatureScanID = creatureScanID;
		scanNodeProperties.scrapValue = scrapValue;
		scanNodeProperties.minRange = minRange;
		scanNodeProperties.maxRange = maxRange;
	}

	public static void AddScanNode(GameObject objectToAddScanNode, NodeType nodeType, string header = "KROES Scan Node", string subText = "SUBTEXT", int creatureScanID = -1, int minRange = 2, int maxRange = 7)
	{
		if (!((Object)(object)objectToAddScanNode.GetComponentInChildren<ScanNodeProperties>() != (Object)null))
		{
			GameObject val = CreateCanvasScanNode(ref objectToAddScanNode);
			ScanNodeProperties scanNodeProperties = val.AddComponent<ScanNodeProperties>();
			ChangeScanNode(ref scanNodeProperties, nodeType, header, subText, creatureScanID, 0, minRange, maxRange);
		}
	}

	public static void AddGeneralScanNode(GameObject objectToAddScanNode, string header = "KROES Scan Node", string subText = "SUBTEXT", int creatureScanID = -1, int minRange = 2, int maxRange = 7)
	{
		AddScanNode(objectToAddScanNode, NodeType.GENERAL, header, subText, creatureScanID, minRange, maxRange);
	}

	public static void RemoveScanNode(GameObject objectToRemoveScanNode)
	{
		Object.Destroy((Object)(object)objectToRemoveScanNode.GetComponentInChildren<ScanNodeProperties>());
	}

	public static void AddScannerNodeToAllPlayers(ref StartOfRound startOfRound)
	{
		PlayerControllerB[] allPlayerScripts = startOfRound.allPlayerScripts;
		PlayerControllerB[] array = allPlayerScripts;
		foreach (PlayerControllerB val in array)
		{
			if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null))
			{
				ScanPlugin.Log.LogInfo((object)("Adding Scan Node for player: " + val.playerUsername));
				AddGeneralScanNode(((Component)val).gameObject, "Player", val.playerUsername, -1, 3);
			}
		}
	}
}