|
- using System;
- using System.Reflection;
- using Harmony;
- using UnityEngine;
- using Unity.Entities;
- using RobocraftX;
- using RobocraftX.GUI.CommandLine;
- using RobocraftX.Multiplayer;
- using Svelto.ECS;
- using Svelto.Context;
-
- namespace ExtraCommands
- {
- [HarmonyPatch]
- class CommandLineCompositionRootUnregisterCommandPatch
- {
- static void Prefix()
- {
- MethodInfo commandRemoveHelp = Harmony.AccessTools.Method(Harmony.AccessTools.TypeByName("RobocraftX.GUI.CommandLine.CommandLineUtility"), "SaveCommandHelp", new Type[] { typeof(string) });
- foreach (Type t in typeof(CustomCommandEngine).Assembly.GetTypes())
- {
- CustomCommandAttribute[] attributes = (CustomCommandAttribute[])t.GetCustomAttributes(typeof(CustomCommandAttribute), false);
- foreach (CustomCommandAttribute attr in attributes)
- {
- if (attr != null && t.IsSubclassOf(typeof(CustomCommandEngine)))
- {
- // remove Gamecraft help command
- commandRemoveHelp.Invoke(null, new string[] { attr.Name });
- }
- }
- }
- }
-
- [HarmonyTargetMethod]
- static MethodBase HTargetMethod(HarmonyInstance instance)
- {
- return _OnContextDestroyedMethodInfo((new CommandLineCompositionRoot()).OnContextDestroyed);
- }
-
- private static MethodInfo _OnContextDestroyedMethodInfo(Action a)
- {
- return a.Method;
- }
- }
- }
|