Decompiled source of Modders Logger UI v1.0.0

Megabonk.LoggerUI.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.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Megabonk.LoggerUI
{
	[BepInPlugin("com.ImLegless.LoggerUI", "Megabonk Logger UI", "1.3.0")]
	public class LoggingUiPlugin : BasePlugin
	{
		public class UiController : MonoBehaviour
		{
			public UiController(IntPtr ptr)
				: base(ptr)
			{
			}

			private void Update()
			{
				if (IsComboDown())
				{
					_show = !_show;
				}
				_blinkTimer += Time.unscaledDeltaTime;
				if (_blinkTimer > 1.2f)
				{
					_blinkTimer = 0f;
				}
			}

			private void OnGUI()
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Invalid comparison between Unknown and I4
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Invalid comparison between Unknown and I4
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_019f: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_020e: Unknown result type (might be due to invalid IL or missing references)
				//IL_022b: Unknown result type (might be due to invalid IL or missing references)
				//IL_026a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_029b: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0315: Unknown result type (might be due to invalid IL or missing references)
				if (!_show)
				{
					return;
				}
				try
				{
					GUIStyle val = (((Object)(object)GUI.skin != (Object)null) ? GUI.skin.window : GUIStyle.none);
					GUI.Box(_win, string.Empty, val);
					Rect val2 = default(Rect);
					((Rect)(ref val2))..ctor(((Rect)(ref _win)).x, ((Rect)(ref _win)).y, ((Rect)(ref _win)).width, 22f);
					GUI.Label(val2, "Logger UI", StyleCentered());
					Event current = Event.current;
					if ((int)current.type == 0 && ((Rect)(ref val2)).Contains(current.mousePosition))
					{
						_dragging = true;
						_dragOffset = current.mousePosition - new Vector2(((Rect)(ref _win)).x, ((Rect)(ref _win)).y);
						current.Use();
					}
					if ((int)current.type == 3 && _dragging)
					{
						Vector2 position = current.mousePosition - _dragOffset;
						((Rect)(ref _win)).position = position;
						current.Use();
					}
					if ((int)current.type == 1 && _dragging)
					{
						_dragging = false;
						current.Use();
					}
					float num = 8f;
					float num2 = ((Rect)(ref _win)).x + num;
					float num3 = ((Rect)(ref _win)).y + 28f;
					float num4 = ((Rect)(ref _win)).width - num * 2f;
					float num5 = 22f;
					GUI.Label(new Rect(num2, num3, num4, num5), "<b>Megabonk Logger UI</b>", StyleRichLeft());
					num3 += num5 + 6f;
					GUI.Label(new Rect(num2, num3, num4, num5), "Type (full name; nested as Outer+Inner):");
					num3 += num5;
					TextBox(new Rect(num2, num3, num4, num5), 0, ref _typeName, "e.g. Assets.Scripts.Player+Mover or ChestOpening");
					num3 += num5 + 6f;
					GUI.Label(new Rect(num2, num3, num4, num5), "Method:");
					num3 += num5;
					TextBox(new Rect(num2, num3, num4, num5), 1, ref _methodName, "e.g. Update or OpenChest");
					num3 += num5 + 6f;
					GUI.Label(new Rect(num2, num3, num4, num5), "Param Types CSV (or #<overload_index>):");
					num3 += num5;
					TextBox(new Rect(num2, num3, num4, num5), 2, ref _paramCsv, "e.g. System.Int32, Assets.Scripts.ItemData  or  #0");
					num3 += num5 + 10f;
					float num6 = (num4 - 12f) / 3f;
					if (GUI.Button(new Rect(num2, num3, num6, num5 + 4f), "Find Type"))
					{
						DoFindType(_typeName);
					}
					if (GUI.Button(new Rect(num2 + num6 + 6f, num3, num6, num5 + 4f), "List Overloads"))
					{
						DoListOverloads(_typeName, _methodName);
					}
					if (GUI.Button(new Rect(num2 + (num6 + 6f) * 2f, num3, num6, num5 + 4f), "Patch"))
					{
						DoPatch(_typeName, _methodName, _paramCsv);
					}
					num3 += num5 + 10f;
					if (GUI.Button(new Rect(num2, num3, num4, num5 + 4f), "Close"))
					{
						_show = false;
					}
				}
				catch (Exception ex)
				{
					SLog.LogError((object)ex);
				}
			}

			private static bool IsComboDown()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				if (!Input.GetKeyDown(Cfg_ToggleKey.Value))
				{
					return false;
				}
				if (Cfg_ModCtrl.Value && !Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305))
				{
					return false;
				}
				if (Cfg_ModAlt.Value && !Input.GetKey((KeyCode)308) && !Input.GetKey((KeyCode)307) && !Input.GetKey((KeyCode)313))
				{
					return false;
				}
				if (Cfg_ModShift.Value && !Input.GetKey((KeyCode)304) && !Input.GetKey((KeyCode)303))
				{
					return false;
				}
				return true;
			}
		}

		internal static ManualLogSource SLog;

		internal static ConfigEntry<KeyCode> Cfg_ToggleKey;

		internal static ConfigEntry<bool> Cfg_ModCtrl;

		internal static ConfigEntry<bool> Cfg_ModAlt;

		internal static ConfigEntry<bool> Cfg_ModShift;

		private static GameObject _host;

		private static bool _show;

		private static Rect _win = new Rect(100f, 100f, 560f, 360f);

		private static bool _dragging;

		private static Vector2 _dragOffset;

		private static string _typeName = "ChestOpening";

		private static string _methodName = "OpenChest";

		private static string _paramCsv = "";

		private static int _focusedTextBox = -1;

		private static float _blinkTimer;

		private const float BLINK_PERIOD = 0.6f;

		private static Type _lastType;

		private static string _lastMethod;

		private static readonly List<MethodBase> _lastOverloads = new List<MethodBase>();

		public override void Load()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			SLog = Logger.CreateLogSource("MB-LoggerUI");
			Cfg_ToggleKey = ((BasePlugin)this).Config.Bind<KeyCode>("UI", "ToggleKey", (KeyCode)289, "Main key to toggle the Logger UI.");
			Cfg_ModCtrl = ((BasePlugin)this).Config.Bind<bool>("UI", "RequireCtrl", false, "Require Ctrl with ToggleKey.");
			Cfg_ModAlt = ((BasePlugin)this).Config.Bind<bool>("UI", "RequireAlt", false, "Require Alt with ToggleKey.");
			Cfg_ModShift = ((BasePlugin)this).Config.Bind<bool>("UI", "RequireShift", false, "Require Shift with ToggleKey.");
			ClassInjector.RegisterTypeInIl2Cpp<UiController>();
			_host = new GameObject("MB_LoggerUI_Host");
			_host.AddComponent(Il2CppType.Of<UiController>());
			Object.DontDestroyOnLoad((Object)(object)_host);
			ManualLogSource sLog = SLog;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 4, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Logger UI loaded. Toggle: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Cfg_ModCtrl.Value ? "Ctrl+" : "");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Cfg_ModAlt.Value ? "Alt+" : "");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Cfg_ModShift.Value ? "Shift+" : "");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<KeyCode>(Cfg_ToggleKey.Value);
			}
			sLog.LogInfo(val);
		}

		private static void TextBox(Rect r, int id, ref string value, string placeholder)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Invalid comparison between Unknown and I4
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Invalid comparison between Unknown and I4
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Invalid comparison between Unknown and I4
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Invalid comparison between Unknown and I4
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if ((int)current.type == 0 && ((Rect)(ref r)).Contains(current.mousePosition))
			{
				_focusedTextBox = id;
				current.Use();
			}
			GUIStyle val = (((Object)(object)GUI.skin != (Object)null) ? GUI.skin.textField : GUIStyle.none);
			GUI.Box(r, string.Empty, val);
			if (_focusedTextBox == id && current.isKey && (int)current.type == 4)
			{
				if ((int)current.keyCode == 8)
				{
					if (!string.IsNullOrEmpty(value))
					{
						value = value.Substring(0, value.Length - 1);
					}
					current.Use();
				}
				else if ((int)current.keyCode == 13 || (int)current.keyCode == 271)
				{
					_focusedTextBox = -1;
					current.Use();
				}
				else
				{
					char character = current.character;
					if (character >= ' ' && character != '\u007f')
					{
						value += character;
						current.Use();
					}
				}
			}
			string text = (string.IsNullOrEmpty(value) ? placeholder : value);
			GUIStyle val2 = (((Object)(object)GUI.skin != (Object)null) ? GUI.skin.label : GUIStyle.none);
			if (string.IsNullOrEmpty(value))
			{
				GUIStyle val3 = new GUIStyle(val2);
				val3.normal.textColor = new Color(1f, 1f, 1f, 0.5f);
				GUI.Label(new Rect(((Rect)(ref r)).x + 6f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width - 12f, ((Rect)(ref r)).height - 4f), text, val3);
			}
			else
			{
				GUI.Label(new Rect(((Rect)(ref r)).x + 6f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width - 12f, ((Rect)(ref r)).height - 4f), text, val2);
			}
			if (_focusedTextBox == id && _blinkTimer < 0.6f)
			{
				float num = ((Rect)(ref r)).x + 6f + Mathf.Min((float)text.Length * 7f, ((Rect)(ref r)).width - 12f);
				Rect val4 = new Rect(num, ((Rect)(ref r)).y + 3f, 1f, ((Rect)(ref r)).height - 6f);
				Color color = GUI.color;
				GUI.color = Color.white;
				GUI.DrawTexture(val4, (Texture)(object)Texture2D.whiteTexture);
				GUI.color = color;
			}
		}

		private static GUIStyle StyleRichLeft()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			return new GUIStyle(GUI.skin.label)
			{
				richText = true,
				alignment = (TextAnchor)3
			};
		}

		private static GUIStyle StyleCentered()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			return new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4
			};
		}

		private static void DoFindType(string partialName)
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			try
			{
				if (string.IsNullOrWhiteSpace(partialName))
				{
					SLog.LogWarning((object)"[Find] Enter a type name.");
					return;
				}
				List<Type> list = new List<Type>();
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					try
					{
						Type type = AccessTools.GetTypesFromAssembly(assembly).FirstOrDefault((Type tp) => string.Equals(tp.FullName, partialName, StringComparison.Ordinal) || string.Equals(tp.Name, partialName, StringComparison.Ordinal));
						if (type != null)
						{
							list.Add(type);
						}
					}
					catch
					{
					}
				}
				bool flag = default(bool);
				if (list.Count == 0)
				{
					ManualLogSource sLog = SLog;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Find] No type found matching '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(partialName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'.");
					}
					sLog.LogWarning(val);
					return;
				}
				ManualLogSource sLog2 = SLog;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(39, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Find] Found ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list.Count);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" type candidate(s) for '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(partialName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("':");
				}
				sLog2.LogInfo(val2);
				int num = 0;
				foreach (Type item in list)
				{
					ManualLogSource sLog3 = SLog;
					val2 = new BepInExInfoLogInterpolatedStringHandler(14, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("  [");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num++);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(item.FullName ?? item.Name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("  (asm: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(item.Assembly.GetName().Name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
					}
					sLog3.LogInfo(val2);
				}
				SLog.LogInfo((object)"Copy the exact FullName into the Type field (use '+' for nested), or just the class name if it’s in the global namespace.");
			}
			catch (Exception ex)
			{
				SLog.LogError((object)ex);
			}
		}

		private static void DoListOverloads(string typeName, string methodName)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			try
			{
				if (!TryResolveType(typeName, out var t))
				{
					return;
				}
				_lastType = t;
				_lastMethod = methodName;
				_lastOverloads.Clear();
				List<MethodBase> list = (from m in AccessTools.GetDeclaredMethods(t)
					where string.Equals(m.Name, methodName, StringComparison.Ordinal)
					select m).Cast<MethodBase>().ToList();
				bool flag = default(bool);
				if (list.Count == 0)
				{
					ManualLogSource sLog = SLog;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(30, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[List] No methods named '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(methodName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' on ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(t.FullName ?? t.Name);
					}
					sLog.LogWarning(val);
					return;
				}
				ManualLogSource sLog2 = SLog;
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[List] Methods named '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(methodName);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' on ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(t.FullName ?? t.Name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(":");
				}
				sLog2.LogInfo(val2);
				int num = 0;
				foreach (MethodBase item in list)
				{
					_lastOverloads.Add(item);
					ParameterInfo[] parameters = item.GetParameters();
					string text = string.Join(", ", parameters.Select((ParameterInfo pi) => pi.ParameterType.FullName ?? pi.ParameterType.Name));
					Type type = (item as MethodInfo)?.ReturnType;
					string text2 = ((type == null) ? "void" : (type.FullName ?? type.Name));
					ManualLogSource sLog3 = SLog;
					val2 = new BepInExInfoLogInterpolatedStringHandler(9, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("  [#");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text2);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(item.Name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("(");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
					}
					sLog3.LogInfo(val2);
					num++;
				}
				SLog.LogInfo((object)"Tip: In Param Types, enter '#<index>' (e.g., '#0') to pick an overload by index.");
			}
			catch (Exception ex)
			{
				SLog.LogError((object)ex);
			}
		}

		private static void DoPatch(string typeName, string methodName, string paramCsvOrIndex)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Expected O, but got Unknown
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Expected O, but got Unknown
			try
			{
				if (!TryResolveType(typeName, out var t))
				{
					return;
				}
				MethodBase methodBase = null;
				bool flag = default(bool);
				if (!string.IsNullOrWhiteSpace(paramCsvOrIndex) && paramCsvOrIndex.TrimStart().StartsWith("#") && _lastType == t && string.Equals(_lastMethod, methodName, StringComparison.Ordinal))
				{
					if (!int.TryParse(paramCsvOrIndex.Trim().Substring(1), out var result) || result < 0 || result >= _lastOverloads.Count)
					{
						ManualLogSource sLog = SLog;
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(64, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Patch] Invalid overload index '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(paramCsvOrIndex);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'. Click 'List Overloads' first.");
						}
						sLog.LogWarning(val);
						return;
					}
					methodBase = _lastOverloads[result];
				}
				else
				{
					string text = (paramCsvOrIndex ?? "").Trim();
					Type[] array = ((text.Length != 0) ? (from n in (from s in text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
							select s.Trim()).ToArray()
						select AccessTools.TypeByName(n) ?? Type.GetType(n) into tp
						select tp ?? typeof(object)).ToArray() : Type.EmptyTypes);
					methodBase = AccessTools.Method(t, methodName, array, (Type[])null);
				}
				if (methodBase == null)
				{
					ManualLogSource sLog2 = SLog;
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(29, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Patch] Method not found: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(t.FullName ?? t.Name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(methodName);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(paramCsvOrIndex);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
					}
					sLog2.LogWarning(val);
					if (_lastType == t && !string.IsNullOrWhiteSpace(_lastMethod))
					{
						DumpOverloadsForHelp(t, methodName);
					}
					return;
				}
				Harmony val2 = new Harmony("com.yourname.megabonk.loggerui.dynamic");
				HarmonyMethod val3 = new HarmonyMethod(typeof(LoggingUiPlugin).GetMethod("DynPrefix", BindingFlags.Static | BindingFlags.NonPublic));
				HarmonyMethod val4 = new HarmonyMethod(typeof(LoggingUiPlugin).GetMethod("DynPostfix", BindingFlags.Static | BindingFlags.NonPublic));
				val2.Patch(methodBase, val3, val4, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				ParameterInfo[] parameters = methodBase.GetParameters();
				string text2 = string.Join(", ", parameters.Select((ParameterInfo pi) => pi.ParameterType.FullName ?? pi.ParameterType.Name));
				ManualLogSource sLog3 = SLog;
				BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(19, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[Patch] Patched ");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(methodBase.DeclaringType?.FullName);
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(".");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(methodBase.Name);
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("(");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(text2);
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(")");
				}
				sLog3.LogInfo(val5);
			}
			catch (Exception ex)
			{
				SLog.LogError((object)ex);
			}
		}

		private static bool TryResolveType(string typeName, out Type t)
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			t = null;
			if (string.IsNullOrWhiteSpace(typeName))
			{
				SLog.LogWarning((object)"Enter a type name.");
				return false;
			}
			t = AccessTools.TypeByName(typeName) ?? Type.GetType(typeName);
			if (t != null)
			{
				return true;
			}
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					Type type = AccessTools.GetTypesFromAssembly(assembly).FirstOrDefault((Type tp) => string.Equals(tp.FullName, typeName, StringComparison.Ordinal) || string.Equals(tp.Name, typeName, StringComparison.Ordinal));
					if (type != null)
					{
						t = type;
						return true;
					}
				}
				catch
				{
				}
			}
			ManualLogSource sLog = SLog;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(90, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Type not found: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(typeName);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". If nested, use 'Outer+Inner'. For global namespace, just the class name.");
			}
			sLog.LogWarning(val);
			return false;
		}

		private static void DumpOverloadsForHelp(Type t, string methodName)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			List<MethodInfo> list = (from m in AccessTools.GetDeclaredMethods(t)
				where m.Name == methodName
				select m).ToList();
			if (list.Count == 0)
			{
				return;
			}
			ManualLogSource sLog = SLog;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Available overloads on ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(t.FullName ?? t.Name);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(":");
			}
			sLog.LogInfo(val);
			foreach (MethodInfo item in list)
			{
				ParameterInfo[] parameters = item.GetParameters();
				string text = string.Join(", ", parameters.Select((ParameterInfo pi) => pi.ParameterType.FullName ?? pi.ParameterType.Name));
				Type type = item?.ReturnType;
				string text2 = ((type == null) ? "void" : (type.FullName ?? type.Name));
				ManualLogSource sLog2 = SLog;
				val = new BepInExInfoLogInterpolatedStringHandler(5, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("  ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item.Name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
				}
				sLog2.LogInfo(val);
			}
		}

		private static void DynPrefix(object __instance, object[] __args)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			string text = __instance?.GetType().FullName ?? "(static)";
			string text2 = ((__args == null || __args.Length == 0) ? "" : string.Join(", ", __args.Select((object a) => a ?? "null")));
			ManualLogSource sLog = SLog;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(16, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Prefix] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" args: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
			}
			sLog.LogInfo(val);
		}

		private static void DynPostfix(object __instance, object[] __args)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			string text = __instance?.GetType().FullName ?? "(static)";
			ManualLogSource sLog = SLog;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Postfix] ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> (done)");
			}
			sLog.LogInfo(val);
		}
	}
}