/// <summary> /// High level connnected/disconnected events so we can keep track of our threads by proxy /// </summary> /// <param name="callbot"></param> /// <param name="eventt"></param> public void handlebotEvent(PhysicsBot callbot, EventType eventt) { switch (eventt) { case EventType.CONNECTED: m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Connected"); numbots++; break; case EventType.DISCONNECTED: m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Disconnected"); m_td[m_lBot.IndexOf(callbot)].Abort(); numbots--; if (numbots > 1) { Environment.Exit(0); } break; } }
/// <summary> /// This starts up the bot and stores the thread for the bot in the thread array /// </summary> /// <param name="pos">The position in the thread array to stick the bot's thread</param> /// <param name="cs">Configuration of the bot</param> public void startupBot(int pos, IConfig cs) { PhysicsBot pb = new PhysicsBot(cs); pb.OnConnected += handlebotEvent; pb.OnDisconnected += handlebotEvent; if (cs.GetString("firstname", "random") == "random") { pb.firstname = CreateRandomName(); } if (cs.GetString("lastname", "random") == "random") { pb.lastname = CreateRandomName(); } m_td[pos] = new Thread(pb.startup); m_td[pos].Name = "CampBot_" + pos; m_td[pos].IsBackground = true; m_td[pos].Start(); m_lBot.Add(pb); }
/// <summary> /// High level connnected/disconnected events so we can keep track of our threads by proxy /// </summary> /// <param name="callbot"></param> /// <param name="eventt"></param> public void handlebotEvent(PhysicsBot callbot, EventType eventt) { switch (eventt) { case EventType.CONNECTED: m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Connected"); numbots++; break; case EventType.DISCONNECTED: m_log.Info("[ " + callbot.firstname + " " + callbot.lastname + "]: Disconnected"); m_td[m_lBot.IndexOf(callbot)].Abort(); numbots--; if (numbots > 1) Environment.Exit(0); break; } }
/// <summary> /// This starts up the bot and stores the thread for the bot in the thread array /// </summary> /// <param name="pos">The position in the thread array to stick the bot's thread</param> /// <param name="cs">Configuration of the bot</param> public void startupBot(int pos, IConfig cs) { PhysicsBot pb = new PhysicsBot(cs); pb.OnConnected += handlebotEvent; pb.OnDisconnected += handlebotEvent; if (cs.GetString("firstname", "random") == "random") pb.firstname = CreateRandomName(); if (cs.GetString("lastname", "random") == "random") pb.lastname = CreateRandomName(); m_td[pos] = new Thread(pb.startup); m_td[pos].Name = "CampBot_" + pos; m_td[pos].IsBackground = true; m_td[pos].Start(); m_lBot.Add(pb); ThreadTracker.Add(m_td[pos]); }