Decompiled source of NoGoCheckPlugin v1.0.2

NoGoCheckPlugin.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using Bounce.Singletons;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoGoCheckPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoGoCheckPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("NoGoCheckPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[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 LordAshes;

[BepInPlugin("org.lordashes.plugins.nogocheck", "No Go Check Plugin", "1.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class NoGoCheckPlugin : BaseUnityPlugin
{
	public static class Utility
	{
		public static void PostOnMainPage(MemberInfo plugin)
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Expected O, but got Unknown
				try
				{
					if (((Scene)(ref scene)).name == "UI")
					{
						TextMeshProUGUI uITextByName = GetUITextByName("BETA");
						if (Object.op_Implicit((Object)(object)uITextByName))
						{
							((TMP_Text)uITextByName).text = "INJECTED BUILD - unstable mods";
						}
					}
					else
					{
						TextMeshProUGUI uITextByName2 = GetUITextByName("TextMeshPro Text");
						if (Object.op_Implicit((Object)(object)uITextByName2))
						{
							BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(plugin, typeof(BepInPlugin));
							if (((TMP_Text)uITextByName2).text.EndsWith("</size>"))
							{
								((TMP_Text)uITextByName2).text = ((TMP_Text)uITextByName2).text + "\n\nMods Currently Installed:\n";
							}
							TextMeshProUGUI val2 = uITextByName2;
							((TMP_Text)val2).text = ((TMP_Text)val2).text + "\nLord Ashes' " + val.Name + " - " + val.Version;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
				}
			};
		}

		private static TextMeshProUGUI GetUITextByName(string name)
		{
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)array[i]).name == name)
				{
					return array[i];
				}
			}
			return null;
		}
	}

	public const string Name = "No Go Check Plugin";

	public const string Guid = "org.lordashes.plugins.nogocheck";

	public const string Version = "1.0.0.0";

	public const string Author = "Lord Ashes";

	public static int problem = 0;

	public static List<string> issues = new List<string>();

	public static Texture2D backgroundTexture1 = Image.LoadTexture("SatanRules.png", (CacheType)999);

	public static Texture2D backgroundTexture2 = Image.LoadTexture("SatanLists.png", (CacheType)999);

	private static GUIStyle infoTextStyle = new GUIStyle();

	private void Awake()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)"No Go Check Plugin: Active.");
		infoTextStyle.fontSize = 32;
		infoTextStyle.normal.textColor = Color.black;
		Utility.PostOnMainPage(((object)this).GetType());
	}

	private void OnGUI()
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		if (!SimpleSingletonBehaviour<CameraController>.HasInstance || !SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance || BoardSessionManager.IsLoading)
		{
			return;
		}
		if (problem == 0)
		{
			problem = 1;
			((MonoBehaviour)this).StartCoroutine(CheckForIssues());
		}
		if (problem == 2)
		{
			GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)backgroundTexture1, (ScaleMode)2);
		}
		if (problem != 3)
		{
			return;
		}
		GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)backgroundTexture2, (ScaleMode)2);
		int num = 140;
		GUI.Label(new Rect((float)(825 * (1920 / Screen.width)), (float)num, (float)Screen.width, 30f), "Found " + issues.Count + " Issues:", infoTextStyle);
		num += 90;
		foreach (string issue in issues)
		{
			GUI.Label(new Rect((float)(Screen.width / 2 - 100), (float)num, (float)Screen.width, 30f), issue, infoTextStyle);
			num += 60;
		}
	}

	private IEnumerator CheckForIssues()
	{
		yield return (object)new WaitForSeconds(0.1f);
		string entries = File.ReadAllText("org.lordashes.plugins.nogocheck.txt", (CacheType)999);
		foreach (string dir in Directory.EnumerateDirectories(Paths.PluginPath))
		{
			LoggingPlugin.LogInfo("Found Plugin/Asset Pack '" + Path.GetFileName(dir) + "': " + (entries.Contains(dir) ? "BAD" : "OK"));
			if (entries.Contains(Path.GetFileName(dir)))
			{
				issues.Add(Path.GetFileName(dir));
			}
		}
		if (issues.Count > 0)
		{
			LoggingPlugin.LogInfo("Configuration has " + issues.Count + " Obsolete/Broken plugins");
			while (true)
			{
				problem = 2;
				LoggingPlugin.LogDebug("Showing Satan message");
				yield return (object)new WaitForSeconds(10f);
				problem = 3;
				LoggingPlugin.LogDebug("Showing issue list");
				yield return (object)new WaitForSeconds(10f);
			}
		}
	}
}