当前位置: 首页>>代码示例>>C#>>正文


C# Scene.AddNewAgent方法代码示例

本文整理汇总了C#中OpenSim.Region.Framework.Scenes.Scene.AddNewAgent方法的典型用法代码示例。如果您正苦于以下问题:C# Scene.AddNewAgent方法的具体用法?C# Scene.AddNewAgent怎么用?C# Scene.AddNewAgent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenSim.Region.Framework.Scenes.Scene的用法示例。


在下文中一共展示了Scene.AddNewAgent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IntroduceClientToScene

        /// <summary>
        /// Introduce an agent into the scene by adding a new client.
        /// </summary>
        /// <returns>The scene presence added</returns>
        /// <param name='scene'></param>
        /// <param name='testClient'></param>
        /// <param name='agentData'></param>
        /// <param name='tf'></param>
        private static ScenePresence IntroduceClientToScene(
            Scene scene, IClientAPI client, AgentCircuitData agentData, TeleportFlags tf)
        {
            string reason;

            // Stage 1: tell the scene to expect a new user connection
            if (!scene.NewUserConnection(agentData, (uint)tf, null, out reason))
                Console.WriteLine("NewUserConnection failed: " + reason);

            // Stage 2: add the new client as a child agent to the scene
            scene.AddNewAgent(client, PresenceType.User);

            return scene.GetScenePresence(client.AgentId);
        }
开发者ID:CassieEllen,项目名称:opensim,代码行数:22,代码来源:SceneHelpers.cs

示例2: CreateNPC

        public UUID CreateNPC(string firstname, string lastname,
                Vector3 position, UUID owner, bool senseAsAgent, Scene scene,
                AvatarAppearance appearance)
        {
            NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position,
                    owner, senseAsAgent, scene);
            npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
                    int.MaxValue);

            m_log.DebugFormat(
                "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
                firstname, lastname, npcAvatar.AgentId, owner,
                senseAsAgent, position, scene.RegionInfo.RegionName);

            AgentCircuitData acd = new AgentCircuitData();
            acd.AgentID = npcAvatar.AgentId;
            acd.firstname = firstname;
            acd.lastname = lastname;
            acd.ServiceURLs = new Dictionary<string, object>();

            AvatarAppearance npcAppearance = new AvatarAppearance(appearance,
                    true);
            acd.Appearance = npcAppearance;

            /*
            for (int i = 0;
                    i < acd.Appearance.Texture.FaceTextures.Length; i++)
            {
                m_log.DebugFormat(
                        "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
                        acd.AgentID, i,
                        acd.Appearance.Texture.FaceTextures[i]);
            }
            */

            lock (m_avatars)
            {
                scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode,
                        acd);
                scene.AddNewAgent(npcAvatar, PresenceType.Npc);

                ScenePresence sp;
                if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
                {
                    /*
                    m_log.DebugFormat(
                            "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}",
                            sp.Name, sp.UUID);
                    */

                    sp.CompleteMovement(npcAvatar, false);
                    m_avatars.Add(npcAvatar.AgentId, npcAvatar);
                    m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);

                    return npcAvatar.AgentId;
                }
                else
                {
                    m_log.WarnFormat(
                        "[NPC MODULE]: Could not find scene presence for NPC {0} {1}",
                        sp.Name, sp.UUID);

                    return UUID.Zero;
                }
            }
        }
开发者ID:Michelle-Argus,项目名称:opensim,代码行数:66,代码来源:NPCModule.cs

示例3: CreateNPC

        public UUID CreateNPC(string firstname, string lastname,
                Vector3 position, UUID agentID, UUID owner, string groupTitle, UUID groupID, bool senseAsAgent, Scene scene,
                AvatarAppearance appearance)
        {
            NPCAvatar npcAvatar = null;

            try
            {
                if (agentID == UUID.Zero)
                    npcAvatar = new NPCAvatar(firstname, lastname, position,
                            owner, senseAsAgent, scene);
                else
                    npcAvatar = new NPCAvatar(firstname, lastname, agentID, position,
                        owner, senseAsAgent, scene);
            }
            catch (Exception e)
            {
                m_log.Info("[NPC MODULE]: exception creating NPC avatar: " + e.ToString());
                return UUID.Zero;
            }

            npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
                    int.MaxValue);

//            m_log.DebugFormat(
//                "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
//                firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName);

            AgentCircuitData acd = new AgentCircuitData();
            acd.AgentID = npcAvatar.AgentId;
            acd.firstname = firstname;
            acd.lastname = lastname;
            acd.ServiceURLs = new Dictionary<string, object>();

            AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
            acd.Appearance = npcAppearance;

            /*
            for (int i = 0;
                    i < acd.Appearance.Texture.FaceTextures.Length; i++)
            {
                m_log.DebugFormat(
                        "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
                        acd.AgentID, i,
                        acd.Appearance.Texture.FaceTextures[i]);
            }
            */

//            ManualResetEvent ev = new ManualResetEvent(false);

//            Util.FireAndForget(delegate(object x) {
                lock (m_avatars)
                {
                    scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
                    scene.AddNewAgent(npcAvatar, PresenceType.Npc);

                    ScenePresence sp;
                    if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
                    {
                        npcAvatar.ActiveGroupId = groupID;
                        sp.CompleteMovement(npcAvatar, false);
                        sp.Grouptitle = groupTitle;
                        m_avatars.Add(npcAvatar.AgentId, npcAvatar);
//                        m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
                    }
                }
//                ev.Set();
//            });

//            ev.WaitOne();

//            m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);

            return npcAvatar.AgentId;
        }
开发者ID:emperorstarfinder,项目名称:Opensim2,代码行数:75,代码来源:NPCModule.cs


注:本文中的OpenSim.Region.Framework.Scenes.Scene.AddNewAgent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。