/// <summary> /// Add a bot to the runner. /// </summary> /// <param name="type"></param> /// <param name="username"></param> /// <param name="password"></param> public void AddBot(Type type, string username, string password) { List <VTankBot> bots = BotRunner.GetRunningBots(); // Remove old bot if it exists. for (int i = 0; i < bots.Count; ++i) { VTankBot bot = bots[i]; if (bot.AuthInfo.Username == username) { Print("Removed duplicate bot {0}.", username); BotRunner.Kill(bot); break; } } AuthInfo auth = new AuthInfo(username, password); BotRunner.Register(type, auth, null); BotRunner.Start(false); Print("Added new bot, {0}.", username); if (OnBotChange != null) { OnBotChange(null); } }
/// <summary> /// Move an online bot to the reserved bot list. /// </summary> /// <param name="username"></param> public void MoveBotToReserve(VTankBot bot) { reservedList.Add(bot); BotRunner.Kill(bot); Print("{0} moved to reserve.", bot.AuthInfo.Username); if (OnBotChange != null) { OnBotChange(bot); } }
/// <summary> /// Remove a bot from the entire bot manager, including the reserved list. /// </summary> /// <param name="username"></param> /// <returns></returns> public bool Remove(string username) { bool found = false; if (!BotRunner.Kill(username)) { VTankBot bot = reservedList.Find((b) => { return(b.AuthInfo.Username == username); }); if (bot != null) { found = reservedList.Remove(bot); } } else { found = true; } if (found && OnBotChange != null) { OnBotChange(null); } return(found); }