diff --git a/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs index 66d5542844..9bc85124ac 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs @@ -50,5 +50,7 @@ namespace pCampBot { Bot = bot; } + + public virtual void Close() {} } } diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs index 47b4d46108..65a7c90d49 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs @@ -78,6 +78,11 @@ namespace pCampBot Bot.Client.Self.Chat(randomf, 0, ChatType.Normal); } + public override void Close() + { + Bot.Client.Self.Jump(false); + } + private string[] readexcuses() { string allexcuses = ""; diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index 0bd8151ecc..f871b7764e 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -209,7 +209,17 @@ namespace pCampBot public bool RemoveBehaviour(string abbreviatedName) { lock (Behaviours) - return Behaviours.Remove(abbreviatedName); + { + IBehaviour behaviour; + + if (!Behaviours.TryGetValue(abbreviatedName, out behaviour)) + return false; + + behaviour.Close(); + Behaviours.Remove(abbreviatedName); + + return true; + } } private void CreateLibOmvClient() @@ -282,6 +292,10 @@ namespace pCampBot // XXX: This is a really shitty way of yielding so that behaviours can be added/removed Thread.Sleep(100); } + + lock (Behaviours) + foreach (IBehaviour b in Behaviours.Values) + b.Close(); } /// diff --git a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs index f8a661badd..0ed48256c1 100644 --- a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs @@ -50,6 +50,14 @@ namespace pCampBot.Interfaces /// void Initialize(Bot bot); + /// + /// Close down this behaviour. + /// + /// + /// This is triggered if a behaviour is removed via explicit command and when a bot is disconnected + /// + void Close(); + /// /// Action to take when this behaviour is invoked. ///