From bdcfd6afee5651bd5fc3b4e6a2dfeeb47b983661 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Nov 2011 17:35:33 +0000 Subject: Add disabled CrossBehaviour to pCampBot, which is designed to cross test bots between neighbouring regions. Not yet enabled since there is a bug where the initial cross will work but all subsequent movements on the receiving simulator appear to fail. --- .../Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | 1 - OpenSim/Tools/pCampBot/Bot.cs | 2 -- OpenSim/Tools/pCampBot/BotManager.cs | 3 +++ OpenSim/Tools/pCampBot/pCampBot.cs | 26 +++++++++++++--------- 4 files changed, 18 insertions(+), 14 deletions(-) (limited to 'OpenSim/Tools/pCampBot') diff --git a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs index f782bb5..25529d0 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs @@ -73,7 +73,6 @@ namespace pCampBot Thread.Sleep(bot.Random.Next(3000, 13000)); bot.Client.Self.Movement.AtPos = false; bot.Client.Self.Jump(true); - string randomf = talkarray[bot.Random.Next(talkarray.Length)]; if (talkarray.Length > 1 && randomf.Length > 1) bot.Client.Self.Chat(randomf, 0, ChatType.Normal); diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index 7a73e3f..409734e 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -226,8 +226,6 @@ namespace pCampBot MakeDefaultAppearance(wear); } - Client.Self.Jump(true); - // Extract nearby region information. Client.Grid.GridRegion += Manager.Grid_GridRegion; uint xUint, yUint; diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index 29cb1ba..d91990f 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -163,6 +163,9 @@ namespace pCampBot if (behaviourSwitches.Contains("t")) behaviours.Add(new TeleportBehaviour()); +// if (behaviourSwitches.Contains("c")) +// behaviours.Add(new CrossBehaviour()); + MainConsole.Instance.OutputFormat( "[BOT MANAGER]: Bots configured for behaviours {0}", string.Join(",", behaviours.ConvertAll(b => b.Name).ToArray())); diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index e7288d5..3f43cff 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -104,17 +104,21 @@ namespace pCampBot // name, to load an specific folder, or save, to save an avatar with some already existing wearables // worn to the folder MyAppearance/FirstName_LastName, and the load it. Console.WriteLine( - "usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" + - "Spawns a set of bots to test an OpenSim region\n\n" + - " -l, -loginuri loginuri for sim to log into (required)\n" + - " -n, -botcount number of bots to start (default: 1)\n" + - " -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), t (teleport). Comma separated, e.g. p,g. Default is p", - " -wear set appearance folder to load from (default: no)\n" + - " -h, -help show this message" - ); + "usage: pCampBot <-loginuri loginuri> [OPTIONS]\n" + + "Spawns a set of bots to test an OpenSim region\n\n" + + " -l, -loginuri loginuri for sim to log into (required)\n" + + " -n, -botcount number of bots to start (default: 1)\n" + + " -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. Comma separated, e.g. p,g. Default is p\n", + " current options are:" + + " p (physics)" + + " g (grab)" + + " t (teleport)" + +// " c (cross)" + + " -wear set appearance folder to load from (default: no)\n" + + " -h, -help show this message"); } } } -- cgit v1.1 From 2ae5b40ca6bb3d33310f0f66569bf150548a2de6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Nov 2011 22:36:45 +0000 Subject: On pCampBot, add bot as a property on behaviours instead of passing it in every time --- .../Tools/pCampBot/Behaviours/AbstractBehaviour.cs | 49 ++++++++++++++++++++++ .../Tools/pCampBot/Behaviours/GrabbingBehaviour.cs | 16 +++---- .../Tools/pCampBot/Behaviours/PhysicsBehaviour.cs | 31 +++++++------- .../Tools/pCampBot/Behaviours/TeleportBehaviour.cs | 22 +++++----- OpenSim/Tools/pCampBot/Bot.cs | 4 +- OpenSim/Tools/pCampBot/BotManager.cs | 38 ++++++++--------- OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs | 11 ++++- 7 files changed, 115 insertions(+), 56 deletions(-) create mode 100644 OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs (limited to 'OpenSim/Tools/pCampBot') diff --git a/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs new file mode 100644 index 0000000..9a9371d --- /dev/null +++ b/OpenSim/Tools/pCampBot/Behaviours/AbstractBehaviour.cs @@ -0,0 +1,49 @@ +/* + * 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 +{ + public class AbstractBehaviour : IBehaviour + { + public string Name { get; protected set; } + + public Bot Bot { get; protected set; } + + public virtual void Action() {} + + public virtual void Initialize(Bot bot) + { + Bot = bot; + } + } +} diff --git a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs index 0a6d5d2..6ad02b2 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs @@ -39,20 +39,20 @@ namespace pCampBot /// /// The viewer itself does not give the option of grabbing objects that haven't been signalled as grabbable. /// - public class GrabbingBehaviour : IBehaviour + public class GrabbingBehaviour : AbstractBehaviour { - public string Name { get { return "Grabbing"; } } + public GrabbingBehaviour() { Name = "Grabbing"; } - public void Action(Bot bot) + public override void Action() { - Dictionary objects = bot.Objects; + Dictionary objects = Bot.Objects; - Primitive prim = objects.ElementAt(bot.Random.Next(0, objects.Count)).Value; + 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); + 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 25529d0..daa7485 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/PhysicsBehaviour.cs @@ -40,42 +40,41 @@ namespace pCampBot /// /// TODO: talkarray should be in a separate behaviour. /// - public class PhysicsBehaviour : IBehaviour + public class PhysicsBehaviour : AbstractBehaviour { - public string Name { get { return "Physics"; } } - private string[] talkarray; public PhysicsBehaviour() { + Name = "Physics"; talkarray = readexcuses(); } - public void Action(Bot bot) + public override void Action() { - int walkorrun = bot.Random.Next(4); // Randomize between walking and running. The greater this number, + int walkorrun = Bot.Random.Next(4); // Randomize between walking and running. The greater this number, // the greater the bot's chances to walk instead of run. - bot.Client.Self.Jump(false); + Bot.Client.Self.Jump(false); if (walkorrun == 0) { - bot.Client.Self.Movement.AlwaysRun = true; + Bot.Client.Self.Movement.AlwaysRun = true; } else { - bot.Client.Self.Movement.AlwaysRun = false; + Bot.Client.Self.Movement.AlwaysRun = false; } // TODO: unused: Vector3 pos = client.Self.SimPosition; - Vector3 newpos = new Vector3(bot.Random.Next(1, 254), bot.Random.Next(1, 254), bot.Random.Next(1, 254)); - bot.Client.Self.Movement.TurnToward(newpos); + Vector3 newpos = new Vector3(Bot.Random.Next(1, 254), Bot.Random.Next(1, 254), Bot.Random.Next(1, 254)); + Bot.Client.Self.Movement.TurnToward(newpos); - bot.Client.Self.Movement.AtPos = true; - Thread.Sleep(bot.Random.Next(3000, 13000)); - bot.Client.Self.Movement.AtPos = false; - bot.Client.Self.Jump(true); - string randomf = talkarray[bot.Random.Next(talkarray.Length)]; + Bot.Client.Self.Movement.AtPos = true; + Thread.Sleep(Bot.Random.Next(3000, 13000)); + Bot.Client.Self.Movement.AtPos = false; + Bot.Client.Self.Jump(true); + string randomf = talkarray[Bot.Random.Next(talkarray.Length)]; if (talkarray.Length > 1 && randomf.Length > 1) - bot.Client.Self.Chat(randomf, 0, ChatType.Normal); + Bot.Client.Self.Chat(randomf, 0, ChatType.Normal); } private string[] readexcuses() diff --git a/OpenSim/Tools/pCampBot/Behaviours/TeleportBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/TeleportBehaviour.cs index fc2ed2c..fbb4e96 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/TeleportBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/TeleportBehaviour.cs @@ -38,38 +38,38 @@ namespace pCampBot /// /// Teleport to a random region on the grid. /// - public class TeleportBehaviour : IBehaviour + public class TeleportBehaviour : AbstractBehaviour { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - public string Name { get { return "Teleport"; } } + public TeleportBehaviour() { Name = "Teleport"; } - public void Action(Bot bot) + public override void Action() { - Random rng = bot.Manager.Rng; + Random rng = Bot.Manager.Rng; GridRegion[] knownRegions; - lock (bot.Manager.RegionsKnown) + lock (Bot.Manager.RegionsKnown) { - if (bot.Manager.RegionsKnown.Count == 0) + if (Bot.Manager.RegionsKnown.Count == 0) { m_log.DebugFormat( - "[TELEPORT BEHAVIOUR]: Ignoring teleport action for {0} since no regions are known yet", bot.Name); + "[TELEPORT BEHAVIOUR]: Ignoring teleport action for {0} since no regions are known yet", Bot.Name); return; } - knownRegions = bot.Manager.RegionsKnown.Values.ToArray(); + knownRegions = Bot.Manager.RegionsKnown.Values.ToArray(); } - Simulator sourceRegion = bot.Client.Network.CurrentSim; + Simulator sourceRegion = Bot.Client.Network.CurrentSim; GridRegion destRegion = knownRegions[rng.Next(knownRegions.Length)]; Vector3 destPosition = new Vector3(rng.Next(255), rng.Next(255), 50); m_log.DebugFormat( "[TELEPORT BEHAVIOUR]: Teleporting {0} from {1} {2} to {3} {4}", - bot.Name, sourceRegion.Name, bot.Client.Self.SimPosition, destRegion.Name, destPosition); + Bot.Name, sourceRegion.Name, Bot.Client.Self.SimPosition, destRegion.Name, destPosition); - bot.Client.Self.Teleport(destRegion.RegionHandle, destPosition); + Bot.Client.Self.Teleport(destRegion.RegionHandle, destPosition); } } } \ No newline at end of file diff --git a/OpenSim/Tools/pCampBot/Bot.cs b/OpenSim/Tools/pCampBot/Bot.cs index 409734e..0bd0bcc 100644 --- a/OpenSim/Tools/pCampBot/Bot.cs +++ b/OpenSim/Tools/pCampBot/Bot.cs @@ -130,6 +130,8 @@ namespace pCampBot BotManager bm, List behaviours, string firstName, string lastName, string password, string loginUri) { + behaviours.ForEach(b => b.Initialize(this)); + Client = new GridClient(); Random = new Random(Environment.TickCount);// We do stuff randomly here @@ -156,7 +158,7 @@ namespace pCampBot b => { // m_log.DebugFormat("[pCAMPBOT]: For {0} performing action {1}", Name, b.GetType()); - b.Action(this); + b.Action(); Thread.Sleep(Random.Next(1000, 10000)); } diff --git a/OpenSim/Tools/pCampBot/BotManager.cs b/OpenSim/Tools/pCampBot/BotManager.cs index d91990f..6481e97 100644 --- a/OpenSim/Tools/pCampBot/BotManager.cs +++ b/OpenSim/Tools/pCampBot/BotManager.cs @@ -151,29 +151,29 @@ namespace pCampBot Array.ForEach( cs.GetString("behaviours", "p").Split(new char[] { ',' }), b => behaviourSwitches.Add(b)); - List behaviours = new List(); - - // 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()); - -// if (behaviourSwitches.Contains("c")) -// behaviours.Add(new CrossBehaviour()); - - MainConsole.Instance.OutputFormat( - "[BOT MANAGER]: Bots configured for behaviours {0}", - string.Join(",", behaviours.ConvertAll(b => b.Name).ToArray())); - 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()); + + if (behaviourSwitches.Contains("t")) + behaviours.Add(new TeleportBehaviour()); + + if (behaviourSwitches.Contains("c")) + behaviours.Add(new CrossBehaviour()); + + MainConsole.Instance.OutputFormat( + "[BOT MANAGER]: Bot {0} {1} configured for behaviours {2}", + firstName, lastName, string.Join(",", behaviours.ConvertAll(b => b.Name).ToArray())); + StartBot(this, behaviours, firstName, lastName, password, loginUri); } } diff --git a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs index 912216f..9c984be 100644 --- a/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Interfaces/IBehaviour.cs @@ -37,9 +37,18 @@ namespace pCampBot.Interfaces string Name { get; } /// + /// Initialize the behaviour for this bot. + /// + /// + /// This must be invoked before Action() is called. + /// + /// + void Initialize(Bot bot); + + /// /// Action to take when this behaviour is invoked. /// /// - void Action(Bot bot); + void Action(); } } \ No newline at end of file -- cgit v1.1 From 0a0aa77cfd64eeebe0fadecd999e5a0d4ee3739e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Nov 2011 22:46:43 +0000 Subject: Adding missing CrossBehaviour.cs file to fix build --- .../Tools/pCampBot/Behaviours/CrossBehaviour.cs | 169 +++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 OpenSim/Tools/pCampBot/Behaviours/CrossBehaviour.cs (limited to 'OpenSim/Tools/pCampBot') diff --git a/OpenSim/Tools/pCampBot/Behaviours/CrossBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/CrossBehaviour.cs new file mode 100644 index 0000000..1e01c64 --- /dev/null +++ b/OpenSim/Tools/pCampBot/Behaviours/CrossBehaviour.cs @@ -0,0 +1,169 @@ +/* + * 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 System; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using log4net; +using OpenMetaverse; +using OpenSim.Framework; +using pCampBot.Interfaces; + +namespace pCampBot +{ + /// + /// Get the bot to make a region crossing. + /// + public class CrossBehaviour : AbstractBehaviour + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public AutoResetEvent m_regionCrossedMutex = new AutoResetEvent(false); + + public const int m_regionCrossingTimeout = 1000 * 60; + + public CrossBehaviour() { Name = "Cross"; } + + public override void Action() + { + GridClient client = Bot.Client; + +// // Fly to make the border cross easier. +// client.Self.Movement.Fly = true; +// client.Self.Movement.Fly = false; + + // Seek out neighbouring region + Simulator currentSim = client.Network.CurrentSim; + ulong currentHandle = currentSim.Handle; + uint currentX, currentY; + Utils.LongToUInts(currentHandle, out currentX, out currentY); + + List candidateRegions = new List(); + TryAddRegion(Utils.UIntsToLong(Math.Max(0, currentX - Constants.RegionSize), currentY), candidateRegions); // West + TryAddRegion(Utils.UIntsToLong(currentX + Constants.RegionSize, currentY), candidateRegions); // East + TryAddRegion(Utils.UIntsToLong(currentX, Math.Max(0, currentY - Constants.RegionSize)), candidateRegions); // South + TryAddRegion(Utils.UIntsToLong(currentX, currentY + Constants.RegionSize), candidateRegions); // North + + if (candidateRegions.Count != 0) + { + GridRegion destRegion = candidateRegions[Bot.Manager.Rng.Next(candidateRegions.Count)]; + + uint targetX, targetY; + Utils.LongToUInts(destRegion.RegionHandle, out targetX, out targetY); + + Vector3 pos = client.Self.SimPosition; + if (targetX < currentX) + pos.X = -1; + else if (targetX > currentX) + pos.X = Constants.RegionSize + 1; + + if (targetY < currentY) + pos.Y = -1; + else if (targetY > currentY) + pos.Y = Constants.RegionSize + 1; + + m_log.DebugFormat( + "[CROSS BEHAVIOUR]: {0} moving to cross from {1} into {2}, target {3}", + Bot.Name, currentSim.Name, destRegion.Name, pos); + + // Face in the direction of the candidate region + client.Self.Movement.TurnToward(pos); + + // Listen for event so that we know when we've crossed the region boundary + Bot.Client.Self.RegionCrossed += Self_RegionCrossed; + + // Start moving + Bot.Client.Self.Movement.AtPos = true; + + // Stop when reach region target or border cross detected + if (!m_regionCrossedMutex.WaitOne(m_regionCrossingTimeout)) + { + m_log.ErrorFormat( + "[CROSS BEHAVIOUR]: {0} failed to cross from {1} into {2} with {3}ms", + Bot.Name, currentSim.Name, destRegion.Name, m_regionCrossingTimeout); + } + else + { + m_log.DebugFormat( + "[CROSS BEHAVIOUR]: {0} crossed from {1} into {2}", + Bot.Name, currentSim.Name, destRegion.Name); + } + + Bot.Client.Self.RegionCrossed -= Self_RegionCrossed; + + // We will hackishly carry on travelling into the region for a little bit. + Thread.Sleep(6000); + + m_log.DebugFormat( + "[CROSS BEHAVIOUR]: {0} stopped moving after cross from {1} into {2}", + Bot.Name, currentSim.Name, destRegion.Name); + + Bot.Client.Self.Movement.AtPos = false; + } + else + { + m_log.DebugFormat( + "[CROSS BEHAVIOUR]: No candidate region for {0} to cross into from {1}. Ignoring.", + Bot.Name, currentSim.Name); + } + } + + private bool TryAddRegion(ulong handle, List regions) + { + Dictionary knownRegions = Bot.Manager.RegionsKnown; + + lock (knownRegions) + { + if (knownRegions.Count == 0) + return false; + + m_log.DebugFormat("[CROSS BEHAVIOUR]: Looking for region with handle {0} in known regions", handle); + + if (knownRegions.ContainsKey(handle)) + { + GridRegion region = knownRegions[handle]; + m_log.DebugFormat( + "[CROSS BEHAVIOUR]: Adding region {0} to crossing candidates for {1}", region.Name, Bot.Name); + + regions.Add(region); + + return true; + } + else + { + return false; + } + } + } + + internal void Self_RegionCrossed(object o, RegionCrossedEventArgs args) + { + m_regionCrossedMutex.Set(); + } + } +} \ No newline at end of file -- cgit v1.1