Decompiled source of MoreGameInfo v1.0.1

MoreGameInfo.dll

Decompiled 3 weeks 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.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LethalPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0e442c44-8597-4d85-abe7-d8d3cc7d1e3f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LethalPlugin;

[BepInPlugin("Vrtua.LethalPlugin.pluginX.MoreInfo", "MoreInfo", "1.0.0")]
public class MoreInfo : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully load Patch");
		new Harmony("Vrtua.LethalPlugin.plugin.MoreInfo");
		new Harmony("Vrtua.LethalPlugin.pluginX.MoreInfo").PatchAll();
	}
}
public class GlobalsVar
{
	public static int absoluteRadarTarget;
}
[HarmonyPatch(typeof(PlayerControllerB))]
[HarmonyPatch("Update")]
internal class Updator2
{
	private static Updator2 up = new Updator2();

	private utils ut = new utils();

	private Dictionary<Type, List<Component>> objectCache = new Dictionary<Type, List<Component>>();

	public static void Postfix()
	{
		up.CallCommonProcessor();
	}

	private void CallCommonProcessor()
	{
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0343: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_034e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		string text = "";
		int num = 0;
		List<PlayerControllerB> list = new List<PlayerControllerB>();
		PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
		foreach (PlayerControllerB val in allPlayerScripts)
		{
			if (!val.playerUsername.Contains("Player #"))
			{
				list.Add(val);
			}
		}
		foreach (PlayerControllerB item in list)
		{
			if (item.isPlayerDead)
			{
				text = text + " " + item.playerUsername + ",";
				num++;
			}
		}
		if (num > 0)
		{
			text = $"Dead({num}/{list.Count}):" + text.Substring(0, text.Length - 1) + "\n";
		}
		string text2 = "";
		int num2 = list.Count - num;
		num = 0;
		foreach (PlayerControllerB item2 in list)
		{
			if (item2.isInHangarShipRoom)
			{
				text2 = text2 + " " + item2.playerUsername + ",";
				num++;
			}
		}
		if (num > 0)
		{
			text = text + $"InShip({num}/{num2}): " + text2.Substring(0, text2.Length - 1) + "\n";
		}
		if (TimeOfDay.Instance.votesForShipToLeaveEarly > 0)
		{
			text += $"votesForShipToLeaveEarly: ({TimeOfDay.Instance.votesForShipToLeaveEarly}/{list.Count - num2})\n";
		}
		List<TransformAndName> radarTargets = StartOfRound.Instance.mapScreen.radarTargets;
		text = text + "Ship radar's real target: " + radarTargets[GlobalsVar.absoluteRadarTarget].name + "\n";
		if (radarTargets[GlobalsVar.absoluteRadarTarget].name == GameNetworkManager.Instance.localPlayerController.playerUsername)
		{
			text += "Ship's radar has set you as a target.\n";
		}
		int num3 = FindDressGirl();
		if (num3 > 0)
		{
			text = ((num3 != 1) ? (text + $"{num3} DressGirls have targeted you.") : (text + "One DressGirl have targeted you."));
			text += "\n";
			List<Vector3> list2 = FindNearestDressGildDirection();
			if (list2.Count() > 0)
			{
				float num4 = -1f;
				Vector3 val2 = default(Vector3);
				foreach (Vector3 item3 in list2)
				{
					float num5 = Vector3.Distance(GameNetworkManager.Instance.localPlayerController.thisPlayerBody.position, item3);
					if (num4 == -1f || num4 > num5)
					{
						num4 = num5;
						val2 = item3;
					}
				}
				Vector3 forward = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.forward;
				Vector3 right = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.right;
				Vector3 position = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.position;
				Vector3 val3 = val2 - position;
				float num6 = Vector3.Angle(forward, val3);
				float num7 = Vector3.Angle(right, val3);
				float num8 = Vector3.Angle(-forward, val3);
				float num9 = Vector3.Angle(-right, val3);
				string text3 = "DressGirl appeared! The one closest to you is ";
				text3 = ((num6 < 45f) ? "In front of" : ((num7 < 45f) ? "On the right of" : ((num9 < 45f) ? "On the left of" : ((num8 < 45f) ? "Behind" : ((num6 < 90f && num7 < 90f) ? "In the right front of" : ((num6 < 90f && num9 < 90f) ? "In the left front of" : ((num8 < 90f && num7 < 90f) ? "In the right back of" : ((!(num8 < 90f) || !(num9 < 90f)) ? "In the undetectable direction of" : "In the left back of"))))))));
				text = text + text3 + " you!";
			}
		}
		ut.UpdateText(text);
	}

	private void CacheObjects<T>() where T : Component
	{
		objectCache[typeof(T)] = new List<Component>((IEnumerable<Component>)(object)Object.FindObjectsOfType<T>());
	}

	private int FindDressGirl()
	{
		CacheObjects<DressGirlAI>();
		if (!objectCache.TryGetValue(typeof(DressGirlAI), out var value))
		{
			return 0;
		}
		int counter = 0;
		Action<DressGirlAI> action = delegate(DressGirlAI obj)
		{
			if ((Object)(object)obj.hauntingPlayer == (Object)(object)GameNetworkManager.Instance.localPlayerController)
			{
				counter++;
			}
		};
		foreach (DressGirlAI item in value.Cast<DressGirlAI>())
		{
			action(item);
		}
		return counter;
	}

	private List<Vector3> FindNearestDressGildDirection()
	{
		List<Vector3> Vlist = new List<Vector3>();
		CacheObjects<DressGirlAI>();
		if (!objectCache.TryGetValue(typeof(DressGirlAI), out var value))
		{
			return Vlist;
		}
		Action<DressGirlAI> action = delegate(DressGirlAI obj)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			if (obj.staringInHaunt)
			{
				_ = ((Component)obj).transform.position;
				if (((Component)obj).transform.position != default(Vector3))
				{
					Vlist.Add(((Component)obj).transform.position);
				}
			}
		};
		foreach (DressGirlAI item in value.Cast<DressGirlAI>())
		{
			action(item);
		}
		return Vlist;
	}
}
[HarmonyPatch(typeof(PlayerControllerB))]
[HarmonyPatch("SpawnPlayerAnimation")]
internal class SpawnTrigger
{
	public static void Postfix()
	{
		new utils().CreateText("Ini...");
	}
}
[HarmonyPatch(typeof(ManualCameraRenderer))]
[HarmonyPatch("SwitchRadarTargetClientRpc", new Type[] { typeof(int) })]
internal class StartSwitchPatch
{
	public static void Prefix(ref int switchToIndex)
	{
		GlobalsVar.absoluteRadarTarget = switchToIndex;
	}
}
internal class utils
{
	private static TextMeshProUGUI WatchedText;

	public void CreateText(string text)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = GameObject.Find("Systems/UI/Canvas");
		if ((Object)(object)val == (Object)null)
		{
			Debug.LogError((object)"'Canvas' not found.");
			return;
		}
		GameObject val2 = new GameObject("WatchedText");
		val2.transform.SetParent(val.transform, false);
		WatchedText = val2.AddComponent<TextMeshProUGUI>();
		((TMP_Text)WatchedText).fontSize = 10f;
		((Graphic)WatchedText).color = new Color(0.678f, 0.847f, 0.902f);
		((TMP_Text)WatchedText).alignment = (TextAlignmentOptions)513;
		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(15f, -30f);
		UpdateText(text);
	}

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