|
|
@@ -11,12 +11,15 @@ using Svelto.Context; |
|
|
|
|
|
|
|
namespace ExtraCommands |
|
|
|
{ |
|
|
|
[HarmonyPatch] |
|
|
|
class CommandLineCompositionRootUnregisterCommandPatch |
|
|
|
class UnregisterCommandEngine : CustomCommandEngine |
|
|
|
{ |
|
|
|
static void Prefix() |
|
|
|
public UnregisterCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams) |
|
|
|
{ |
|
|
|
MethodInfo commandRemoveHelp = Harmony.AccessTools.Method(Harmony.AccessTools.TypeByName("RobocraftX.GUI.CommandLine.CommandLineUtility"), "SaveCommandHelp", new Type[] { typeof(string) }); |
|
|
|
} |
|
|
|
public override void Dispose() |
|
|
|
{ |
|
|
|
int count = 0; |
|
|
|
MethodInfo commandRemoveHelp = Harmony.AccessTools.Method(Harmony.AccessTools.TypeByName("RobocraftX.GUI.CommandLine.CommandLineUtility"), "UnregisterCommandHelp", new Type[] { typeof(string) }); |
|
|
|
foreach (Type t in typeof(CustomCommandEngine).Assembly.GetTypes()) |
|
|
|
{ |
|
|
|
CustomCommandAttribute[] attributes = (CustomCommandAttribute[])t.GetCustomAttributes(typeof(CustomCommandAttribute), false); |
|
|
@@ -26,20 +29,11 @@ namespace ExtraCommands |
|
|
|
{ |
|
|
|
// remove Gamecraft help command |
|
|
|
commandRemoveHelp.Invoke(null, new string[] { attr.Name }); |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[HarmonyTargetMethod] |
|
|
|
static MethodBase HTargetMethod(HarmonyInstance instance) |
|
|
|
{ |
|
|
|
return _OnContextDestroyedMethodInfo((new CommandLineCompositionRoot()).OnContextDestroyed); |
|
|
|
} |
|
|
|
|
|
|
|
private static MethodInfo _OnContextDestroyedMethodInfo(Action a) |
|
|
|
{ |
|
|
|
return a.Method; |
|
|
|
Debug.Log($"Removed {count} custom commands"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |