Print out what behaviours are active when pCampBot starts up

iar_mods
Justin Clark-Casey (justincc) 2011-11-23 22:18:10 +00:00
parent d145750e87
commit ed7ddeecf2
5 changed files with 42 additions and 12 deletions

View File

@ -41,6 +41,8 @@ namespace pCampBot
/// </remarks> /// </remarks>
public class GrabbingBehaviour : IBehaviour public class GrabbingBehaviour : IBehaviour
{ {
public string Name { get { return "Grabbing"; } }
public void Action(Bot bot) public void Action(Bot bot)
{ {
Dictionary<UUID, Primitive> objects = bot.Objects; Dictionary<UUID, Primitive> objects = bot.Objects;

View File

@ -42,6 +42,8 @@ namespace pCampBot
/// </remarks> /// </remarks>
public class PhysicsBehaviour : IBehaviour public class PhysicsBehaviour : IBehaviour
{ {
public string Name { get { return "Physics"; } }
private string[] talkarray; private string[] talkarray;
public PhysicsBehaviour() public PhysicsBehaviour()

View File

@ -42,6 +42,8 @@ namespace pCampBot
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public string Name { get { return "Teleport"; } }
public void Action(Bot bot) public void Action(Bot bot)
{ {
Random rng = bot.Manager.Rng; Random rng = bot.Manager.Rng;

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using OpenMetaverse; using OpenMetaverse;
@ -48,7 +49,14 @@ namespace pCampBot
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Command console
/// </summary>
protected CommandConsole m_console; protected CommandConsole m_console;
/// <summary>
/// Created bots, whether active or inactive.
/// </summary>
protected List<Bot> m_lBot; protected List<Bot> m_lBot;
/// <summary> /// <summary>
@ -56,6 +64,9 @@ namespace pCampBot
/// </summary> /// </summary>
public Random Rng { get; private set; } public Random Rng { get; private set; }
/// <summary>
/// Overall configuration.
/// </summary>
public IConfig Config { get; private set; } public IConfig Config { get; private set; }
/// <summary> /// <summary>
@ -140,22 +151,26 @@ namespace pCampBot
Array.ForEach<string>( Array.ForEach<string>(
cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b)); cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
List<IBehaviour> behaviours = new List<IBehaviour>();
// Hard-coded for now
if (behaviourSwitches.Contains("p"))
behaviours.Add(new PhysicsBehaviour());
if (behaviourSwitches.Contains("g"))
behaviours.Add(new GrabbingBehaviour());
if (behaviourSwitches.Contains("t"))
behaviours.Add(new TeleportBehaviour());
MainConsole.Instance.OutputFormat(
"[BOT MANAGER]: Bots configured for behaviours {0}",
string.Join(",", behaviours.ConvertAll<string>(b => b.Name).ToArray()));
for (int i = 0; i < botcount; i++) for (int i = 0; i < botcount; i++)
{ {
string lastName = string.Format("{0}_{1}", lastNameStem, i); string lastName = string.Format("{0}_{1}", lastNameStem, i);
List<IBehaviour> behaviours = new List<IBehaviour>();
// Hard-coded for now
if (behaviourSwitches.Contains("p"))
behaviours.Add(new PhysicsBehaviour());
if (behaviourSwitches.Contains("g"))
behaviours.Add(new GrabbingBehaviour());
if (behaviourSwitches.Contains("t"))
behaviours.Add(new TeleportBehaviour());
StartBot(this, behaviours, firstName, lastName, password, loginUri); StartBot(this, behaviours, firstName, lastName, password, loginUri);
} }
} }

View File

@ -31,6 +31,15 @@ namespace pCampBot.Interfaces
{ {
public interface IBehaviour public interface IBehaviour
{ {
/// <summary>
/// Name of this behaviour.
/// </summary>
string Name { get; }
/// <summary>
/// Action to take when this behaviour is invoked.
/// </summary>
/// <param name="bot"></param>
void Action(Bot bot); void Action(Bot bot);
} }
} }