public StarcraftBotProxy() { string dll = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Properties.Settings.Default.BotDLL); if (!File.Exists(dll)) { err = "DLL [" + dll + "] not Found"; return; } Assembly a = Assembly.LoadFile(dll); if (a == null) { err = "Could not load Assembly"; return; } Type botType = a.GetExportedTypes().Where((t) => (t.GetInterfaces().Contains(typeof(BWAPI.IStarcraftBot)))).FirstOrDefault(); if (botType == null) { err = "No Types implement IStarcraftBot"; return; } var ci = botType.GetConstructor(new Type[0]); if (ci == null) { err = "No Constructor that take 0 arguments for [" + botType.FullName + "]"; return; } realBot = (BWAPI.IStarcraftBot)ci.Invoke(new object[0]); }
public bool RegisterListener(BWAPI.IStarcraftBot client, string name) { if (name.Length < 1 || client == null || clients.ContainsKey(name)) { return(false); } clients.Add(name, client); return(true); }
static void loadBot() { string dll = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ClrAIModuleLoader.Properties.Settings.Default.BotDLL); System.Console.WriteLine("Loading Bot [{0}]",dll); if (!File.Exists(dll)) { throw new BotLoaderException("DLL [" + dll + "] not Found"); } //patch in support for loading bwapi-clr instead of monobridgeai-interop patchmonointeropcatch(); Assembly a = Assembly.LoadFile(dll); if (a == null) { throw new BotLoaderException("Could not load Assembly"); } System.Type botType = a.GetExportedTypes().Where((t) => (t.GetInterfaces().Contains(typeof(BWAPI.IStarcraftBot)))).FirstOrDefault(); if (botType == null) { throw new BotLoaderException("No Types implement IStarcraftBot"); } var ci = botType.GetConstructor(new System.Type[0]); if (ci == null) { throw new BotLoaderException("No Constructor that take 0 arguments for [" + botType.FullName + "]"); } client = (BWAPI.IStarcraftBot)ci.Invoke(new object[0]); System.Console.WriteLine("Bot Loaded: OK"); }
static void loadBot() { string dll = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), ClrAIModuleLoader.Properties.Settings.Default.BotDLL); System.Console.WriteLine("Loading Bot [{0}]", dll); if (!File.Exists(dll)) { throw new BotLoaderException("DLL [" + dll + "] not Found"); } //patch in support for loading bwapi-clr instead of monobridgeai-interop patchmonointeropcatch(); Assembly a = Assembly.LoadFile(dll); if (a == null) { throw new BotLoaderException("Could not load Assembly"); } System.Type botType = a.GetExportedTypes().Where((t) => (t.GetInterfaces().Contains(typeof(BWAPI.IStarcraftBot)))).FirstOrDefault(); if (botType == null) { throw new BotLoaderException("No Types implement IStarcraftBot"); } var ci = botType.GetConstructor(new System.Type[0]); if (ci == null) { throw new BotLoaderException("No Constructor that take 0 arguments for [" + botType.FullName + "]"); } client = (BWAPI.IStarcraftBot)ci.Invoke(new object[0]); System.Console.WriteLine("Bot Loaded: OK"); }