|
|
@@ -2,11 +2,15 @@ |
|
|
|
using IllusionPlugin; |
|
|
|
using UnityEngine; |
|
|
|
using uREPL; |
|
|
|
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"; |
|
|
@@ -21,7 +25,18 @@ namespace TestMod |
|
|
|
public void OnApplicationStart() |
|
|
|
{ |
|
|
|
Debug.Log("Hello World!"); |
|
|
|
RuntimeCommands.Register<object>("Log", LogCommand,"Write a message to Player.log (Runtime version)"); |
|
|
|
if (harmony == null) |
|
|
|
{ |
|
|
|
harmony = HarmonyInstance.Create("org.git.exmods.gamecraft.testmod.testplugin"); |
|
|
|
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<string>("Log", LogCommand, "this description is not shown anywhere"); |
|
|
|
commandHelp.Invoke(null, new string[] { "Log", "Write a string to Player.log" }); |
|
|
|
uREPL.RuntimeCommands.Register<string>("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"); |
|
|
|
} |
|
|
|
|
|
|
@@ -52,9 +67,19 @@ namespace TestMod |
|
|
|
} |
|
|
|
|
|
|
|
/* Log command method. This called by uREPL when the Log <object> command is called from RCX */ |
|
|
|
private void LogCommand(object msg) |
|
|
|
private void LogCommand(string msg) |
|
|
|
{ |
|
|
|
Debug.Log(msg); |
|
|
|
} |
|
|
|
|
|
|
|
private void EchoCommand(string msg) |
|
|
|
{ |
|
|
|
uREPL.Log.Output(msg); |
|
|
|
} |
|
|
|
|
|
|
|
private void QuitCommand() |
|
|
|
{ |
|
|
|
UnityEngine.Application.Quit(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |