Disable unusable commands

This commit is contained in:
NGnius (Graham) 2019-11-05 16:43:49 -05:00
parent 181597cd2f
commit 915e6b6434
3 changed files with 3 additions and 42 deletions

View file

@ -16,8 +16,8 @@ using RobocraftX;
namespace ExtraCommands.Basics
{
[HarmonyPatch]
[CustomCommand]
//[HarmonyPatch]
//[CustomCommand("ToggleJumpEnabled")]
class ToggleJumpCommandEngine : CustomCommandEngine
{
private static bool isJumpEnabled = false;

View file

@ -1,39 +0,0 @@
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
{
class UnregisterCommandEngine : CustomCommandEngine
{
public UnregisterCommandEngine(UnityContext<FullGameCompositionRoot> ctxHolder, EnginesRoot enginesRoot, World physW, Action reloadGame, MultiplayerInitParameters mpParams) : base(ctxHolder, enginesRoot, physW, reloadGame, mpParams)
{
}
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);
foreach (CustomCommandAttribute attr in attributes)
{
if (attr != null && t.IsSubclassOf(typeof(CustomCommandEngine)))
{
// remove Gamecraft help command
commandRemoveHelp.Invoke(null, new string[] { attr.Name });
count++;
}
}
}
Debug.Log($"Removed {count} custom commands");
}
}
}

View file

@ -21,7 +21,7 @@ namespace ExtraCommands.Basics
public override void Ready()
{
CustomCommandUtility.Register<int>("Wait", WaitCommand, "Delay execution for a length of time (ms)");
CustomCommandUtility.Register<int>("Wait", WaitCommand, "Delay execution (freeze the game) for a length of time (ms)");
}
private void WaitCommand(int ms)