diff --git a/ExtraCommands.sln b/ExtraCommands.sln new file mode 100644 index 0000000..2d8f760 --- /dev/null +++ b/ExtraCommands.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29411.108 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExtraCommands", "extracommands\ExtraCommands.csproj", "{7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7FD5A7D8-4F3E-426A-B07D-7DC70442A4DF}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {72FB94D0-6C50-475B-81E0-C94C7D7A2A17} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md index 449fd01..b106b4d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,24 @@ -# extracommands +# ExtraCommands +Proof of concept mod and reference implementation + +## Installation + +1. Patch Gamecraft with [GCIPA](https://git.exmods.org/modtainers/GCIPA). +You should download the latest release and extract it to the Gamecraft folder. +To patch, drag `Gamecraft.exe` onto `IPA.exe`. You will need to redo this step whenever Gamecraft is updated. +2. Extract the TestMod zip into Gamecraft's `Plugins\` folder (GCIPA should have created this automatically in the previous step). You should see `0Harmony.dll` and `ExtraCommands.dll` in the `Plugins\` folder. If those files are in another folder in `Plugins\` it will not work. +3. Launch Gamecraft. +You can check the log file `%APPDATA%\..\LocalLow\FreeJam\RobocraftX\Player.log` to confirm. +You should be able to see a message near the top showing how many plugins have been loaded and their names. + +## Development + +Interested in making your own mod? +Clone this repository and modify the C# classes in `extracommands\`. +Patch Gamecraft with [GCIPA](#installation) +Build the solution and copy `bin\Debug\net45\extracommands.dll` and `bin\Debug\net45\0Harmony.dll` into Gamecraft's `Plugins\` folder. + +More information about the IPlugin and IEnhancedPlugin interface can be found [on the IPA repository](https://github.com/Eusth/IPA). + +More information about Harmony can be found [on the Harmony wiki](https://github.com/pardeike/Harmony/wiki). diff --git a/extracommands/ExtraCommands.csproj b/extracommands/ExtraCommands.csproj new file mode 100644 index 0000000..c034e29 --- /dev/null +++ b/extracommands/ExtraCommands.csproj @@ -0,0 +1,23 @@ + + + + net45 + + + + + + + + + ..\..\..\IPA\IPA\bin\Debug\IPA\Data\Managed\IllusionPlugin.dll + + + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gamecraft\RobocraftX_Data\Managed\UnityEngine.dll + + + ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Gamecraft\RobocraftX_Data\Managed\UnityEngine.CoreModule.dll + + + + diff --git a/extracommands/TestPatch.cs b/extracommands/TestPatch.cs new file mode 100644 index 0000000..c7703d0 --- /dev/null +++ b/extracommands/TestPatch.cs @@ -0,0 +1,22 @@ +using System; +using System.Reflection; +using Harmony; +using UnityEngine; + +namespace TestMod +{ + [HarmonyPatch] + class TestPatch + { + static void Prefix() + { + Debug.Log("Test Patch Prefix"); + } + + [HarmonyTargetMethod] + static MethodBase HTargetMethod(HarmonyInstance instance) + { + throw new NotImplementedException(); + } + } +} diff --git a/extracommands/TestPlugin.cs b/extracommands/TestPlugin.cs new file mode 100644 index 0000000..07c60ad --- /dev/null +++ b/extracommands/TestPlugin.cs @@ -0,0 +1,62 @@ +using System; +using IllusionPlugin; +using UnityEngine; +using Harmony; +using System.Reflection; + +namespace TestMod +{ + public class Plugin : IllusionPlugin.IEnhancedPlugin + { + public static HarmonyInstance harmony { get; protected set; } + + public string[] Filter { get; } = new string[] { "RobocraftX", "Gamecraft" }; + + public string Name { get; } = "TestPlugin"; + + public string Version { get; } = "v0.0.0a"; + + public string HarmonyID { get; } = "org.git.exmods.base.testmod.testplugin"; + + public void OnApplicationQuit() + { + harmony.UnpatchAll(HarmonyID); + Debug.Log("TestPlugin shutdown complete"); + } + + public void OnApplicationStart() + { + if (harmony == null) + { + harmony = HarmonyInstance.Create(HarmonyID); + harmony.PatchAll(Assembly.GetExecutingAssembly()); + } + Debug.Log("TestPlugin start & patch complete"); + } + + public void OnFixedUpdate() + { + //throw new NotImplementedException(); + } + + public void OnLateUpdate() + { + //throw new NotImplementedException(); + } + + public void OnLevelWasInitialized(int level) + { + //throw new NotImplementedException(); + } + + public void OnLevelWasLoaded(int level) + { + //throw new NotImplementedException(); + } + + public void OnUpdate() + { + //throw new NotImplementedException(); + } + } +}