瀏覽代碼

Remove path properties from Utility

Bepis 6 年之前
父節點
當前提交
83c39e0c44
共有 4 個文件被更改,包括 8 次插入19 次删除
  1. 1 12
      BepInEx.Common/Utility.cs
  2. 3 3
      BepInEx/Bootstrap/Chainloader.cs
  3. 3 3
      BepInEx/Bootstrap/Preloader.cs
  4. 1 1
      BepInEx/Config.cs

+ 1 - 12
BepInEx.Common/Utility.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.Diagnostics;
 using System.IO;
 using System.Linq;
 using System.Reflection;
@@ -13,16 +12,6 @@ namespace BepInEx.Common
     public static class Utility
     {
         /// <summary>
-        /// The directory that the game .exe is being run from.
-        /// </summary>
-        public static string ExecutingDirectory { get; } = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
-
-        /// <summary>
-        /// The path that the plugins folder is located.
-        /// </summary>
-        public static string PluginsDirectory { get; } = Path.Combine(ExecutingDirectory, "BepInEx");
-
-        /// <summary>
         /// Combines multiple paths together, as the specfic method is not availble in .NET 3.5.
         /// </summary>
         /// <param name="parts">The multiple paths to combine together.</param>
@@ -119,4 +108,4 @@ namespace BepInEx.Common
             return true;
         }
     }
-}
+}

+ 3 - 3
BepInEx/Bootstrap/Chainloader.cs

@@ -38,8 +38,8 @@ namespace BepInEx.Bootstrap
 			if (_loaded)
 				return;
 
-			if (!Directory.Exists(Utility.PluginsDirectory))
-				Directory.CreateDirectory(Utility.PluginsDirectory);
+			if (!Directory.Exists(Paths.PluginPath))
+				Directory.CreateDirectory(Paths.PluginPath);
 
 			Preloader.AllocateConsole();
 
@@ -67,7 +67,7 @@ namespace BepInEx.Bootstrap
 
 				string currentProcess = Process.GetCurrentProcess().ProcessName.ToLower();
 
-				var pluginTypes = TypeLoader.LoadTypes<BaseUnityPlugin>(Utility.PluginsDirectory)
+				var pluginTypes = TypeLoader.LoadTypes<BaseUnityPlugin>(Paths.PluginPath)
 					.Where(plugin =>
 					{
 						//Perform a filter for currently running process

+ 3 - 3
BepInEx/Bootstrap/Preloader.cs

@@ -258,11 +258,11 @@ namespace BepInEx.Bootstrap
 				}
 				else
 				{
-					foreach (var loadScene in entryType.Methods.Where(x => x.Name == entrypointMethod))
+					foreach (var method in entryType.Methods.Where(x => x.Name == entrypointMethod))
 					{
-						var il = loadScene.Body.GetILProcessor();
+						var il = method.Body.GetILProcessor();
 
-						il.InsertBefore(loadScene.Body.Instructions[0], il.Create(OpCodes.Call, injectMethod));
+						il.InsertBefore(method.Body.Instructions[0], il.Create(OpCodes.Call, injectMethod));
 					}
 				}
 			}

+ 1 - 1
BepInEx/Config.cs

@@ -14,7 +14,7 @@ namespace BepInEx
     {
         private static readonly Dictionary<string, Dictionary<string, string>> cache = new Dictionary<string, Dictionary<string, string>>();
 
-        private static string configPath => Path.Combine(Common.Utility.PluginsDirectory, "config.ini");
+        private static string configPath => Path.Combine(Paths.PluginPath, "config.ini");
 
         private static readonly Regex sanitizeKeyRegex = new Regex(@"[^a-zA-Z0-9\-\.]+");