source: binary-improvements/7dtd-server-fixes/src/CommandExtensions.cs@ 205

Last change on this file since 205 was 198, checked in by alloc, 10 years ago

fixes

File size: 932 bytes
Line 
1using AllocsFixes.CustomCommands;
2using System;
3using System.Collections.Generic;
4using System.Reflection;
5
6namespace 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.