Decompiled source of MoreInfoPRO EN v0.8.5

MoreInfoPRO-EN.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
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: AssemblyTitle("MoreInfoPRO-EN")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreInfoPRO-EN")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("fc160b8d-44a8-4bfb-b404-3245a77cd9c5")]
[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 LethalPlugin;

[BepInPlugin("Hiester.LethalCompany.MoreInfoPRO_EN", "MoreInfoPRO_EN", "0.8.5")]
public class MoreInfoPRO_EN : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		((BaseUnityPlugin)this).Logger.LogInfo((object)"MoreInfoPRO_EN Mod loaded successfully");
		Harmony val = new Harmony("Hiester.LethalCompany.MoreInfoPRO_EN");
		val.PatchAll(typeof(Updator2));
		val.PatchAll(typeof(SpawnTrigger));
		val.PatchAll(typeof(StartSwitchPatch));
		val.PatchAll(typeof(RoomChangeHandler));
	}

	private void OnDestroy()
	{
		utils.CleanupAll();
	}
}
public class GlobalsVar
{
	public static int absoluteRadarTarget;
}
[HarmonyPatch]
internal class RoomChangeHandler
{
	[HarmonyPatch(typeof(StartOfRound), "EndOfGame")]
	[HarmonyPostfix]
	public static void OnGameEnd()
	{
		utils.CleanupAll();
		Updator2.ResetState();
	}

	[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
	[HarmonyPostfix]
	public static void OnDisconnect()
	{
		utils.CleanupAll();
		Updator2.ResetState();
	}

	[HarmonyPatch(typeof(StartOfRound), "OnDestroy")]
	[HarmonyPostfix]
	public static void OnSceneChange()
	{
		utils.CleanupAll();
		Updator2.ResetState();
	}
}
[HarmonyPatch]
internal class Updator2
{
	private static utils ut = new utils();

	private static float lastUpdateTime = 0f;

	private const float updateInterval = 0.5f;

	private static bool isInitialized = false;

	private static int lastPlayerCount = 0;

	public static void ResetState()
	{
		isInitialized = false;
		lastUpdateTime = 0f;
		lastPlayerCount = 0;
	}

	[HarmonyPatch(typeof(PlayerControllerB), "Update")]
	[HarmonyPostfix]
	public static void PlayerUpdatePostfix()
	{
		CallCommonProcessor();
	}

	private static void CallCommonProcessor()
	{
		if ((Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)
		{
			if (isInitialized)
			{
				ut.UpdateText("Disconnected...");
			}
		}
		else
		{
			if (Time.time - lastUpdateTime < 0.5f)
			{
				return;
			}
			lastUpdateTime = Time.time;
			if (!isInitialized)
			{
				ut.CreateText("Loading game info...");
				isInitialized = true;
			}
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (localPlayerController.isPlayerDead)
			{
				ut.UpdateText("You are dead, waiting for revive...");
				return;
			}
			if ((Object)(object)StartOfRound.Instance == (Object)null)
			{
				ut.UpdateText("Waiting for game to start...");
				return;
			}
			string text = "";
			List<PlayerControllerB> onlinePlayers = GetOnlinePlayers();
			if (onlinePlayers.Count == 0)
			{
				ut.UpdateText("Waiting for players to join...");
				return;
			}
			int num = 0;
			List<string> list = new List<string>();
			foreach (PlayerControllerB item in onlinePlayers)
			{
				if ((Object)(object)item != (Object)null && item.isPlayerDead)
				{
					num++;
					if (!string.IsNullOrEmpty(item.playerUsername))
					{
						list.Add(item.playerUsername);
					}
				}
			}
			if (num > 0)
			{
				if (num >= 4)
				{
					text = $"<color=red>Dead({num}/{onlinePlayers.Count}): {num} players</color>\n";
				}
				else
				{
					string arg = string.Join(", ", list);
					text = $"<color=red>Dead({num}/{onlinePlayers.Count}):</color> {arg}\n";
				}
			}
			int num2 = 0;
			List<string> list2 = new List<string>();
			foreach (PlayerControllerB item2 in onlinePlayers)
			{
				if ((Object)(object)item2 != (Object)null && !item2.isPlayerDead && item2.isInHangarShipRoom)
				{
					num2++;
					if (!string.IsNullOrEmpty(item2.playerUsername))
					{
						list2.Add(item2.playerUsername);
					}
				}
			}
			if (num2 > 0)
			{
				int num3 = onlinePlayers.Count - num;
				text += string.Format("In Ship({0}/{1}): {2}\n", num2, num3, string.Join(", ", list2));
			}
			if ((Object)(object)StartOfRound.Instance.mapScreen != (Object)null && StartOfRound.Instance.mapScreen.radarTargets != null && GlobalsVar.absoluteRadarTarget >= 0 && GlobalsVar.absoluteRadarTarget < StartOfRound.Instance.mapScreen.radarTargets.Count)
			{
				TransformAndName val = StartOfRound.Instance.mapScreen.radarTargets[GlobalsVar.absoluteRadarTarget];
				if (val != null && !string.IsNullOrEmpty(val.name))
				{
					text = text + "Radar: " + val.name;
					if (val.name == localPlayerController.playerUsername)
					{
						text += " ← Tracking you";
					}
					text += "\n";
				}
			}
			if (onlinePlayers.Count != lastPlayerCount)
			{
				lastPlayerCount = onlinePlayers.Count;
			}
			text += $"Online: {lastPlayerCount} players\n";
			int num4 = FindDressGirl();
			if (num4 > 0)
			{
				text += $"<color=orange>Dress Girl: {num4} tracking you</color>";
			}
			ut.UpdateText(text);
		}
	}

	private static List<PlayerControllerB> GetOnlinePlayers()
	{
		List<PlayerControllerB> list = new List<PlayerControllerB>();
		try
		{
			if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.allPlayerScripts != null)
			{
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB val in allPlayerScripts)
				{
					if ((Object)(object)val != (Object)null && ((Behaviour)val).isActiveAndEnabled && !string.IsNullOrEmpty(val.playerUsername) && !val.playerUsername.StartsWith("Player #") && !val.playerUsername.Contains("Bot"))
					{
						list.Add(val);
					}
				}
			}
		}
		catch
		{
		}
		return list;
	}

	private static int FindDressGirl()
	{
		try
		{
			Component[] array = (from comp in Object.FindObjectsOfType<Component>()
				where ((object)comp).GetType().Name.Contains("DressGirlAI") || ((object)comp).GetType().Name.Contains("ForestGiantAI") || ((object)comp).GetType().Name.Contains("Girl")
				select comp).ToArray();
			int num = 0;
			Component[] array2 = array;
			foreach (Component val in array2)
			{
				FieldInfo field = ((object)val).GetType().GetField("hauntingPlayer");
				if (field != null)
				{
					object? value = field.GetValue(val);
					PlayerControllerB val2 = (PlayerControllerB)((value is PlayerControllerB) ? value : null);
					if ((Object)(object)val2 == (Object)(object)GameNetworkManager.Instance.localPlayerController)
					{
						num++;
					}
				}
			}
			return num;
		}
		catch
		{
			return 0;
		}
	}
}
[HarmonyPatch(typeof(PlayerControllerB))]
[HarmonyPatch("SpawnPlayerAnimation")]
internal class SpawnTrigger
{
	[HarmonyPostfix]
	public static void Postfix()
	{
		Updator2.ResetState();
	}
}
[HarmonyPatch(typeof(ManualCameraRenderer))]
[HarmonyPatch("SwitchRadarTargetClientRpc")]
internal class StartSwitchPatch
{
	[HarmonyPrefix]
	public static void Prefix(ref int switchToIndex)
	{
		GlobalsVar.absoluteRadarTarget = switchToIndex;
	}
}
internal class utils
{
	private static TextMeshProUGUI WatchedText;

	private static bool textCreated;

	public void CreateText(string text)
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (textCreated && (Object)(object)WatchedText != (Object)null)
			{
				UpdateText(text);
				return;
			}
			CleanupExistingText();
			GameObject val = GameObject.Find("Systems/UI/Canvas");
			if ((Object)(object)val == (Object)null)
			{
				val = GameObject.Find("Canvas");
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
			}
			GameObject val2 = new GameObject("WatchedText_Mod");
			val2.transform.SetParent(val.transform, false);
			WatchedText = val2.AddComponent<TextMeshProUGUI>();
			((TMP_Text)WatchedText).fontSize = 12f;
			((Graphic)WatchedText).color = Color.white;
			((TMP_Text)WatchedText).alignment = (TextAlignmentOptions)257;
			((TMP_Text)WatchedText).richText = true;
			((TMP_Text)WatchedText).fontMaterial.EnableKeyword("UNDERLAY_ON");
			((TMP_Text)WatchedText).fontMaterial.SetColor("_UnderlayColor", new Color(0f, 0f, 0f, 0.3f));
			((TMP_Text)WatchedText).fontMaterial.SetFloat("_UnderlayOffsetX", 0.5f);
			((TMP_Text)WatchedText).fontMaterial.SetFloat("_UnderlayOffsetY", 0.5f);
			((TMP_Text)WatchedText).fontMaterial.SetFloat("_UnderlayDilate", 0.5f);
			((TMP_Text)WatchedText).fontMaterial.SetFloat("_UnderlaySoftness", 0.1f);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(0f, 1f);
			component.pivot = new Vector2(0f, 1f);
			component.anchoredPosition = new Vector2(10f, -10f);
			component.sizeDelta = new Vector2(300f, 120f);
			textCreated = true;
			UpdateText(text);
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("Text creation error: " + ex.Message));
		}
	}

	private void CleanupExistingText()
	{
		try
		{
			GameObject[] array = (from obj in Object.FindObjectsOfType<GameObject>()
				where ((Object)obj).name == "WatchedText_Mod"
				select obj).ToArray();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
			WatchedText = null;
			textCreated = false;
		}
		catch
		{
		}
	}

	public void UpdateText(string text)
	{
		try
		{
			if ((Object)(object)WatchedText != (Object)null)
			{
				((TMP_Text)WatchedText).text = text;
			}
		}
		catch
		{
		}
	}

	public static void CleanupAll()
	{
		try
		{
			GameObject[] array = (from obj in Object.FindObjectsOfType<GameObject>()
				where ((Object)obj).name.Contains("_Mod")
				select obj).ToArray();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
			WatchedText = null;
			textCreated = false;
		}
		catch
		{
		}
	}
}