Paths.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.IO;
  2. using System.Reflection;
  3. namespace BepInEx
  4. {
  5. /// <summary>
  6. /// Paths used by BepInEx
  7. /// </summary>
  8. public static class Paths
  9. {
  10. internal static void SetExecutablePath(string executablePath)
  11. {
  12. ExecutablePath = executablePath;
  13. ProcessName = Path.GetFileNameWithoutExtension(executablePath);
  14. GameRootPath = Path.GetDirectoryName(executablePath);
  15. ManagedPath = Utility.CombinePaths(GameRootPath, $"{ProcessName}_Data", "Managed");
  16. BepInExRootPath = Utility.CombinePaths(GameRootPath, "BepInEx");
  17. PluginPath = Utility.CombinePaths(BepInExRootPath, "plugins");
  18. PatcherPluginPath = Utility.CombinePaths(BepInExRootPath, "patchers");
  19. BepInExAssemblyDirectory = Utility.CombinePaths(BepInExRootPath, "core");
  20. BepInExAssemblyPath = Utility.CombinePaths(BepInExAssemblyDirectory, $"{Assembly.GetExecutingAssembly().GetName().Name}.dll");
  21. }
  22. internal static void SetPluginPath(string pluginPath)
  23. {
  24. PluginPath = Utility.CombinePaths(BepInExRootPath, pluginPath);
  25. }
  26. /// <summary>
  27. /// The directory that the core BepInEx DLLs reside in.
  28. /// </summary>
  29. public static string BepInExAssemblyDirectory { get; private set; }
  30. /// <summary>
  31. /// The path to the core BepInEx DLL.
  32. /// </summary>
  33. public static string BepInExAssemblyPath { get; private set; }
  34. /// <summary>
  35. /// The path to the main BepInEx folder.
  36. /// </summary>
  37. public static string BepInExRootPath { get; private set; }
  38. /// <summary>
  39. /// The path of the currently executing program BepInEx is encapsulated in.
  40. /// </summary>
  41. public static string ExecutablePath { get; private set; }
  42. /// <summary>
  43. /// The directory that the currently executing process resides in.
  44. /// </summary>
  45. public static string GameRootPath { get; private set; }
  46. /// <summary>
  47. /// The path to the Managed folder of the currently running Unity game.
  48. /// </summary>
  49. public static string ManagedPath { get; private set; }
  50. /// <summary>
  51. /// The path to the patcher plugin folder which resides in the BepInEx folder.
  52. /// </summary>
  53. public static string PatcherPluginPath { get; private set; }
  54. /// <summary>
  55. /// The path to the plugin folder which resides in the BepInEx folder.
  56. /// <para>
  57. /// This is ONLY guaranteed to be set correctly when Chainloader has been initialized.
  58. /// </para>
  59. /// </summary>
  60. public static string PluginPath { get; private set; }
  61. /// <summary>
  62. /// The name of the currently executing process.
  63. /// </summary>
  64. public static string ProcessName { get; private set; }
  65. }
  66. }