Skip to content

Commit 55a7455

Browse files
authored
Added GetAllCommands and OnCommandExecuted (#92)
* Added DebugLogConsole.GetAllCommands method to return list of all commands * Added DebugLogConsole.OnCommandExecuted event that's invoked each time a command is executed
1 parent afe348b commit 55a7455

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Plugins/IngameDebugConsole/Scripts/DebugLogConsole.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public static class DebugLogConsole
5454
{
5555
public delegate bool ParseFunction( string input, out object output );
5656

57+
public delegate void CommandExecutedDelegate( string command, object[] parameters );
58+
public static event CommandExecutedDelegate OnCommandExecuted;
59+
5760
// All the commands
5861
private static readonly List<ConsoleMethodInfo> methods = new List<ConsoleMethodInfo>();
5962
private static readonly List<ConsoleMethodInfo> matchingMethods = new List<ConsoleMethodInfo>( 4 );
@@ -212,6 +215,11 @@ public static void SearchAssemblyForConsoleMethods( Assembly assembly )
212215
}
213216
}
214217

218+
public static List<ConsoleMethodInfo> GetAllCommands()
219+
{
220+
return methods;
221+
}
222+
215223
// Logs the list of available commands
216224
public static void LogAllCommands()
217225
{
@@ -745,6 +753,9 @@ public static void ExecuteCommand( string command )
745753
else
746754
Debug.Log( "Returned: " + result.ToString() );
747755
}
756+
757+
if( OnCommandExecuted != null )
758+
OnCommandExecuted( methodToExecute.command, parameters );
748759
}
749760
}
750761

@@ -1507,4 +1518,4 @@ private static bool ParseVector( string input, Type vectorType, out object outpu
15071518
return true;
15081519
}
15091520
}
1510-
}
1521+
}

0 commit comments

Comments
 (0)