Line | |
---|
1 | using AllocsFixes.CustomCommands;
|
---|
2 | using System;
|
---|
3 | using System.Collections.Generic;
|
---|
4 | using System.Reflection;
|
---|
5 |
|
---|
6 | namespace AllocsFixes
|
---|
7 | {
|
---|
8 | public class CommandExtensions
|
---|
9 | {
|
---|
10 | public static void InitCommandExtensions (GameManager manager)
|
---|
11 | {
|
---|
12 | try {
|
---|
13 | ConsoleSdtd cons = manager.m_GUIConsole;
|
---|
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 | }
|
---|
27 | } catch (Exception e) {
|
---|
28 | Log.Out ("Error registering custom commands: " + e);
|
---|
29 | }
|
---|
30 | }
|
---|
31 | }
|
---|
32 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.