using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using AssetRipper.Primitives; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Preloader.Core.Logging; using BepInEx.Unity.Common; using BepInEx.Unity.Mono.Bootstrap; using BepInEx.Unity.Mono.Logging; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("UnityEngine")] [assembly: InternalsVisibleTo("UnityEngine.Core")] [assembly: AssemblyCompany("BepInEx")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2022 BepInEx Team")] [assembly: AssemblyDescription("BepInEx support library for Mono Unity games")] [assembly: AssemblyFileVersion("6.0.0.0")] [assembly: AssemblyInformationalVersion("6.0.0-be.697+53625800b86f6c68751445248260edf0b27a71c2")] [assembly: AssemblyProduct("BepInEx.Unity.Mono")] [assembly: AssemblyTitle("BepInEx.Unity.Mono")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("6.0.0.0")] [module: UnverifiableCode] namespace UnityEngine { internal sealed class UnityLogWriter { [MethodImpl(MethodImplOptions.InternalCall)] public static extern void WriteStringToUnityLogImpl(string s); [MethodImpl(MethodImplOptions.InternalCall)] public static extern void WriteStringToUnityLog(string s); } } namespace BepInEx.Unity.Mono { public abstract class BaseUnityPlugin : MonoBehaviour { public PluginInfo Info { get; } protected ManualLogSource Logger { get; } public ConfigFile Config { get; } protected BaseUnityPlugin() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown BepInPlugin metadata = MetadataHelper.GetMetadata((object)this); if (metadata == null) { throw new InvalidOperationException("Can't create an instance of " + ((object)this).GetType().FullName + " because it inherits from BaseUnityPlugin and the BepInPlugin attribute is missing."); } Info = new PluginInfo { Metadata = metadata, Instance = this, Dependencies = MetadataHelper.GetDependencies(((object)this).GetType()), Processes = MetadataHelper.GetAttributes(((object)this).GetType()), Location = ((object)this).GetType().Assembly.Location }; Logger = Logger.CreateLogSource(metadata.Name); Config = new ConfigFile(Utility.CombinePaths(new string[2] { Paths.ConfigPath, metadata.GUID + ".cfg" }), false, metadata); } } public static class BepInExInstance { public static UnityChainloader Chainloader { get; } } public sealed class ThreadingHelper : MonoBehaviour, ISynchronizeInvoke { private sealed class InvokeResult : IAsyncResult { internal bool ExceptionThrown; public bool IsCompleted { get; private set; } public WaitHandle AsyncWaitHandle { get; } public object AsyncState { get; private set; } public bool CompletedSynchronously { get; private set; } public InvokeResult() { AsyncWaitHandle = new EventWaitHandle(initialState: false, EventResetMode.ManualReset); } public void Finish(object result, bool completedSynchronously) { AsyncState = result; CompletedSynchronously = completedSynchronously; IsCompleted = true; ((EventWaitHandle)AsyncWaitHandle).Set(); } } private readonly object _invokeLock = new object(); private Action _invokeList; private Thread _mainThread; public static ThreadingHelper Instance { get; private set; } public static ISynchronizeInvoke SynchronizingObject => Instance; public bool InvokeRequired { get { if (_mainThread != null) { return _mainThread != Thread.CurrentThread; } return true; } } private void Update() { if (_mainThread == null) { _mainThread = Thread.CurrentThread; } if (_invokeList == null) { return; } Action invokeList; lock (_invokeLock) { invokeList = _invokeList; _invokeList = null; } foreach (Action item in invokeList.GetInvocationList().Cast()) { try { item(); } catch (Exception ex) { LogInvocationException(ex); } } } internal static void Initialize() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown GameObject val = new GameObject("BepInEx_ThreadingHelper") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)val); Instance = val.AddComponent(); } public void StartSyncInvoke(Action action) { if (action == null) { throw new ArgumentNullException("action"); } lock (_invokeLock) { _invokeList = (Action)Delegate.Combine(_invokeList, action); } } public void StartAsyncInvoke(Func action) { if (!ThreadPool.QueueUserWorkItem(DoWork)) { throw new NotSupportedException("Failed to queue the action on ThreadPool"); } void DoWork(object _) { try { Action action2 = action(); if (action2 != null) { StartSyncInvoke(action2); } } catch (Exception ex) { LogInvocationException(ex); } } } private static void LogInvocationException(Exception ex) { //IL_0010: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown Logger.Log((LogLevel)2, (object)ex); if (ex.InnerException != null) { LogLevel val = (LogLevel)2; bool flag = default(bool); BepInExLogInterpolatedStringHandler val2 = new BepInExLogInterpolatedStringHandler(7, 1, val, ref flag); if (flag) { val2.AppendLiteral("INNER: "); val2.AppendFormatted(ex.InnerException); } Logger.Log(val, val2); } } IAsyncResult ISynchronizeInvoke.BeginInvoke(Delegate method, object[] args) { InvokeResult result = new InvokeResult(); if (!InvokeRequired) { result.Finish(Invoke(), completedSynchronously: true); } else { StartSyncInvoke(delegate { result.Finish(Invoke(), completedSynchronously: false); }); } return result; object Invoke() { try { return method.DynamicInvoke(args); } catch (Exception result2) { result.ExceptionThrown = true; return result2; } } } object ISynchronizeInvoke.EndInvoke(IAsyncResult result) { InvokeResult invokeResult = (InvokeResult)result; invokeResult.AsyncWaitHandle.WaitOne(); if (invokeResult.ExceptionThrown) { throw (Exception)invokeResult.AsyncState; } return invokeResult.AsyncState; } object ISynchronizeInvoke.Invoke(Delegate method, object[] args) { IAsyncResult result = ((ISynchronizeInvoke)this).BeginInvoke(method, args); return ((ISynchronizeInvoke)this).EndInvoke(result); } } public static class ThreadingExtensions { public static IEnumerable RunParallel(this IEnumerable data, Func work, int workerCount = -1) { foreach (TOut item in data.ToList().RunParallel(work)) { yield return item; } } public static IEnumerable RunParallel(this IList data, Func work, int workerCount = -1) { if (workerCount < 0) { workerCount = Mathf.Max(2, Environment.ProcessorCount); } else if (workerCount == 0) { throw new ArgumentException("Need at least 1 worker", "workerCount"); } int perThreadCount = Mathf.CeilToInt((float)data.Count / (float)workerCount); int doneCount = 0; object lockObj = new object(); ManualResetEvent are = new ManualResetEvent(initialState: false); IEnumerable doneItems = null; Exception exceptionThrown = null; for (int i = 0; i < workerCount; i++) { int first = i * perThreadCount; int last = Mathf.Min(first + perThreadCount, data.Count); ThreadPool.QueueUserWorkItem(delegate { List list = new List(perThreadCount); try { for (int j = first; j < last; j++) { if (exceptionThrown != null) { break; } list.Add(work(data[j])); } } catch (Exception ex) { exceptionThrown = ex; } lock (lockObj) { IEnumerable enumerable2; if (doneItems != null) { enumerable2 = list.Concat(doneItems); } else { IEnumerable enumerable3 = list; enumerable2 = enumerable3; } doneItems = enumerable2; int num = doneCount; doneCount = num + 1; are.Set(); } }); } bool isDone; do { are.WaitOne(); IEnumerable enumerable; lock (lockObj) { enumerable = doneItems; doneItems = null; isDone = doneCount == workerCount; } if (enumerable == null) { continue; } foreach (TOut item in enumerable) { yield return item; } } while (!isDone); if (exceptionThrown != null) { throw new TargetInvocationException("An exception was thrown inside one of the threads", exceptionThrown); } } public static void ForEachParallel(this IList data, Action work, int workerCount = -1) { if (workerCount < 0) { workerCount = Mathf.Max(2, Environment.ProcessorCount); } else if (workerCount == 0) { throw new ArgumentException("Need at least 1 worker", "workerCount"); } int currentIndex = data.Count; ManualResetEvent are = new ManualResetEvent(initialState: false); int runningCount = workerCount; Exception exceptionThrown = null; for (int i = 0; i < workerCount - 1; i++) { ThreadPool.QueueUserWorkItem(DoWork); } DoWork(null); are.WaitOne(); if (exceptionThrown != null) { throw new TargetInvocationException("An exception was thrown inside one of the threads", exceptionThrown); } void DoWork(object _) { try { while (exceptionThrown == null) { int num = Interlocked.Decrement(ref currentIndex); if (num < 0) { break; } work(data[num]); } } catch (Exception ex) { exceptionThrown = ex; } finally { if (Interlocked.Decrement(ref runningCount) <= 0) { are.Set(); } } } } } internal static class UnityTomlTypeConverters { [MethodImpl(MethodImplOptions.NoInlining)] public static void AddUnityEngineConverters() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown TypeConverter val = new TypeConverter { ConvertToString = (object obj, Type type) => ColorUtility.ToHtmlStringRGBA((Color)obj), ConvertToObject = delegate(string str, Type type) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) Color val3 = default(Color); if (!ColorUtility.TryParseHtmlString("#" + str.Trim('#', ' '), ref val3)) { throw new FormatException("Invalid color string, expected hex #RRGGBBAA"); } return val3; } }; TomlTypeConverter.AddConverter(typeof(Color), val); TypeConverter val2 = new TypeConverter { ConvertToString = (object obj, Type type) => JsonUtility.ToJson(obj), ConvertToObject = (string str, Type type) => JsonUtility.FromJson(str, type) }; TomlTypeConverter.AddConverter(typeof(Vector2), val2); TomlTypeConverter.AddConverter(typeof(Vector3), val2); TomlTypeConverter.AddConverter(typeof(Vector4), val2); TomlTypeConverter.AddConverter(typeof(Quaternion), val2); } } } namespace BepInEx.Unity.Mono.Logging { public class UnityLogListener : ILogListener, IDisposable { internal static readonly Action WriteStringToUnityLog; protected static readonly ConfigEntry ConfigUnityLogLevel; private readonly ConfigEntry LogConsoleToUnity = ConfigFile.CoreConfig.Bind("Logging", "LogConsoleToUnityLog", false, new StringBuilder().AppendLine("If enabled, writes Standard Output messages to Unity log").AppendLine("NOTE: By default, Unity does so automatically. Only use this option if no console messages are visible in Unity log").ToString()); public LogLevel LogLevelFilter => ConfigUnityLogLevel.Value; static UnityLogListener() { ConfigUnityLogLevel = ConfigFile.CoreConfig.Bind("Logging.Unity", "LogLevels", (LogLevel)31, "What log levels to log to Unity's output log."); MethodInfo[] methods = typeof(UnityLogWriter).GetMethods(BindingFlags.Static | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { try { methodInfo.Invoke(null, new object[1] { "" }); } catch { continue; } WriteStringToUnityLog = (Action)Delegate.CreateDelegate(typeof(Action), methodInfo); break; } if (WriteStringToUnityLog == null) { Logger.Log((LogLevel)2, (object)"Unable to start Unity log writer"); } } public void LogEvent(object sender, LogEventArgs eventArgs) { if (!(eventArgs.Source is UnityLogSource) && (LogConsoleToUnity.Value || eventArgs.Source.SourceName != "Console")) { WriteStringToUnityLog?.Invoke(eventArgs.ToStringLine()); } } public void Dispose() { } } public class UnityLogSource : ILogSource, IDisposable { private bool disposed; public string SourceName { get; } = "Unity Log"; public event EventHandler LogEvent; private static event EventHandler InternalUnityLogMessage; public UnityLogSource() { InternalUnityLogMessage += UnityLogMessageHandler; } public void Dispose() { if (!disposed) { InternalUnityLogMessage -= UnityLogMessageHandler; disposed = true; } } private void UnityLogMessageHandler(object sender, LogEventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown LogEventArgs e = new LogEventArgs(eventArgs.Data, eventArgs.Level, (ILogSource)(object)this); this.LogEvent?.Invoke(this, e); } static UnityLogSource() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown LogCallback val = new LogCallback(OnUnityLogMessageReceived); EventInfo eventInfo = typeof(Application).GetEvent("logMessageReceived", BindingFlags.Static | BindingFlags.Public); if ((object)eventInfo != null) { eventInfo.AddEventHandler(null, (Delegate?)(object)val); return; } typeof(Application).GetMethod("RegisterLogCallback", BindingFlags.Static | BindingFlags.Public).Invoke(null, new object[1] { val }); } private static void OnUnityLogMessageReceived(string message, string stackTrace, LogType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected I4, but got Unknown //IL_001d: 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_0026: 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_0029: Invalid comparison between Unknown and I4 //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown LogLevel val; switch ((int)type) { case 0: case 1: case 4: val = (LogLevel)2; break; case 2: val = (LogLevel)4; break; default: val = (LogLevel)16; break; } if ((int)type == 4) { message = message + "\nStack trace:\n" + stackTrace; } UnityLogSource.InternalUnityLogMessage?.Invoke(null, new LogEventArgs((object)message, val, (ILogSource)null)); } } } namespace BepInEx.Unity.Mono.Configuration { public struct KeyboardShortcut { public static readonly KeyboardShortcut Empty; public static readonly IEnumerable AllKeyCodes; private static readonly KeyCode[] _modifierBlockKeyCodes; private readonly KeyCode[] _allKeys; public KeyCode MainKey { get { if (_allKeys != null && _allKeys.Length != 0) { return _allKeys[0]; } return (KeyCode)0; } } public IEnumerable Modifiers => _allKeys?.Skip(1) ?? Enumerable.Empty(); static KeyboardShortcut() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown Empty = default(KeyboardShortcut); AllKeyCodes = (KeyCode[])Enum.GetValues(typeof(KeyCode)); _modifierBlockKeyCodes = AllKeyCodes.Except((IEnumerable)(object)new KeyCode[8] { (KeyCode)323, (KeyCode)324, (KeyCode)325, (KeyCode)326, (KeyCode)327, (KeyCode)328, (KeyCode)329, default(KeyCode) }).ToArray(); TomlTypeConverter.AddConverter(typeof(KeyboardShortcut), new TypeConverter { ConvertToString = (object o, Type type) => ((KeyboardShortcut)o).Serialize(), ConvertToObject = (string s, Type type) => Deserialize(s) }); } public KeyboardShortcut(KeyCode mainKey, params KeyCode[] modifiers) : this(((IEnumerable)(object)new KeyCode[1] { (KeyCode)(int)mainKey }).Concat(modifiers).ToArray()) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected I4, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) if ((int)mainKey == 0 && modifiers.Any()) { throw new ArgumentException("Can't set mainKey to KeyCode.None if there are any modifiers"); } } private KeyboardShortcut(KeyCode[] keys) { _allKeys = SanitizeKeys(keys); } private static KeyCode[] SanitizeKeys(params KeyCode[] keys) { if (keys.Length == 0 || (int)keys[0] == 0) { return (KeyCode[])(object)new KeyCode[1]; } return ((IEnumerable)(object)new KeyCode[1] { keys[0] }).Concat(from x in keys.Skip(1).Distinct() where (int)x != (int)keys[0] orderby (int)x select x).ToArray(); } public static KeyboardShortcut Deserialize(string str) { try { return new KeyboardShortcut(((IEnumerable)str.Split(new char[5] { ' ', '+', ',', ';', '|' }, StringSplitOptions.RemoveEmptyEntries)).Select((Func)((string x) => (KeyCode)Enum.Parse(typeof(KeyCode), x))).ToArray()); } catch (SystemException ex) { Logger.Log((LogLevel)2, (object)("Failed to read keybind from settings: " + ex.Message)); return Empty; } } public unsafe string Serialize() { if (_allKeys == null) { return string.Empty; } return string.Join(" + ", _allKeys.Select((KeyCode x) => ((object)(*(KeyCode*)(&x))/*cast due to .constrained prefix*/).ToString()).ToArray()); } public bool IsDown() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) KeyCode mainKey = MainKey; if ((int)mainKey == 0) { return false; } if (Input.GetKeyDown(mainKey)) { return ModifierKeyTest(); } return false; } public bool IsPressed() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) KeyCode mainKey = MainKey; if ((int)mainKey == 0) { return false; } if (Input.GetKey(mainKey)) { return ModifierKeyTest(); } return false; } public bool IsUp() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) KeyCode mainKey = MainKey; if ((int)mainKey == 0) { return false; } if (Input.GetKeyUp(mainKey)) { return ModifierKeyTest(); } return false; } private bool ModifierKeyTest() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) KeyCode[] allKeys = _allKeys; KeyCode mainKey = MainKey; if (!allKeys.All((KeyCode c) => c == mainKey || Input.GetKey(c))) { return false; } return _modifierBlockKeyCodes.All((KeyCode c) => !Input.GetKey(c) || allKeys.Contains(c)); } public unsafe override string ToString() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)MainKey == 0) { return "Not set"; } return string.Join(" + ", _allKeys.Select((KeyCode c) => ((object)(*(KeyCode*)(&c))/*cast due to .constrained prefix*/).ToString()).ToArray()); } public override bool Equals(object obj) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (obj is KeyboardShortcut keyboardShortcut && MainKey == keyboardShortcut.MainKey) { return Modifiers.SequenceEqual(keyboardShortcut.Modifiers); } return false; } public override int GetHashCode() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)MainKey == 0) { return 0; } return _allKeys.Aggregate(_allKeys.Length, (int current, KeyCode item) => current * 31 + item); } } } namespace BepInEx.Unity.Mono.Bootstrap { public class UnityChainloader : BaseChainloader { private static readonly ConfigEntry ConfigUnityLogging = ConfigFile.CoreConfig.Bind("Logging", "UnityLogListening", true, "Enables showing unity log messages in the BepInEx logging system."); private static readonly ConfigEntry ConfigDiskWriteUnityLog = ConfigFile.CoreConfig.Bind("Logging.Disk", "WriteUnityLog", false, "Include unity log messages in log file output."); private static readonly bool staticStartHasBeenCalled = false; private string _consoleTitle; public static UnityChainloader Instance { get; set; } public static GameObject ManagerObject { get; private set; } protected override string ConsoleTitle => _consoleTitle; private static string UnityVersion { [MethodImpl(MethodImplOptions.NoInlining)] get { return Application.unityVersion; } } [Obsolete("This method is public due to a limitation with Unity 4.x. DO NOT CALL", true)] public static void StaticStart(string gameExePath = null) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown try { if (staticStartHasBeenCalled) { throw new InvalidOperationException("Cannot call StaticStart again"); } Logger.Log((LogLevel)32, (object)"Entering chainloader StaticStart"); UnityChainloader unityChainloader = new UnityChainloader(); ((BaseChainloader)unityChainloader).Initialize(gameExePath); ((BaseChainloader)unityChainloader).Execute(); Logger.Log((LogLevel)32, (object)"Exiting chainloader StaticStart"); } catch (Exception ex) { LogLevel val = (LogLevel)1; bool flag = default(bool); BepInExLogInterpolatedStringHandler val2 = new BepInExLogInterpolatedStringHandler(44, 1, val, ref flag); if (flag) { val2.AppendLiteral("Unable to complete chainloader StaticStart: "); val2.AppendFormatted(ex.Message); } Logger.Log(val, val2); Logger.Log((LogLevel)1, (object)ex.StackTrace); } } public override void Initialize(string gameExePath = null) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown try { Logger.Log((LogLevel)32, (object)"Entering chainloader initialize"); Instance = this; UnityTomlTypeConverters.AddUnityEngineConverters(); Logger.Log((LogLevel)32, (object)"Initializing ThreadingHelper"); ThreadingHelper.Initialize(); Logger.Log((LogLevel)32, (object)"Creating Manager object"); ManagerObject = new GameObject("BepInEx_Manager") { hideFlags = (HideFlags)61 }; Object.DontDestroyOnLoad((Object)(object)ManagerObject); Logger.Log((LogLevel)32, (object)"Getting game product name"); PropertyInfo property = typeof(Application).GetProperty("productName", BindingFlags.Static | BindingFlags.Public); _consoleTitle = $"{BaseChainloader.CurrentAssemblyName} {BaseChainloader.CurrentAssemblyVersion} - {property?.GetValue(null, null) ?? Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().ProcessName)}"; Logger.Log((LogLevel)32, (object)"Falling back to BaseChainloader initializer"); base.Initialize(gameExePath); Logger.Log((LogLevel)32, (object)"Exiting chainloader initialize"); } catch (Exception ex) { LogLevel val = (LogLevel)1; bool flag = default(bool); BepInExLogInterpolatedStringHandler val2 = new BepInExLogInterpolatedStringHandler(37, 1, val, ref flag); if (flag) { val2.AppendLiteral("Unable to complete chainloader init: "); val2.AppendFormatted(ex.Message); } Logger.Log(val, val2); Logger.Log((LogLevel)1, (object)ex.StackTrace); } } protected override void InitializeLoggers() { //IL_0015: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) base.InitializeLoggers(); Logger.Listeners.Add((ILogListener)(object)new UnityLogListener()); UnityVersion version = UnityInfo.Version; UnityInfo.SetRuntimeUnityVersion(UnityVersion); if (UnityInfo.Version != version) { LogLevel val = (LogLevel)16; bool flag = default(bool); BepInExLogInterpolatedStringHandler val2 = new BepInExLogInterpolatedStringHandler(21, 1, val, ref flag); if (flag) { val2.AppendLiteral("UnityPlayer version: "); val2.AppendFormatted(UnityInfo.Version); } Logger.Log(val, val2); } if (!ConfigDiskWriteUnityLog.Value) { DiskLogListener.BlacklistedSources.Add("Unity Log"); } ChainloaderLogHelper.RewritePreloaderLogs(); if (ConfigUnityLogging.Value) { Logger.Sources.Add((ILogSource)(object)new UnityLogSource()); } } public override BaseUnityPlugin LoadPlugin(PluginInfo pluginInfo, Assembly pluginAssembly) { return (BaseUnityPlugin)(object)ManagerObject.AddComponent(pluginAssembly.GetType(pluginInfo.TypeName)); } } }