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


C# Scene.TryGetScenePresence方法代码示例

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


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

示例1: 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.AddNewClient(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 with id {0}", npcAvatar.AgentId);

                    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:JAllard,项目名称:osmodified,代码行数:56,代码来源:NPCModule.cs

示例2: CreateNPC

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

            m_log.DebugFormat(
                "[NPC MODULE]: Creating NPC {0} {1} {2} at {3} in {4}",
                firstname, lastname, npcAvatar.AgentId, 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 originalAppearance = GetAppearance(cloneAppearanceFrom, scene);
            AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true);
            acd.Appearance = npcAppearance;

            scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
            scene.AddNewClient(npcAvatar);

            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);

                // Shouldn't call this - temporary.
                sp.CompleteMovement(npcAvatar);

//                        sp.SendAppearanceToAllOtherAgents();
//
//                        // Send animations back to the avatar as well
//                        sp.Animator.SendAnimPack();
            }
            else
            {
                m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID);
            }

            lock (m_avatars)
                m_avatars.Add(npcAvatar.AgentId, npcAvatar);

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

            return npcAvatar.AgentId;
        }
开发者ID:caocao,项目名称:diva-distribution,代码行数:48,代码来源:NPCModule.cs

示例3: Autopilot

 public void Autopilot(UUID agentID, Scene scene, Vector3 pos)
 {
     lock (m_avatars)
     {
         if (m_avatars.ContainsKey(agentID))
         {
             ScenePresence sp;
             scene.TryGetScenePresence(agentID, out sp);
             sp.DoAutoPilot(0, pos, m_avatars[agentID]);
         }
     }
 }
开发者ID:shangcheng,项目名称:Aurora,代码行数:12,代码来源:NPCModule.cs

示例4: Whisper

        public bool Whisper(UUID agentID, Scene scene, string text, int channel)
        {
            lock (m_avatars)
            {
                if (m_avatars.ContainsKey(agentID))
                {
                    ScenePresence sp;
                    scene.TryGetScenePresence(agentID, out sp);

                    m_avatars[agentID].Whisper(channel, text);

                    return true;
                }
            }

            return false;
        }
开发者ID:JAllard,项目名称:opensim,代码行数:17,代码来源:NPCModule.cs

示例5: AllowTeleport


//.........这里部分代码省略.........
                    {
                        newPosition = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                    }
                    else
                    {
                        int LastTelehubNum = 0;
                        if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
                            LastTelehubNum = 0;
                        newPosition = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                        LastTelehubNum++;
                        if (LastTelehubNum == telehub.SpawnPos.Count)
                            LastTelehubNum = 0;
                        LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
                    }
                }
                else
                {
                    reason = "Teleport has been blocked for this region.";
                    return false;
                }
            }
            else
            {
                //If they are owner, they don't have to have permissions checked
                if (!m_scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
                {
                    if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land
                    {
                        //Find a new parcel for them
                        List<ILandObject> Parcels = m_scene.LandChannel.ParcelsNearPoint(Position);
                        if (Parcels.Count == 0)
                        {
                            ScenePresence SP;
                            scene.TryGetScenePresence(userID, out SP);
                            newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(SP);
                        }
                        else
                        {
                            bool found = false;
                            //We need to check here as well for bans, can't toss someone into a parcel they are banned from
                            foreach (ILandObject Parcel in Parcels)
                            {
                                if (!Parcel.IsBannedFromLand(userID))
                                {
                                    //Now we have to check their userloc
                                    if (ILO.LandData.LandingType == 2)
                                        continue; //Blocked, check next one
                                    else if (ILO.LandData.LandingType == 1) //Use their landing spot
                                        newPosition = Parcel.LandData.UserLocation;
                                    else //They allow for anywhere, so dump them in the center at the ground
                                        newPosition = m_scene.LandChannel.GetParcelCenterAtGround(Parcel);
                                    found = true;
                                }
                            }
                            if (!found) //Dump them at the edge
                            {
                                if(Sp != null)
                                    newPosition = m_scene.LandChannel.GetNearestRegionEdgePosition(Sp);
                                else
                                {
                                    reason = "Banned from this parcel.";
                                    return true;
                                }
                            }
                        }
                    }
开发者ID:NickyPerian,项目名称:Aurora,代码行数:67,代码来源:EstateService.cs

示例6: Say

        public bool Say(UUID agentID, Scene scene, string text)
        {
            lock (m_avatars)
            {
                if (m_avatars.ContainsKey(agentID))
                {
                    ScenePresence sp;
                    scene.TryGetScenePresence(agentID, out sp);

                    m_avatars[agentID].Say(text);

                    return true;
                }
            }

            return false;
        }
开发者ID:JAllard,项目名称:osmodified,代码行数:17,代码来源:NPCModule.cs

示例7: Stand

        public bool Stand(UUID agentID, Scene scene)
        {
            lock (m_avatars)
            {
                if (m_avatars.ContainsKey(agentID))
                {
                    ScenePresence sp;
                    scene.TryGetScenePresence(agentID, out sp);
                    sp.StandUp();

                    return true;
                }
            }

            return false;
        }
开发者ID:JAllard,项目名称:osmodified,代码行数:16,代码来源:NPCModule.cs

示例8: MoveToTarget

        public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos,
                bool noFly, bool landAtTarget, bool running)
        {
            lock (m_avatars)
            {
                if (m_avatars.ContainsKey(agentID))
                {
                    ScenePresence sp;
                    if (scene.TryGetScenePresence(agentID, out sp))
                    {
                        if (sp.IsSatOnObject || sp.SitGround)
                            return false;

//                        m_log.DebugFormat(
//                                "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
//                                sp.Name, pos, scene.RegionInfo.RegionName,
//                                noFly, landAtTarget);

                        sp.MoveToTarget(pos, noFly, landAtTarget);
                        sp.SetAlwaysRun = running;

                        return true;
                    }
                }
            }

            return false;
        }
开发者ID:RadaSangOn,项目名称:workCore2,代码行数:28,代码来源:NPCModule.cs

示例9: OnAllowedIncomingTeleport


//.........这里部分代码省略.........
                    {
                        newPosition = new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                    }
                    else
                    {
                        int LastTelehubNum = 0;
                        if (!LastTelehub.TryGetValue(scene.RegionInfo.RegionID, out LastTelehubNum))
                            LastTelehubNum = 0;
                        newPosition = telehub.SpawnPos[LastTelehubNum] + new Vector3(telehub.TelehubLocX, telehub.TelehubLocY, telehub.TelehubLocZ);
                        LastTelehubNum++;
                        if (LastTelehubNum == telehub.SpawnPos.Count)
                            LastTelehubNum = 0;
                        LastTelehub[scene.RegionInfo.RegionID] = LastTelehubNum;
                    }
                }
                else
                {
                    reason = "Teleport has been blocked for this region.";
                    return false;
                }
            }
            else
            {
                //If they are owner, they don't have to have permissions checked
                if (!scene.Permissions.GenericParcelPermission(userID, ILO, (ulong)GroupPowers.None))
                {
                    if (ILO.LandData.LandingType == 2) //Blocked, force this person off this land
                    {
                        //Find a new parcel for them
                        List<ILandObject> Parcels = parcelManagement.ParcelsNearPoint(Position);
                        if (Parcels.Count == 0)
                        {
                            ScenePresence SP;
                            scene.TryGetScenePresence(userID, out SP);
                            newPosition = parcelManagement.GetNearestRegionEdgePosition(SP);
                        }
                        else
                        {
                            bool found = false;
                            //We need to check here as well for bans, can't toss someone into a parcel they are banned from
                            foreach (ILandObject Parcel in Parcels)
                            {
                                if (!Parcel.IsBannedFromLand(userID))
                                {
                                    //Now we have to check their userloc
                                    if (ILO.LandData.LandingType == 2)
                                        continue; //Blocked, check next one
                                    else if (ILO.LandData.LandingType == 1) //Use their landing spot
                                        newPosition = Parcel.LandData.UserLocation;
                                    else //They allow for anywhere, so dump them in the center at the ground
                                        newPosition = parcelManagement.GetParcelCenterAtGround(Parcel);
                                    found = true;
                                }
                            }
                            if (!found) //Dump them at the edge
                            {
                                if (Sp != null)
                                    newPosition = parcelManagement.GetNearestRegionEdgePosition(Sp);
                                else
                                {
                                    reason = "Banned from this parcel.";
                                    return true;
                                }
                            }
                        }
                    }
开发者ID:mugginsm,项目名称:Aurora-Sim,代码行数:67,代码来源:EstateService.cs

示例10: Sit

        public bool Sit(UUID agentID, UUID partID, Scene scene)
        {
            m_avatarsRwLock.AcquireReaderLock(-1);
            try
            {
                if (m_avatars.ContainsKey(agentID))
                {
                    ScenePresence sp;
                    if (scene.TryGetScenePresence(agentID, out sp))
                    {
                        sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero);

                        return true;
                    }
                }
            }
            finally
            {
                m_avatarsRwLock.ReleaseReaderLock();
            }

            return false;
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:23,代码来源:NPCModule.cs

示例11: Stand

        public bool Stand(UUID agentID, Scene scene)
        {
            m_avatarsRwLock.AcquireReaderLock(-1);
            try
            {
                if (m_avatars.ContainsKey(agentID))
                {
                    ScenePresence sp;
                    if (scene.TryGetScenePresence(agentID, out sp))
                    {
                        sp.StandUp();

                        return true;
                    }
                }
            }
            finally
            {
                m_avatarsRwLock.ReleaseReaderLock();
            }

            return false;
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:23,代码来源:NPCModule.cs

示例12: StopMoveToTarget

        public bool StopMoveToTarget(UUID agentID, Scene scene)
        {
            m_avatarsRwLock.AcquireReaderLock(-1);
            try
            {
                if (m_avatars.ContainsKey(agentID))
                {
                    ScenePresence sp;
                    if (scene.TryGetScenePresence(agentID, out sp))
                    {
                        sp.Velocity = Vector3.Zero;
                        sp.ResetMoveToTarget();

                        return true;
                    }
                }
            }
            finally
            {
                m_avatarsRwLock.ReleaseReaderLock();
            }

            return false;
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:24,代码来源:NPCModule.cs

示例13: CreateNPC

        public UUID CreateNPC(string firstname, string lastname,
                Vector3 position, UUID agentID, UUID owner, 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]);
            }
            */

            m_avatarsRwLock.AcquireWriterLock(-1);
            try
            {
                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;
                }
            }
            finally
            {
                m_avatarsRwLock.ReleaseWriterLock();
            }
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:85,代码来源:NPCModule.cs

示例14: 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

示例15: MoveToTarget

        public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget)
        {
            lock (m_avatars)
            {
                if (m_avatars.ContainsKey(agentID))
                {
                    ScenePresence sp;
                    scene.TryGetScenePresence(agentID, out sp);

                    m_log.DebugFormat(
                        "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
                        sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget);

                    sp.MoveToTarget(pos, noFly, landAtTarget);

                    return true;
                }
            }

            return false;
        }
开发者ID:JAllard,项目名称:osmodified,代码行数:21,代码来源:NPCModule.cs


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