private void LoadPlugin(Type plugin_type, string filelocation, ref List <MelonBase> melonTbl) { IPlugin pluginInstance = Activator.CreateInstance(plugin_type) as IPlugin; string[] filter = null; if (pluginInstance is IEnhancedPlugin) { filter = ((IEnhancedPlugin)pluginInstance).Filter; } List <MelonGameAttribute> gamestbl = null; if ((filter != null) && (filter.Count() > 0)) { string exe_name = Path.GetFileNameWithoutExtension(string.Copy(MelonUtils.GetApplicationPath())); gamestbl = new List <MelonGameAttribute>(); bool game_found = false; foreach (string x in filter) { if (string.IsNullOrEmpty(x)) { continue; } gamestbl.Add(new MelonGameAttribute(name: x)); if (x.Equals(exe_name)) { game_found = true; } } if (!game_found) { MelonLogger.Error($"Incompatible Game for {filelocation}"); return; } } string plugin_name = pluginInstance.Name; if (string.IsNullOrEmpty(plugin_name)) { plugin_name = plugin_type.FullName; } if (MelonHandler.IsModAlreadyLoaded(plugin_name)) { MelonLogger.Error($"Duplicate File {plugin_name}: {filelocation}"); return; } string plugin_version = pluginInstance.Version; if (string.IsNullOrEmpty(plugin_version)) { plugin_version = asm.GetName().Version.ToString(); } if (string.IsNullOrEmpty(plugin_version) || plugin_version.Equals("0.0.0.0")) { plugin_version = "1.0.0.0"; } MelonModWrapper wrapper = new MelonCompatibilityLayer.WrapperData() { Assembly = asm, Info = new MelonInfoAttribute(typeof(MelonModWrapper), plugin_name, plugin_version), Games = (gamestbl != null) ? gamestbl.ToArray() : null, Priority = 0, Location = filelocation }.CreateMelon <MelonModWrapper>(); if (wrapper == null) { return; } wrapper.pluginInstance = pluginInstance; melonTbl.Add(wrapper); PluginManager._Plugins.Add(pluginInstance); }