private static void LoadDLLs(bool plugins = false) { string searchdir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, (plugins ? "Plugins" : "Mods")); if (!Directory.Exists(searchdir)) { Directory.CreateDirectory(searchdir); } else { // DLL string[] files = Directory.GetFiles(searchdir, "*.dll"); if (files.Length > 0) { for (int i = 0; i < files.Count(); i++) { string file = files[i]; if (!string.IsNullOrEmpty(file)) { if (plugins) { if ((Imports.IsDevPluginsOnly() && !file.EndsWith("-dev.dll")) || (!Imports.IsDevPluginsOnly() && file.EndsWith("-dev.dll"))) { continue; } } else { if ((Imports.IsDevModsOnly() && !file.EndsWith("-dev.dll")) || (!Imports.IsDevModsOnly() && file.EndsWith("-dev.dll"))) { continue; } } try { LoadAssembly(File.ReadAllBytes(file), plugins, file); } catch (Exception e) { MelonModLogger.LogError("Unable to load " + file + ":\n" + e.ToString()); MelonModLogger.Log("------------------------------"); } } } } // ZIP string[] zippedFiles = Directory.GetFiles(searchdir, "*.zip"); if (zippedFiles.Length > 0) { for (int i = 0; i < zippedFiles.Count(); i++) { string file = zippedFiles[i]; if (!string.IsNullOrEmpty(file)) { try { using (var fileStream = File.OpenRead(file)) { using (var zipInputStream = new ZipInputStream(fileStream)) { ZipEntry entry; while ((entry = zipInputStream.GetNextEntry()) != null) { string filename = Path.GetFileName(entry.Name); if (string.IsNullOrEmpty(filename) || !filename.EndsWith(".dll")) { continue; } if (plugins) { if ((Imports.IsDevPluginsOnly() && !filename.EndsWith("-dev.dll")) || (!Imports.IsDevPluginsOnly() && filename.EndsWith("-dev.dll"))) { continue; } } else { if ((Imports.IsDevModsOnly() && !filename.EndsWith("-dev.dll")) || (!Imports.IsDevModsOnly() && filename.EndsWith("-dev.dll"))) { continue; } } using (var unzippedFileStream = new MemoryStream()) { int size = 0; byte[] buffer = new byte[4096]; while (true) { size = zipInputStream.Read(buffer, 0, buffer.Length); if (size > 0) { unzippedFileStream.Write(buffer, 0, size); } else { break; } } LoadAssembly(unzippedFileStream.ToArray(), plugins, (file + "/" + filename)); } } } } } catch (Exception e) { MelonModLogger.LogError("Unable to load " + file + ":\n" + e.ToString()); MelonModLogger.Log("------------------------------"); } } } } } }