using System.IO; using System.Reflection; namespace BepInEx { /// /// Paths used by BepInEx /// public static class Paths { internal static void SetExecutablePath(string executablePath, string bepinRootPath = null, string managedPath = null, string pluginPath = null) { ExecutablePath = executablePath; ProcessName = Path.GetFileNameWithoutExtension(executablePath); GameRootPath = Path.GetDirectoryName(executablePath); if (ManagedPath == null || managedPath != null) ManagedPath = managedPath ?? Utility.CombinePaths(GameRootPath, $"{ProcessName}_Data", "Managed"); if (BepInExRootPath == null || bepinRootPath != null) BepInExRootPath = bepinRootPath ?? Path.Combine(GameRootPath, "BepInEx"); ConfigPath = Path.Combine(BepInExRootPath, "config"); BepInExConfigPath = Path.Combine(ConfigPath, "BepInEx.cfg"); if (PluginPath == null || pluginPath != null) PluginPath = pluginPath ?? Path.Combine(BepInExRootPath, "plugins"); PatcherPluginPath = Path.Combine(BepInExRootPath, "patchers"); BepInExAssemblyDirectory = Path.Combine(BepInExRootPath, "core"); BepInExAssemblyPath = Path.Combine(BepInExAssemblyDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}.dll"); } /// /// The directory that the core BepInEx DLLs reside in. /// public static string BepInExAssemblyDirectory { get; private set; } /// /// The path to the core BepInEx DLL. /// public static string BepInExAssemblyPath { get; private set; } /// /// The path to the main BepInEx folder. /// public static string BepInExRootPath { get; private set; } /// /// The path of the currently executing program BepInEx is encapsulated in. /// public static string ExecutablePath { get; private set; } /// /// The directory that the currently executing process resides in. /// public static string GameRootPath { get; private set; } /// /// The path to the Managed folder of the currently running Unity game. /// public static string ManagedPath { get; private set; } /// /// The path to the config directory. /// public static string ConfigPath { get; private set; } /// /// The path to the global BepInEx configuration file. /// public static string BepInExConfigPath { get; private set; } /// /// The path to the patcher plugin folder which resides in the BepInEx folder. /// public static string PatcherPluginPath { get; private set; } /// /// The path to the plugin folder which resides in the BepInEx folder. /// /// This is ONLY guaranteed to be set correctly when Chainloader has been initialized. /// /// public static string PluginPath { get; private set; } /// /// The name of the currently executing process. /// public static string ProcessName { get; private set; } } }