Paths.cs 2.1 KB

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