Rev | Line | |
---|
[130] | 1 | using AllocsFixes.CustomCommands;
|
---|
[96] | 2 | using System;
|
---|
[107] | 3 | using System.Collections.Generic;
|
---|
[198] | 4 | using System.Reflection;
|
---|
[96] | 5 |
|
---|
[130] | 6 | namespace AllocsFixes
|
---|
[96] | 7 | {
|
---|
[130] | 8 | public class CommandExtensions
|
---|
[96] | 9 | {
|
---|
[130] | 10 | public static void InitCommandExtensions (GameManager manager)
|
---|
| 11 | {
|
---|
| 12 | try {
|
---|
[163] | 13 | ConsoleSdtd cons = manager.m_GUIConsole;
|
---|
[198] | 14 | string ns = "AllocsFixes.CustomCommands";
|
---|
| 15 | string basetype = "ConsoleCommand";
|
---|
| 16 |
|
---|
| 17 | foreach (Type t in Assembly.GetExecutingAssembly ().GetTypes()) {
|
---|
| 18 | if (t.IsClass && t.Namespace.Equals (ns) && t.BaseType.Name.Equals (basetype)) {
|
---|
| 19 | try {
|
---|
| 20 | ConstructorInfo ctor = t.GetConstructor (new Type[] {typeof(ConsoleSdtd)});
|
---|
| 21 | cons.AddCommand ((ConsoleCommand)ctor.Invoke (new object[] {cons}));
|
---|
| 22 | } catch (Exception e) {
|
---|
| 23 | Log.Out ("Could not register custom command \"" + t.Name + "\": " + e);
|
---|
| 24 | }
|
---|
| 25 | }
|
---|
| 26 | }
|
---|
[130] | 27 | } catch (Exception e) {
|
---|
| 28 | Log.Out ("Error registering custom commands: " + e);
|
---|
| 29 | }
|
---|
[107] | 30 | }
|
---|
[96] | 31 | }
|
---|
| 32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.