aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tools/pCampBot/BotManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tools/pCampBot/BotManager.cs')
-rw-r--r--OpenSim/Tools/pCampBot/BotManager.cs36
1 files changed, 27 insertions, 9 deletions
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index b05bd6d..704770a 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -37,6 +37,7 @@ using log4net.Repository;
37using Nini.Config; 37using Nini.Config;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
40using pCampBot.Interfaces;
40 41
41namespace pCampBot 42namespace pCampBot
42{ 43{
@@ -48,7 +49,7 @@ namespace pCampBot
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 50
50 protected CommandConsole m_console; 51 protected CommandConsole m_console;
51 protected List<PhysicsBot> m_lBot; 52 protected List<Bot> m_lBot;
52 protected Random somthing = new Random(Environment.TickCount); 53 protected Random somthing = new Random(Environment.TickCount);
53 protected int numbots = 0; 54 protected int numbots = 0;
54 public IConfig Config { get; private set; } 55 public IConfig Config { get; private set; }
@@ -102,7 +103,7 @@ namespace pCampBot
102// "add bots <number>", 103// "add bots <number>",
103// "Add more bots", HandleAddBots); 104// "Add more bots", HandleAddBots);
104 105
105 m_lBot = new List<PhysicsBot>(); 106 m_lBot = new List<Bot>();
106 } 107 }
107 108
108 /// <summary> 109 /// <summary>
@@ -119,10 +120,24 @@ namespace pCampBot
119 string password = cs.GetString("password"); 120 string password = cs.GetString("password");
120 string loginUri = cs.GetString("loginuri"); 121 string loginUri = cs.GetString("loginuri");
121 122
123 HashSet<string> behaviourSwitches = new HashSet<string>();
124 Array.ForEach<string>(
125 cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
126
122 for (int i = 0; i < botcount; i++) 127 for (int i = 0; i < botcount; i++)
123 { 128 {
124 string lastName = string.Format("{0}_{1}", lastNameStem, i); 129 string lastName = string.Format("{0}_{1}", lastNameStem, i);
125 startupBot(i, this, firstName, lastName, password, loginUri); 130
131 List<IBehaviour> behaviours = new List<IBehaviour>();
132
133 // Hard-coded for now
134 if (behaviourSwitches.Contains("p"))
135 behaviours.Add(new PhysicsBehaviour());
136
137 if (behaviourSwitches.Contains("g"))
138 behaviours.Add(new GrabbingBehaviour());
139
140 startupBot(i, this, behaviours, firstName, lastName, password, loginUri);
126 } 141 }
127 } 142 }
128 143
@@ -150,14 +165,17 @@ namespace pCampBot
150 /// This starts up the bot and stores the thread for the bot in the thread array 165 /// This starts up the bot and stores the thread for the bot in the thread array
151 /// </summary> 166 /// </summary>
152 /// <param name="pos">The position in the thread array to stick the bot's thread</param> 167 /// <param name="pos">The position in the thread array to stick the bot's thread</param>
153 /// <param name="cs">Configuration of the bot</param> 168 /// <param name="bm"></param>
169 /// <param name="behaviours">Behaviours for this bot to perform.</param>
154 /// <param name="firstName">First name</param> 170 /// <param name="firstName">First name</param>
155 /// <param name="lastName">Last name</param> 171 /// <param name="lastName">Last name</param>
156 /// <param name="password">Password</param> 172 /// <param name="password">Password</param>
157 /// <param name="loginUri">Login URI</param> 173 /// <param name="loginUri">Login URI</param>
158 public void startupBot(int pos, BotManager bm, string firstName, string lastName, string password, string loginUri) 174 public void startupBot(
175 int pos, BotManager bm, List<IBehaviour> behaviours,
176 string firstName, string lastName, string password, string loginUri)
159 { 177 {
160 PhysicsBot pb = new PhysicsBot(bm, firstName, lastName, password, loginUri); 178 Bot pb = new Bot(bm, behaviours, firstName, lastName, password, loginUri);
161 179
162 pb.OnConnected += handlebotEvent; 180 pb.OnConnected += handlebotEvent;
163 pb.OnDisconnected += handlebotEvent; 181 pb.OnDisconnected += handlebotEvent;
@@ -176,7 +194,7 @@ namespace pCampBot
176 /// </summary> 194 /// </summary>
177 /// <param name="callbot"></param> 195 /// <param name="callbot"></param>
178 /// <param name="eventt"></param> 196 /// <param name="eventt"></param>
179 private void handlebotEvent(PhysicsBot callbot, EventType eventt) 197 private void handlebotEvent(Bot callbot, EventType eventt)
180 { 198 {
181 switch (eventt) 199 switch (eventt)
182 { 200 {
@@ -201,7 +219,7 @@ namespace pCampBot
201 public void doBotShutdown() 219 public void doBotShutdown()
202 { 220 {
203 lock (m_lBot) 221 lock (m_lBot)
204 foreach (PhysicsBot pb in m_lBot) 222 foreach (Bot pb in m_lBot)
205 pb.shutdown(); 223 pb.shutdown();
206 } 224 }
207 225
@@ -227,7 +245,7 @@ namespace pCampBot
227 245
228 lock (m_lBot) 246 lock (m_lBot)
229 { 247 {
230 foreach (PhysicsBot pb in m_lBot) 248 foreach (Bot pb in m_lBot)
231 { 249 {
232 MainConsole.Instance.OutputFormat( 250 MainConsole.Instance.OutputFormat(
233 outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected")); 251 outputFormat, pb.Name, (pb.IsConnected ? "Connected" : "Disconnected"));