aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-09-03 19:33:17 +0100
committerJustin Clark-Casey (justincc)2013-09-03 19:33:17 +0100
commit3dbe7313d1c3fc28f0642531fbb6e238a98ac821 (patch)
treefdb7503109ee947e5bb9fd7d6fbe31933a0aa2e1 /OpenSim
parentAdd pCampbot "remove behaviour" console command for removing bot behaviours d... (diff)
downloadopensim-SC_OLD-3dbe7313d1c3fc28f0642531fbb6e238a98ac821.zip
opensim-SC_OLD-3dbe7313d1c3fc28f0642531fbb6e238a98ac821.tar.gz
opensim-SC_OLD-3dbe7313d1c3fc28f0642531fbb6e238a98ac821.tar.bz2
opensim-SC_OLD-3dbe7313d1c3fc28f0642531fbb6e238a98ac821.tar.xz
Add Close() method to IBehaviour to allow behaviours to cleanup when removed or bot it disconnected.
In this case, it is used to turn off jump when physics testing behaviour is removed.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs2
-rw-r--r--OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs5
-rw-r--r--OpenSim/Tools/pCampBot/Bot.cs16
-rw-r--r--OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs8
4 files changed, 30 insertions, 1 deletions
diff --git a/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs
index 66d5542..9bc8512 100644
--- a/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs
+++ b/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs
@@ -50,5 +50,7 @@ namespace pCampBot
50 { 50 {
51 Bot = bot; 51 Bot = bot;
52 } 52 }
53
54 public virtual void Close() {}
53 } 55 }
54} 56}
diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs
index 47b4d46..65a7c90 100644
--- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs
+++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs
@@ -78,6 +78,11 @@ namespace pCampBot
78 Bot.Client.Self.Chat(randomf, 0, ChatType.Normal); 78 Bot.Client.Self.Chat(randomf, 0, ChatType.Normal);
79 } 79 }
80 80
81 public override void Close()
82 {
83 Bot.Client.Self.Jump(false);
84 }
85
81 private string[] readexcuses() 86 private string[] readexcuses()
82 { 87 {
83 string allexcuses = ""; 88 string allexcuses = "";
diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs
index 0bd8151..f871b77 100644
--- a/OpenSim/Tools/pCampBot/Bot.cs
+++ b/OpenSim/Tools/pCampBot/Bot.cs
@@ -209,7 +209,17 @@ namespace pCampBot
209 public bool RemoveBehaviour(string abbreviatedName) 209 public bool RemoveBehaviour(string abbreviatedName)
210 { 210 {
211 lock (Behaviours) 211 lock (Behaviours)
212 return Behaviours.Remove(abbreviatedName); 212 {
213 IBehaviour behaviour;
214
215 if (!Behaviours.TryGetValue(abbreviatedName, out behaviour))
216 return false;
217
218 behaviour.Close();
219 Behaviours.Remove(abbreviatedName);
220
221 return true;
222 }
213 } 223 }
214 224
215 private void CreateLibOmvClient() 225 private void CreateLibOmvClient()
@@ -282,6 +292,10 @@ namespace pCampBot
282 // XXX: This is a really shitty way of yielding so that behaviours can be added/removed 292 // XXX: This is a really shitty way of yielding so that behaviours can be added/removed
283 Thread.Sleep(100); 293 Thread.Sleep(100);
284 } 294 }
295
296 lock (Behaviours)
297 foreach (IBehaviour b in Behaviours.Values)
298 b.Close();
285 } 299 }
286 300
287 /// <summary> 301 /// <summary>
diff --git a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs
index f8a661b..0ed4825 100644
--- a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs
+++ b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs
@@ -51,6 +51,14 @@ namespace pCampBot.Interfaces
51 void Initialize(Bot bot); 51 void Initialize(Bot bot);
52 52
53 /// <summary> 53 /// <summary>
54 /// Close down this behaviour.
55 /// </summary>
56 /// <remarks>
57 /// This is triggered if a behaviour is removed via explicit command and when a bot is disconnected
58 /// </remarks>
59 void Close();
60
61 /// <summary>
54 /// Action to take when this behaviour is invoked. 62 /// Action to take when this behaviour is invoked.
55 /// </summary> 63 /// </summary>
56 /// <param name="bot"></param> 64 /// <param name="bot"></param>