diff options
author | Justin Clark-Casey (justincc) | 2011-11-03 22:31:31 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-11-03 22:31:31 +0000 |
commit | 5a67940acc17c80c419781fddc9efa0c18ce1f15 (patch) | |
tree | 18b58a3cb1434a1ec05c5170bdb59e4d55e19cb3 | |
parent | Move PhysicsBehaviour into a spearate behaviours folder (diff) | |
download | opensim-SC_OLD-5a67940acc17c80c419781fddc9efa0c18ce1f15.zip opensim-SC_OLD-5a67940acc17c80c419781fddc9efa0c18ce1f15.tar.gz opensim-SC_OLD-5a67940acc17c80c419781fddc9efa0c18ce1f15.tar.bz2 opensim-SC_OLD-5a67940acc17c80c419781fddc9efa0c18ce1f15.tar.xz |
Add click/grab behaviour to pCampbot, which gets bots to randomly click things.
This can be specified on pCampbot.exe by using g in the list of behaviours for the new -behaviours,-b switch
e.g. -b p,g to get both existing physics and grabbing behaviours.
grabbing is primitive, it attempts grabs on random prims whether they're actually signalled as clickable or not.
behaviour is currently primitive overall, behaviours are just executed in a list
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs | 56 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | 2 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/BotManager.cs | 16 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/PhysicsBot.cs | 31 | ||||
-rw-r--r-- | OpenSim/Tools/pCampBot/pCampBot.cs | 8 | ||||
-rw-r--r-- | prebuild.xml | 1 |
6 files changed, 106 insertions, 8 deletions
diff --git a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs new file mode 100644 index 0000000..00313b8 --- /dev/null +++ b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenMetaverse; | ||
29 | using System; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Linq; | ||
32 | using pCampBot.Interfaces; | ||
33 | |||
34 | namespace pCampBot | ||
35 | { | ||
36 | /// <summary> | ||
37 | /// Click (grab) on random objects in the scene. | ||
38 | /// </summary> | ||
39 | /// <remarks> | ||
40 | /// The viewer itself does not give the option of grabbing objects that haven't been signalled as grabbable. | ||
41 | /// </remarks> | ||
42 | public class GrabbingBehaviour : IBehaviour | ||
43 | { | ||
44 | public void Action(PhysicsBot bot) | ||
45 | { | ||
46 | Dictionary<UUID, Primitive> objects = bot.Objects; | ||
47 | |||
48 | Primitive prim = objects.ElementAt(bot.Random.Next(0, objects.Count)).Value; | ||
49 | |||
50 | // This appears to be a typical message sent when a viewer user clicks a clickable object | ||
51 | bot.Client.Self.Grab(prim.LocalID); | ||
52 | bot.Client.Self.GrabUpdate(prim.ID, Vector3.Zero); | ||
53 | bot.Client.Self.DeGrab(prim.LocalID); | ||
54 | } | ||
55 | } | ||
56 | } \ No newline at end of file | ||
diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs index e76c0b3..bd4a7a2 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | |||
@@ -35,7 +35,7 @@ using pCampBot.Interfaces; | |||
35 | namespace pCampBot | 35 | namespace pCampBot |
36 | { | 36 | { |
37 | /// <summary> | 37 | /// <summary> |
38 | /// This is a behaviour designed to stress physics by moving and bouncing around bots a whole lot. | 38 | /// Stress physics by moving and bouncing around bots a whole lot. |
39 | /// </summary> | 39 | /// </summary> |
40 | /// <remarks> | 40 | /// <remarks> |
41 | /// TODO: talkarray should be in a separate behaviour. | 41 | /// TODO: talkarray should be in a separate behaviour. |
diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 0505c97..dac6e0e 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs | |||
@@ -120,13 +120,23 @@ namespace pCampBot | |||
120 | string password = cs.GetString("password"); | 120 | string password = cs.GetString("password"); |
121 | string loginUri = cs.GetString("loginuri"); | 121 | string loginUri = cs.GetString("loginuri"); |
122 | 122 | ||
123 | // Hardcoded for new | 123 | HashSet<string> behaviourSwitches = new HashSet<string>(); |
124 | List<IBehaviour> behaviours = new List<IBehaviour>(); | 124 | Array.ForEach<string>( |
125 | behaviours.Add(new PhysicsBehaviour()); | 125 | cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b)); |
126 | 126 | ||
127 | for (int i = 0; i < botcount; i++) | 127 | for (int i = 0; i < botcount; i++) |
128 | { | 128 | { |
129 | string lastName = string.Format("{0}_{1}", lastNameStem, i); | 129 | string lastName = string.Format("{0}_{1}", lastNameStem, i); |
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 | |||
130 | startupBot(i, this, behaviours, firstName, lastName, password, loginUri); | 140 | startupBot(i, this, behaviours, firstName, lastName, password, loginUri); |
131 | } | 141 | } |
132 | } | 142 | } |
diff --git a/OpenSim/Tools/pCampBot/PhysicsBot.cs b/OpenSim/Tools/pCampBot/PhysicsBot.cs index 05a510a..6e40ca7 100644 --- a/OpenSim/Tools/pCampBot/PhysicsBot.cs +++ b/OpenSim/Tools/pCampBot/PhysicsBot.cs | |||
@@ -55,9 +55,28 @@ namespace pCampBot | |||
55 | /// <summary> | 55 | /// <summary> |
56 | /// Behaviours implemented by this bot. | 56 | /// Behaviours implemented by this bot. |
57 | /// </summary> | 57 | /// </summary> |
58 | /// <remarks> | ||
59 | /// Lock this list before manipulating it. | ||
60 | /// </remarks> | ||
58 | public List<IBehaviour> Behaviours { get; private set; } | 61 | public List<IBehaviour> Behaviours { get; private set; } |
59 | 62 | ||
60 | /// <summary> | 63 | /// <summary> |
64 | /// Objects that the bot has discovered. | ||
65 | /// </summary> | ||
66 | /// <remarks> | ||
67 | /// Returns a list copy. Inserting new objects manually will have no effect. | ||
68 | /// </remarks> | ||
69 | public Dictionary<UUID, Primitive> Objects | ||
70 | { | ||
71 | get | ||
72 | { | ||
73 | lock (m_objects) | ||
74 | return new Dictionary<UUID, Primitive>(m_objects); | ||
75 | } | ||
76 | } | ||
77 | private Dictionary<UUID, Primitive> m_objects = new Dictionary<UUID, Primitive>(); | ||
78 | |||
79 | /// <summary> | ||
61 | /// Is this bot connected to the grid? | 80 | /// Is this bot connected to the grid? |
62 | /// </summary> | 81 | /// </summary> |
63 | public bool IsConnected { get; private set; } | 82 | public bool IsConnected { get; private set; } |
@@ -125,7 +144,14 @@ namespace pCampBot | |||
125 | private void Action() | 144 | private void Action() |
126 | { | 145 | { |
127 | while (true) | 146 | while (true) |
128 | Behaviours.ForEach(b => b.Action(this)); | 147 | lock (Behaviours) |
148 | Behaviours.ForEach( | ||
149 | b => | ||
150 | { | ||
151 | // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); | ||
152 | b.Action(this); | ||
153 | } | ||
154 | ); | ||
129 | } | 155 | } |
130 | 156 | ||
131 | /// <summary> | 157 | /// <summary> |
@@ -407,6 +433,9 @@ namespace pCampBot | |||
407 | 433 | ||
408 | if (prim != null) | 434 | if (prim != null) |
409 | { | 435 | { |
436 | lock (m_objects) | ||
437 | m_objects[prim.ID] = prim; | ||
438 | |||
410 | if (prim.Textures != null) | 439 | if (prim.Textures != null) |
411 | { | 440 | { |
412 | if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) | 441 | if (prim.Textures.DefaultTexture.TextureID != UUID.Zero) |
diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index cae96e1..4d3b06d 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs | |||
@@ -84,12 +84,13 @@ namespace pCampBot | |||
84 | //Set up our nifty config.. thanks to nini | 84 | //Set up our nifty config.. thanks to nini |
85 | ArgvConfigSource cs = new ArgvConfigSource(args); | 85 | ArgvConfigSource cs = new ArgvConfigSource(args); |
86 | 86 | ||
87 | cs.AddSwitch("Startup", "botcount","n"); | 87 | cs.AddSwitch("Startup", "botcount", "n"); |
88 | cs.AddSwitch("Startup", "loginuri","l"); | 88 | cs.AddSwitch("Startup", "loginuri", "l"); |
89 | cs.AddSwitch("Startup", "firstname"); | 89 | cs.AddSwitch("Startup", "firstname"); |
90 | cs.AddSwitch("Startup", "lastname"); | 90 | cs.AddSwitch("Startup", "lastname"); |
91 | cs.AddSwitch("Startup", "password"); | 91 | cs.AddSwitch("Startup", "password"); |
92 | cs.AddSwitch("Startup", "help","h"); | 92 | cs.AddSwitch("Startup", "behaviours", "b"); |
93 | cs.AddSwitch("Startup", "help", "h"); | ||
93 | cs.AddSwitch("Startup", "wear"); | 94 | cs.AddSwitch("Startup", "wear"); |
94 | 95 | ||
95 | IConfig ol = cs.Configs["Startup"]; | 96 | IConfig ol = cs.Configs["Startup"]; |
@@ -110,6 +111,7 @@ namespace pCampBot | |||
110 | " -firstname first name for the bots\n" + | 111 | " -firstname first name for the bots\n" + |
111 | " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" + | 112 | " -lastname lastname for the bots. Each lastname will have _<bot-number> appended, e.g. Ima Bot_0\n" + |
112 | " -password password for the bots\n" + | 113 | " -password password for the bots\n" + |
114 | " -b, behaviours behaviours for bots. Current options p (physics), g (grab). Comma separated, e.g. p,g. Default is p", | ||
113 | " -wear set appearance folder to load from (default: no)\n" + | 115 | " -wear set appearance folder to load from (default: no)\n" + |
114 | " -h, -help show this message" | 116 | " -h, -help show this message" |
115 | ); | 117 | ); |
diff --git a/prebuild.xml b/prebuild.xml index bf11b0f..4e4bc61 100644 --- a/prebuild.xml +++ b/prebuild.xml | |||
@@ -2487,6 +2487,7 @@ | |||
2487 | 2487 | ||
2488 | <ReferencePath>../../../bin/</ReferencePath> | 2488 | <ReferencePath>../../../bin/</ReferencePath> |
2489 | <Reference name="System"/> | 2489 | <Reference name="System"/> |
2490 | <Reference name="System.Core"/> | ||
2490 | <Reference name="OpenMetaverseTypes" path="../../../bin/"/> | 2491 | <Reference name="OpenMetaverseTypes" path="../../../bin/"/> |
2491 | <Reference name="OpenMetaverse" path="../../../bin/"/> | 2492 | <Reference name="OpenMetaverse" path="../../../bin/"/> |
2492 | <Reference name="OpenSim.Framework"/> | 2493 | <Reference name="OpenSim.Framework"/> |