diff --git a/BepInEx.Patcher/BepInEx.Patcher.csproj b/BepInEx.Patcher/BepInEx.Patcher.csproj
index 79a0205..50038cd 100644
--- a/BepInEx.Patcher/BepInEx.Patcher.csproj
+++ b/BepInEx.Patcher/BepInEx.Patcher.csproj
@@ -54,6 +54,7 @@
+
diff --git a/BepInEx.Patcher/Internal/TitleScenePlugin.cs b/BepInEx.Patcher/Internal/TitleScenePlugin.cs
new file mode 100644
index 0000000..971eb29
--- /dev/null
+++ b/BepInEx.Patcher/Internal/TitleScenePlugin.cs
@@ -0,0 +1,40 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Mono.Cecil;
+using Mono.Cecil.Cil;
+
+namespace BepInEx.Patcher.Internal
+{
+ public class TitleScenePlugin : IPatchPlugin
+ {
+ public void Patch(AssemblyDefinition assembly)
+ {
+ TypeDefinition CustomTrialTitle = assembly.MainModule.Types.First(x => x.Name == "CustomTrialTitle");
+ var enter = CustomTrialTitle.Methods.First(x => x.Name == "Enter");
+
+
+ var IL = enter.Body.GetILProcessor();
+ //IL.Replace(enter.Body.Instructions[32], IL.Create(OpCodes.Ldstr, "Title"));
+ IL.Replace(enter.Body.Instructions[15], IL.Create(OpCodes.Ldstr, "Title"));
+
+ var lambda = (MethodDefinition)enter.Body.Instructions[45].Operand;
+
+ var onCustom = CustomTrialTitle.Methods.First(x => x.Name == "OnCustom");
+ onCustom.Body.Instructions[1].Operand = "Title";
+
+ IL = lambda.Body.GetILProcessor();
+
+ var method = (GenericInstanceMethod)lambda.Body.Instructions[2].Operand;
+
+ method.GenericArguments[0] = assembly.MainModule.Types.First(x => x.Name == "TitleScene");
+
+ //IL.Remove(lambda.Body.Instructions[1]);
+ //IL.Remove(lambda.Body.Instructions[0]);
+
+ //IL.InsertBefore(lambda.Body.Instructions[0], IL.Create(OpCodes.Ldstr, "Title"));
+ }
+ }
+}
diff --git a/BepInEx.Patcher/Program.cs b/BepInEx.Patcher/Program.cs
index a3845c8..8aa966f 100644
--- a/BepInEx.Patcher/Program.cs
+++ b/BepInEx.Patcher/Program.cs
@@ -46,17 +46,22 @@ namespace BepInEx.Patcher
IPatchPlugin slider = new SliderPlugin();
slider.Patch(assembly);
+ IPatchPlugin title = new TitleScenePlugin();
+ title.Patch(assembly);
- InjectAssembly(unity, injected);
+
+ InjectAssembly(assembly, unity, injected);
assembly.Write(outputDLL);
unity.Write(unityOutputDLL);
}
- static void InjectAssembly(AssemblyDefinition unity, AssemblyDefinition injected)
+ static void InjectAssembly(AssemblyDefinition assembly, AssemblyDefinition unity, AssemblyDefinition injected)
{
- //unity.MainModule.AssemblyReferences.Add(new AssemblyNameReference(injected.Name, injected.MainModule.v);
+ ILProcessor IL;
+
+ //Initialize
var originalInjectMethod = injected.MainModule.Types.First(x => x.Name == "Target").Methods.First(x => x.Name == "Initialize");
var injectMethod = unity.MainModule.Import(originalInjectMethod);
@@ -65,10 +70,33 @@ namespace BepInEx.Patcher
foreach (var loadScene in sceneManager.Methods.Where(x => x.Name == "LoadScene"))
{
- var IL = loadScene.Body.GetILProcessor();
+ IL = loadScene.Body.GetILProcessor();
IL.InsertBefore(loadScene.Body.Instructions[0], IL.Create(OpCodes.Call, injectMethod));
}
+
+
+ //CustomInitializer
+ originalInjectMethod = injected.MainModule.Types.First(x => x.Name == "Target").Methods.First(x => x.Name == "InitializeCustomBase");
+
+ injectMethod = assembly.MainModule.Import(originalInjectMethod);
+
+ var customControl = assembly.MainModule.Types.First(x => x.Name == "CustomControl");
+
+ var customInitialize = customControl.Methods.First(x => x.Name == "Initialize");
+
+ IL = customInitialize.Body.GetILProcessor();
+
+ //IL.Replace(customInitialize.Body.Instructions[169], IL.Create(OpCodes.Call, customControl.Properties[4].GetMethod));
+ //IL.Append(IL.Create(OpCodes.Call, injectMethod));
+
+ IL.Replace(customInitialize.Body.Instructions[169], IL.Create(OpCodes.Call, injectMethod));
+
+ customInitialize.Body.Instructions[169].Offset = 0x01f0;
+
+ IL.Append(IL.Create(OpCodes.Ret));
+
+ //injected.MainModule.Import(assembly.MainModule.Types.First(x => x.Name == "CustomBase"));
}
}
}
diff --git a/BepInEx/BepInEx.csproj b/BepInEx/BepInEx.csproj
index 270db82..f447e47 100644
--- a/BepInEx/BepInEx.csproj
+++ b/BepInEx/BepInEx.csproj
@@ -36,8 +36,9 @@
-
- M:\koikatu\KoikatuTrial_Data\Managed\Assembly-CSharp.dll
+
+ False
+ M:\koikatu\KoikatuTrial_Data\Managed\Assembly-CSharp-original.dll
..\packages\Newtonsoft.Json.10.0.3\lib\net20\Newtonsoft.Json.dll
@@ -46,8 +47,9 @@
-
- M:\koikatu\KoikatuTrial_Data\Managed\UnityEngine.dll
+
+ False
+ M:\koikatu\KoikatuTrial_Data\Managed\UnityEngine-original.dll
False
diff --git a/BepInEx/Target.cs b/BepInEx/Target.cs
index 9499fa1..4ce79b7 100644
--- a/BepInEx/Target.cs
+++ b/BepInEx/Target.cs
@@ -1,4 +1,5 @@
-using System;
+using ChaCustom;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -14,9 +15,24 @@ namespace BepInEx
if (loaded)
return;
- UnityEngine.Debug.logger.LogWarning("inject", "Loaded!!!");
+ UnityEngine.Debug.logger.Log("inject: Loaded!!!");
+
+
loaded = true;
}
+
+ public static void InitializeCustomBase() //CustomBase customBase
+ {
+ UnityEngine.Debug.logger.Log("inject: CustomBase loaded!!!");
+
+ CustomBase customBase = Singleton.Instance;
+
+ foreach (var entry in customBase.lstSelectList)
+ {
+ UnityEngine.Debug.Log(entry.list[2]);
+ entry.list[2] = "TL TEST TL TEST";
+ }
+ }
}
}