From 5b79f8dfbaaa3765b3b50e35cc6846bcbddb2b4c Mon Sep 17 00:00:00 2001 From: NGnius Date: Tue, 22 Oct 2019 11:41:58 -0400 Subject: [PATCH] Create minimum dependency mod starter project --- TestMod/TestMod.csproj | 6 ------ TestMod/TestPatch.cs | 21 +++------------------ TestMod/TestPlugin.cs | 35 ++++++----------------------------- 3 files changed, 9 insertions(+), 53 deletions(-) diff --git a/TestMod/TestMod.csproj b/TestMod/TestMod.csproj index ee78617..c034e29 100644 --- a/TestMod/TestMod.csproj +++ b/TestMod/TestMod.csproj @@ -9,9 +9,6 @@ - - ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gamecraft\RobocraftX_Data\Managed\CommandLine.dll - ..\..\..\IPA\IPA\bin\Debug\IPA\Data\Managed\IllusionPlugin.dll @@ -21,9 +18,6 @@ ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gamecraft\RobocraftX_Data\Managed\UnityEngine.CoreModule.dll - - ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gamecraft\RobocraftX_Data\Managed\uREPL.dll - diff --git a/TestMod/TestPatch.cs b/TestMod/TestPatch.cs index 5ae8973..c7703d0 100644 --- a/TestMod/TestPatch.cs +++ b/TestMod/TestPatch.cs @@ -1,10 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Reflection; -using RobocraftX.GUI.CommandLine; using Harmony; using UnityEngine; @@ -13,25 +8,15 @@ namespace TestMod [HarmonyPatch] class TestPatch { - static void Prefix(string name, Action func, string description = "") + static void Prefix() { - Debug.Log("Registering "+name); - //uREPL.Log.Output("This is an unhelpful message"); + Debug.Log("Test Patch Prefix"); } [HarmonyTargetMethod] static MethodBase HTargetMethod(HarmonyInstance instance) { - Type CLUtility = AccessTools.TypeByName("RobocraftX.GUI.CommandLine.CommandLineUtility"); - MethodInfo[] methods = CLUtility.GetMethods(); - foreach (MethodInfo m in methods) - { - if (m.Name == "Register") { - return m; - } - } - Debug.Log("Defaulting to "+methods[0].Name); - return methods[0]; + throw new NotImplementedException(); } } } diff --git a/TestMod/TestPlugin.cs b/TestMod/TestPlugin.cs index 2e1828b..07c60ad 100644 --- a/TestMod/TestPlugin.cs +++ b/TestMod/TestPlugin.cs @@ -1,7 +1,6 @@ using System; using IllusionPlugin; using UnityEngine; -using uREPL; using Harmony; using System.Reflection; @@ -17,27 +16,22 @@ namespace TestMod public string Version { get; } = "v0.0.0a"; + public string HarmonyID { get; } = "org.git.exmods.base.testmod.testplugin"; + public void OnApplicationQuit() { - //throw new NotImplementedException(); + harmony.UnpatchAll(HarmonyID); + Debug.Log("TestPlugin shutdown complete"); } public void OnApplicationStart() { - Debug.Log("Hello World!"); if (harmony == null) { - harmony = HarmonyInstance.Create("org.git.exmods.gamecraft.testmod.testplugin"); + harmony = HarmonyInstance.Create(HarmonyID); harmony.PatchAll(Assembly.GetExecutingAssembly()); } - MethodInfo commandHelp = Harmony.AccessTools.Method(Harmony.AccessTools.TypeByName("RobocraftX.GUI.CommandLine.CommandLineUtility"), "SaveCommandHelp", new Type[] { typeof(string), typeof(string)}); - uREPL.RuntimeCommands.Register("Log", LogCommand, "this description is not shown anywhere"); - commandHelp.Invoke(null, new string[] { "Log", "Write a string to Player.log" }); - uREPL.RuntimeCommands.Register("Echo", EchoCommand, "this doesn't matter"); - commandHelp.Invoke(null, new string[] { "Echo", "Write a message to the command line" }); - uREPL.RuntimeCommands.Register("Exit", QuitCommand, "Close Gamecraft"); - commandHelp.Invoke(null, new string[] { "Exit", "Forcefully exit Gamecraft immediately" }); - Debug.Log("TestPlugin startup complete"); + Debug.Log("TestPlugin start & patch complete"); } public void OnFixedUpdate() @@ -63,23 +57,6 @@ namespace TestMod public void OnUpdate() { //throw new NotImplementedException(); - //UnityEngine.Debug.Log("Baby's first mod injection"); - } - - /* Log command method. This called by uREPL when the Log command is called from RCX */ - private void LogCommand(string msg) - { - Debug.Log(msg); - } - - private void EchoCommand(string msg) - { - uREPL.Log.Output(msg); - } - - private void QuitCommand() - { - UnityEngine.Application.Quit(); } } }