Esempio n. 1
0
        /// <summary>
        /// Creates a new bot inworld
        /// </summary>
        /// <param name="FirstName"></param>
        /// <param name="LastName"></param>
        /// <param name="cloneAppearanceFrom">UUID of the avatar whos appearance will be copied to give this bot an appearance</param>
        /// <returns>ID of the bot</returns>
        public UUID CreateAvatar(string FirstName, string LastName, IScene s, UUID cloneAppearanceFrom)
        {
            Scene            scene          = (Scene)s;
            AgentCircuitData m_aCircuitData = new AgentCircuitData();

            m_aCircuitData.child = false;

            //Add the circuit data so they can login
            m_aCircuitData.circuitcode = (uint)Util.RandomClass.Next();

            m_aCircuitData.Appearance = GetAppearance(cloneAppearanceFrom); //Sets up appearance
            if (m_aCircuitData.Appearance == null)
            {
                m_aCircuitData.Appearance           = new AvatarAppearance();
                m_aCircuitData.Appearance.Wearables = AvatarWearable.DefaultWearables;
            }
            //Create the new bot data
            RexBot m_character = new RexBot(scene, m_aCircuitData);

            m_character.FirstName           = FirstName;
            m_character.LastName            = LastName;
            m_aCircuitData.AgentID          = m_character.AgentId;
            m_aCircuitData.Appearance.Owner = m_character.AgentId;
            m_character.SetSourceAvatarUUID(cloneAppearanceFrom.ToString());

            scene.AuthenticateHandler.AgentCircuits.Add(m_character.CircuitCode, m_aCircuitData);
            //This adds them to the scene and sets them inworld
            scene.AddNewClient(m_character);
            m_character.Initialize();
            m_character.SendRegionHandshake(scene.RegionInfo, null);
            IScenePresence SP = scene.GetScenePresence(m_character.AgentId);

            SP.MakeRootAgent(false);
            SP.Invulnerable = false;


            IAvatarAppearanceModule appearance = SP.RequestModuleInterface <IAvatarAppearanceModule> ();

            appearance.Appearance.SetAppearance(appearance.Appearance.Texture, appearance.Appearance.VisualParams);
            appearance.SendAvatarDataToAllAgents();
            appearance.SendAppearanceToAllOtherAgents();
            appearance.SendOtherAgentsAppearanceToMe();
            IAvatarFactory avFactory = scene.RequestModuleInterface <IAvatarFactory> ();

            if (avFactory != null)
            {
                avFactory.QueueInitialAppearanceSend(SP.UUID);
            }

            //Save them in the bots list
            m_bots.Add(m_character.AgentId, m_character);

            m_log.Info("[RexBotManager]: Added bot " + m_character.Name + " to scene.");

            //Return their UUID
            return(m_character.AgentId);
        }
Esempio n. 2
0
 public void ImportName(RexBot bot, XmlNode node)
 {
     foreach (XmlNode childNode in node.ChildNodes)
     {
         if (childNode.Name == "first_name")
         {
             bot.FirstName = childNode.InnerText;
         }
         if (childNode.Name == "last_name")
         {
             bot.LastName = childNode.InnerText;
         }
     }
 }
Esempio n. 3
0
        // imports rex bot config from xml node. uses strict parsing, throws exception from unknown elements.
        public void ImportRexBot(RexBot bot, XmlNode node)
        {
            foreach (XmlNode childNode in node.ChildNodes)
            {
                switch (childNode.Name)
                {
                    case "first_name":
                        bot.FirstName = childNode.InnerText;
                        break;

                    case "last_name":
                        bot.LastName = childNode.InnerText;
                        break;

                    case "storage_address":
                        bot.SetBotAppearance(childNode.InnerText);
                        break;

                    case "disable_walk":
                        bot.DisableWalk(Convert.ToBoolean(childNode.InnerText));
                        break;

                    case "movement_mod":
                        bot.SetMovementSpeedMod((float)Convert.ToDouble(childNode.InnerText));
                        break;

                    case "path":
                        parsePath(bot, childNode);

                        break;

                    case "admin_mode":
                        bot.AdminMode = (Convert.ToBoolean(childNode.InnerText));
                        break;

            //                    default:
            //                        throw new System.Xml.XmlException("Unknown xml element: " + childNode.Name + ".");
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new bot inworld
        /// </summary>
        /// <param name="FirstName"></param>
        /// <param name="LastName"></param>
        /// <param name="cloneAppearanceFrom">UUID of the avatar whos appearance will be copied to give this bot an appearance</param>
        /// <returns>ID of the bot</returns>
        public UUID CreateAvatar(string FirstName, string LastName, UUID cloneAppearanceFrom)
        {
            //Create the new bot data
            RexBot m_character = new RexBot(m_scene);

            m_character.FirstName = FirstName;
            m_character.LastName = LastName;

            AgentCircuitData m_aCircuitData = new AgentCircuitData();
            m_aCircuitData.child = false;

            m_aCircuitData.firstname = m_character.FirstName;
            m_aCircuitData.lastname = m_character.LastName;

            //Add the circuit data so they can login
            m_aCircuitData.circuitcode = m_character.CircuitCode;

            m_aCircuitData.Appearance = GetAppearance(cloneAppearanceFrom);//Sets up appearance

            m_scene.AuthenticateHandler.AgentCircuits.Add(m_character.CircuitCode, m_aCircuitData);
            //This adds them to the scene and sets them inworld
            m_scene.AddNewClient(m_character);

            m_character.Initialize();

            ScenePresence SP = m_scene.GetScenePresence(m_character.AgentId);
            SP.Appearance.SetAppearance(SP.Appearance.Texture, SP.Appearance.VisualParams);
            SP.SendAppearanceToAllOtherAgents();
            SP.SendAvatarDataToAllAgents();

            //Save them in the bots list
            m_bots.Add(m_character.AgentId, m_character);

            m_log.Info("[RexBotManager]: Added bot " + m_character.Name + " to scene.");

            //Return their UUID
            return m_character.AgentId;
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new bot inworld
        /// </summary>
        /// <param name="FirstName"></param>
        /// <param name="LastName"></param>
        /// <param name="cloneAppearanceFrom">UUID of the avatar whos appearance will be copied to give this bot an appearance</param>
        /// <returns>ID of the bot</returns>
        public UUID CreateAvatar(string FirstName, string LastName, IScene s, UUID cloneAppearanceFrom)
        {
            Scene scene = (Scene)s;
            AgentCircuitData m_aCircuitData = new AgentCircuitData ();
            m_aCircuitData.child = false;

            //Add the circuit data so they can login
            m_aCircuitData.circuitcode = (uint)Util.RandomClass.Next();

            m_aCircuitData.Appearance = GetAppearance (cloneAppearanceFrom);//Sets up appearance
            if (m_aCircuitData.Appearance == null)
            {
                m_aCircuitData.Appearance = new AvatarAppearance ();
                m_aCircuitData.Appearance.Wearables = AvatarWearable.DefaultWearables;
            }
            //Create the new bot data
            RexBot m_character = new RexBot (scene, m_aCircuitData);

            m_character.FirstName = FirstName;
            m_character.LastName = LastName;
            m_aCircuitData.AgentID = m_character.AgentId;
            m_aCircuitData.Appearance.Owner = m_character.AgentId;
            m_character.SetSourceAvatarUUID(cloneAppearanceFrom.ToString());

            scene.AuthenticateHandler.AgentCircuits.Add (m_character.CircuitCode, m_aCircuitData);
            //This adds them to the scene and sets them inworld
            scene.AddNewClient (m_character);
            m_character.Initialize ();
            m_character.SendRegionHandshake (scene.RegionInfo, null);
            IScenePresence SP = scene.GetScenePresence (m_character.AgentId);
            SP.MakeRootAgent (false);
            SP.Invulnerable = false;


            IAvatarAppearanceModule appearance = SP.RequestModuleInterface<IAvatarAppearanceModule> ();
            appearance.Appearance.SetAppearance (appearance.Appearance.Texture, appearance.Appearance.VisualParams);
            appearance.SendAvatarDataToAllAgents ();
            appearance.SendAppearanceToAllOtherAgents ();
            appearance.SendOtherAgentsAppearanceToMe ();
            IAvatarFactory avFactory = scene.RequestModuleInterface<IAvatarFactory> ();
            if (avFactory != null)
                avFactory.QueueInitialAppearanceSend (SP.UUID);

            //Save them in the bots list
            m_bots.Add(m_character.AgentId, m_character);

            m_log.Info("[RexBotManager]: Added bot " + m_character.Name + " to scene.");

            //Return their UUID
            return m_character.AgentId;
        }
Esempio n. 6
0
        private void parsePath(RexBot bot, XmlNode node)
        {
            string name = node.Attributes.GetNamedItem("name").Value;

            TravelMode mode = NavMeshInstance.DEFAULT_TRAVELMODE;
            int startNode = NavMeshInstance.DEFAULT_STARTNODE;
            bool random = NavMeshInstance.DEFAULT_RANDOM;
            bool reverse = NavMeshInstance.DEFAULT_REVERSE;
            bool allowU = NavMeshInstance.DEFAULT_ALLOWU;
            int timeOut = NavMeshInstance.DEFAULT_TIMEOUT;
            try
            {
                mode = NavMesh.ParseTravelMode(node.Attributes.GetNamedItem("mode").Value);
            }
            catch (Exception) { }
            try
            {
                startNode = Convert.ToInt32(node.Attributes.GetNamedItem("start_node").Value);
            }
            catch (Exception) {}
            try
            {
                random = Convert.ToBoolean(node.Attributes.GetNamedItem("random").Value);
            }
            catch (Exception) { }
            try
            {
                reverse = Convert.ToBoolean(node.Attributes.GetNamedItem("reverse").Value);
            }
            catch (Exception) {}
            try
            {
                allowU = Convert.ToBoolean(node.Attributes.GetNamedItem("allow_u").Value);
            }
            catch (Exception) { }
            try
            {
                timeOut = Convert.ToInt32(node.Attributes.GetNamedItem("timeout").Value);
            }
            catch (Exception) { }

            bot.SetPath(name, mode, startNode, random, reverse, allowU, timeOut);
        }
Esempio n. 7
0
        // read config data for single bot and add the avatar to the scene
        private void createAvatar(XmlNode node)
        {
            RexBotSerializer serializer = new RexBotSerializer();

            //first get region name so we know if we add this bot to this scene
            //if value is null we'll add it to all scenes
            string regionName = serializer.GetRegionName(node);
            if (regionName != null)
            {
                if (regionName != m_scene.RegionInfo.RegionName)
                    return;
            }

            RexBot m_character = new RexBot(m_scene, m_navMeshManager);

            serializer.ImportName(m_character, node); // import avatar name from file, we need it early

            m_aCircuitData.firstname = m_character.FirstName;
            m_aCircuitData.lastname = m_character.LastName;
            m_aCircuitData.circuitcode = m_character.CircuitCode;
            m_scene.AuthenticateHandler.AgentCircuits.Add(m_character.CircuitCode, m_aCircuitData);

            m_scene.AddNewClient(m_character);
            m_character.Initialize();
            m_bots.Add(m_character);

            serializer.ImportRexBot(m_character, node); // import after bot has been properly added to scene, because import might call some code that needs it

            m_log.Info("[RexBotManager]: Added bot " + m_character.Name + " to scene.");
        }