diff --git a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs
new file mode 100644
index 0000000000..00313b8eb7
--- /dev/null
+++ b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using OpenMetaverse;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using pCampBot.Interfaces;
+
+namespace pCampBot
+{
+ ///
+ /// Click (grab) on random objects in the scene.
+ ///
+ ///
+ /// The viewer itself does not give the option of grabbing objects that haven't been signalled as grabbable.
+ ///
+ public class GrabbingBehaviour : IBehaviour
+ {
+ public void Action(PhysicsBot bot)
+ {
+ Dictionary objects = bot.Objects;
+
+ Primitive prim = objects.ElementAt(bot.Random.Next(0, objects.Count)).Value;
+
+ // This appears to be a typical message sent when a viewer user clicks a clickable object
+ bot.Client.Self.Grab(prim.LocalID);
+ bot.Client.Self.GrabUpdate(prim.ID, Vector3.Zero);
+ bot.Client.Self.DeGrab(prim.LocalID);
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs
index e76c0b324b..bd4a7a28a6 100644
--- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs
+++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs
@@ -35,7 +35,7 @@ using pCampBot.Interfaces;
namespace pCampBot
{
///
- /// This is a behaviour designed to stress physics by moving and bouncing around bots a whole lot.
+ /// Stress physics by moving and bouncing around bots a whole lot.
///
///
/// TODO: talkarray should be in a separate behaviour.
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs
index 0505c971b6..dac6e0e366 100644
--- a/OpenSim/Tools/pCampBot/BotManager.cs
+++ b/OpenSim/Tools/pCampBot/BotManager.cs
@@ -120,13 +120,23 @@ namespace pCampBot
string password = cs.GetString("password");
string loginUri = cs.GetString("loginuri");
- // Hardcoded for new
- List behaviours = new List();
- behaviours.Add(new PhysicsBehaviour());
+ HashSet behaviourSwitches = new HashSet();
+ Array.ForEach(
+ cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b));
for (int i = 0; i < botcount; i++)
{
string lastName = string.Format("{0}_{1}", lastNameStem, i);
+
+ List behaviours = new List();
+
+ // Hard-coded for now
+ if (behaviourSwitches.Contains("p"))
+ behaviours.Add(new PhysicsBehaviour());
+
+ if (behaviourSwitches.Contains("g"))
+ behaviours.Add(new GrabbingBehaviour());
+
startupBot(i, this, behaviours, firstName, lastName, password, loginUri);
}
}
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs
index 05a510acbb..6e40ca7a27 100644
--- a/OpenSim/Tools/pCampBot/PhysicsBot.cs
+++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs
@@ -55,8 +55,27 @@ namespace pCampBot
///
/// Behaviours implemented by this bot.
///
+ ///
+ /// Lock this list before manipulating it.
+ ///
public List Behaviours { get; private set; }
+ ///
+ /// Objects that the bot has discovered.
+ ///
+ ///
+ /// Returns a list copy. Inserting new objects manually will have no effect.
+ ///
+ public Dictionary Objects
+ {
+ get
+ {
+ lock (m_objects)
+ return new Dictionary(m_objects);
+ }
+ }
+ private Dictionary m_objects = new Dictionary();
+
///
/// Is this bot connected to the grid?
///
@@ -125,7 +144,14 @@ namespace pCampBot
private void Action()
{
while (true)
- Behaviours.ForEach(b => b.Action(this));
+ lock (Behaviours)
+ Behaviours.ForEach(
+ b =>
+ {
+ // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType());
+ b.Action(this);
+ }
+ );
}
///
@@ -407,6 +433,9 @@ namespace pCampBot
if (prim != null)
{
+ lock (m_objects)
+ m_objects[prim.ID] = prim;
+
if (prim.Textures != null)
{
if (prim.Textures.DefaultTexture.TextureID != UUID.Zero)
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs
index cae96e1b9e..4d3b06d5bf 100644
--- a/OpenSim/Tools/pCampBot/pCampBot.cs
+++ b/OpenSim/Tools/pCampBot/pCampBot.cs
@@ -84,12 +84,13 @@ namespace pCampBot
//Set up our nifty config.. thanks to nini
ArgvConfigSource cs = new ArgvConfigSource(args);
- cs.AddSwitch("Startup", "botcount","n");
- cs.AddSwitch("Startup", "loginuri","l");
+ cs.AddSwitch("Startup", "botcount", "n");
+ cs.AddSwitch("Startup", "loginuri", "l");
cs.AddSwitch("Startup", "firstname");
cs.AddSwitch("Startup", "lastname");
cs.AddSwitch("Startup", "password");
- cs.AddSwitch("Startup", "help","h");
+ cs.AddSwitch("Startup", "behaviours", "b");
+ cs.AddSwitch("Startup", "help", "h");
cs.AddSwitch("Startup", "wear");
IConfig ol = cs.Configs["Startup"];
@@ -110,6 +111,7 @@ namespace pCampBot
" -firstname first name for the bots\n" +
" -lastname lastname for the bots. Each lastname will have _ appended, e.g. Ima Bot_0\n" +
" -password password for the bots\n" +
+ " -b, behaviours behaviours for bots. Current options p (physics), g (grab). Comma separated, e.g. p,g. Default is p",
" -wear set appearance folder to load from (default: no)\n" +
" -h, -help show this message"
);
diff --git a/prebuild.xml b/prebuild.xml
index bf11b0ffda..4e4bc61b24 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -2487,6 +2487,7 @@
../../../bin/
+