Procházet zdrojové kódy

Revert "Change patcher output directory to Game Root"

This reverts commit e4644203f8ab42073fc2382baf2efd840c6978fe.
Usagirei před 7 roky
rodič
revize
bbe165db87

+ 1 - 1
BepInEx.Patcher/BepInEx.Patcher.csproj

@@ -18,7 +18,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>K:\</OutputPath>
+    <OutputPath>K:\KoikatuTrial_Data\Managed\</OutputPath>
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>

+ 8 - 15
BepInEx.Patcher/Program.cs

@@ -59,27 +59,20 @@ namespace BepInEx.Patcher
         static void InjectAssembly(AssemblyDefinition unity, AssemblyDefinition injected)
         {
             //Entry point
-            var originalInjectMethod = injected.MainModule.Types.First(x => x.Name == "Chainloader")
-                .Methods.First(x => x.Name == "Initialize");
+            var originalInjectMethod = injected.MainModule.Types.First(x => x.Name == "Chainloader").Methods.First(x => x.Name == "Initialize");
 
             var injectMethod = unity.MainModule.Import(originalInjectMethod);
 
-            var sceneManager = unity.MainModule.Types.First(x => x.Name == "Application");
+            var sceneManager = unity.MainModule.Types.First(x => x.Name == "SceneManager");
 
-            var voidType = unity.MainModule.Import(typeof(void));
-            var cctor = new MethodDefinition(".cctor",
-                Mono.Cecil.MethodAttributes.Static
-                | Mono.Cecil.MethodAttributes.Private
-                | Mono.Cecil.MethodAttributes.HideBySig
-                | Mono.Cecil.MethodAttributes.SpecialName
-                | Mono.Cecil.MethodAttributes.RTSpecialName,
-                voidType);
+            ILProcessor IL;
 
-            var ilp = cctor.Body.GetILProcessor();
-            ilp.Append(ilp.Create(OpCodes.Call, injectMethod));
-            ilp.Append(ilp.Create(OpCodes.Ret));
+            foreach (var loadScene in sceneManager.Methods.Where(x => x.Name == "LoadScene"))
+            {
+                IL = loadScene.Body.GetILProcessor();
 
-            sceneManager.Methods.Add(cctor);
+                IL.InsertBefore(loadScene.Body.Instructions[0], IL.Create(OpCodes.Call, injectMethod));
+            }
         }
     }
 }