protected virtual T GetValue() { try { var strVal = Config.GetEntry(Key, _defaultStr, Section); return(_strToObj(strVal)); } catch (Exception ex) { BepInLogger.Log("ConfigWrapper Get Converter Exception: " + ex.Message); return(_default); } }
protected virtual T GetValue() { try { var strVal = Config.GetEntry(Key, _defaultStr, Section); var obj = _strToObj(strVal); // Always update in case config was changed from outside _lastValue = obj; _lastValueSet = true; return(obj); } catch (Exception ex) { Logger.LogError("ConfigWrapper Get Converter Exception: " + ex.Message); return(_default); } }
/// <summary> /// The entry point for BepInEx, called on the very first LoadScene() from UnityEngine. /// </summary> public static void Initialize() { if (loaded) { return; } if (!Directory.Exists(Common.Utility.PluginsDirectory)) { Directory.CreateDirectory(Utility.PluginsDirectory); } if (bool.Parse(Config.GetEntry("console", "false")) || bool.Parse(Config.GetEntry("console-shiftjis", "false"))) { try { UnityInjector.ConsoleUtil.ConsoleWindow.Attach(); if (bool.Parse(Config.GetEntry("console-shiftjis", "false"))) { UnityInjector.ConsoleUtil.ConsoleEncoding.ConsoleCodePage = 932; } } catch { BepInLogger.Log("Failed to allocate console!", true); } } try { BepInLogger.Log($"BepInEx {Assembly.GetExecutingAssembly().GetName().Version}"); BepInLogger.Log("Chainloader started"); UnityEngine.Object.DontDestroyOnLoad(ManagerObject); string currentProcess = Process.GetCurrentProcess().ProcessName.ToLower(); var pluginTypes = TypeLoader.LoadTypes <BaseUnityPlugin>(Utility.PluginsDirectory) .Where(plugin => { //Perform a filter for currently running process var filters = TypeLoader.GetAttributes <BepInProcess>(plugin); if (!filters.Any()) { return(true); } return(filters.Any(x => x.ProcessName.ToLower().Replace(".exe", "") == currentProcess)); }) .ToList(); BepInLogger.Log($"{pluginTypes.Count} plugins selected"); Dictionary <Type, IEnumerable <Type> > dependencyDict = new Dictionary <Type, IEnumerable <Type> >(); foreach (Type t in pluginTypes) { try { IEnumerable <Type> dependencies = TypeLoader.GetDependencies(t, pluginTypes); dependencyDict[t] = dependencies; } catch (MissingDependencyException) { var metadata = TypeLoader.GetMetadata(t); BepInLogger.Log($"Cannot load [{metadata.Name}] due to missing dependencies."); } } pluginTypes = TopologicalSort(dependencyDict.Keys, x => dependencyDict[x]).ToList(); foreach (Type t in pluginTypes) { try { var metadata = TypeLoader.GetMetadata(t); var plugin = (BaseUnityPlugin)ManagerObject.AddComponent(t); Plugins.Add(plugin); BepInLogger.Log($"Loaded [{metadata.Name} {metadata.Version}]"); } catch (Exception ex) { BepInLogger.Log($"Error loading [{t.Name}] : {ex.Message}"); } } } catch (Exception ex) { UnityInjector.ConsoleUtil.ConsoleWindow.Attach(); Console.WriteLine("Error occurred starting the game"); Console.WriteLine(ex.ToString()); } loaded = true; }