Decompiled source of BetterLethality v1.0.1

BepInEx/plugins/BetterLethality.dll

Decompiled 12 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BetterLethality.Patches;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
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("BetterLethality")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterLethality")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e1fe85a1-6433-439e-a3c1-f5d033f179ad")]
[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 BetterLethality
{
	[BepInPlugin("vzp.lethality", "Better Lethality", "1.0.0.0")]
	public class LethalityMain : BaseUnityPlugin
	{
		private const string modGUID = "vzp.lethality";

		private const string modName = "Better Lethality";

		private const string modVersion = "1.0.0.0";

		private readonly Harmony harmony = new Harmony("vzp.lethality");

		private static LethalityMain instance;

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			harmony.PatchAll(typeof(LethalityMain));
			harmony.PatchAll(typeof(LethalPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Lethality has been bettered");
		}
	}
}
namespace BetterLethality.Patches
{
	[HarmonyPatch(typeof(MenuManager))]
	internal class LethalPatch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__3_0;

			internal void <AddMods>b__3_0()
			{
				modsPanel.SetActive(true);
			}
		}

		private static GameObject modBtn;

		private static GameObject modsPanel;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void UpdateNews(ref GameObject ___NewsPanel)
		{
			TextMeshProUGUI component = ((Component)((Component)___NewsPanel.transform.Find("Panel")).transform.Find("DemoText")).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = ((TMP_Text)component).text + "\n\n[MODS DETECTED]";
		}

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void AddMods(ref GameObject ___menuButtons)
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			modsPanel = Object.Instantiate<GameObject>(((Component)((Component)___menuButtons.transform.parent).transform.Find("CreditsPanel")).gameObject, ___menuButtons.transform.parent);
			((Object)modsPanel).name = "ModsPanel";
			((TMP_Text)((Component)modsPanel.transform.Find("Panel/NotificationText")).GetComponent<TextMeshProUGUI>()).text = "Installed Mods";
			GameObject val = Object.Instantiate<GameObject>(((Component)modsPanel.transform.Find("Panel/Scroll View/Viewport/Content/CreditsText")).gameObject, modsPanel.transform.Find("Panel/Scroll View/Viewport/Content"));
			((Behaviour)val.GetComponent<TextMeshProUGUI>()).enabled = true;
			Object.Destroy((Object)(object)modsPanel.transform.Find("Panel/Scroll View/Viewport/Content/CreditsText"));
			modBtn = Object.Instantiate<GameObject>(((Component)___menuButtons.transform.Find("HostButton")).gameObject, ___menuButtons.transform);
			((Object)modBtn).name = "ModsButton";
			modBtn.transform.localPosition = new Vector3(-253.6928f, -9.9013f, -5.7486f);
			((TMP_Text)modBtn.GetComponentInChildren<TextMeshProUGUI>()).text = "> Mods";
			((UnityEventBase)modBtn.GetComponent<Button>().onClick).RemoveAllListeners();
			ButtonClickedEvent onClick = modBtn.GetComponent<Button>().onClick;
			object obj = <>c.<>9__3_0;
			if (obj == null)
			{
				UnityAction val2 = delegate
				{
					modsPanel.SetActive(true);
				};
				<>c.<>9__3_0 = val2;
				obj = (object)val2;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			string path = Path.Combine(Directory.GetCurrentDirectory(), "BepInEx/plugins");
			string[] files = Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories);
			StringBuilder stringBuilder = new StringBuilder("");
			string[] array = files;
			foreach (string path2 in array)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path2);
				stringBuilder.AppendLine("- " + fileNameWithoutExtension);
			}
			((TMP_Text)val.GetComponent<TextMeshProUGUI>()).text = stringBuilder.ToString();
		}
	}
}