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


C# IScenePresence.AddToPhysicalScene方法代码示例

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


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

示例1: CrossAgentToNewRegionAsync

        /// <summary>
        /// This Closes child agents on neighboring regions
        /// Calls an asynchronous method to do so..  so it doesn't lag the sim.
        /// </summary>
        protected IScenePresence CrossAgentToNewRegionAsync(IScenePresence agent, Vector3 pos,
            GridRegion crossingRegion, bool isFlying)
        {
            m_log.DebugFormat("[EntityTransferModule]: Crossing agent {0} to region {1}", agent.Name, crossingRegion.RegionName);

            IScene m_scene = agent.Scene;

            try
            {
                if (crossingRegion != null)
                {
                    //Make sure that all attachments are ready for the teleport
                    IAttachmentsModule attModule = agent.Scene.RequestModuleInterface<IAttachmentsModule>();
                    if (attModule != null)
                        attModule.ValidateAttachments(agent.UUID);

                    int xOffset = crossingRegion.RegionLocX - m_scene.RegionInfo.RegionLocX;
                    int yOffset = crossingRegion.RegionLocY - m_scene.RegionInfo.RegionLocY;

                    if (xOffset < 0)
                        pos.X += m_scene.RegionInfo.RegionSizeX;
                    else if (xOffset > 0)
                        pos.X -= m_scene.RegionInfo.RegionSizeX;

                    if (yOffset < 0)
                        pos.Y += m_scene.RegionInfo.RegionSizeY;
                    else if (yOffset > 0)
                        pos.Y -= m_scene.RegionInfo.RegionSizeY;

                    //Make sure that they are within bounds (velocity can push it out of bounds)
                    if (pos.X < 0)
                        pos.X = 1;
                    if (pos.Y < 0)
                        pos.Y = 1;

                    if (pos.X > crossingRegion.RegionSizeX)
                        pos.X = crossingRegion.RegionSizeX - 1;
                    if (pos.Y > crossingRegion.RegionSizeY)
                        pos.Y = crossingRegion.RegionSizeY - 1;

                    AgentData cAgent = new AgentData();
                    agent.CopyTo(cAgent);
                    cAgent.Position = pos;
                    if (isFlying)
                        cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;

                    AgentCircuitData agentCircuit = agent.ControllingClient.RequestClientInfo();
                    agentCircuit.startpos = pos;
                    agentCircuit.child = false;
                    IAvatarAppearanceModule appearance = agent.RequestModuleInterface<IAvatarAppearanceModule>();
                    if (appearance != null)
                        agentCircuit.Appearance = appearance.Appearance;

                    IEventQueueService eq = agent.Scene.RequestModuleInterface<IEventQueueService>();
                    if (eq != null)
                    {
                        //This does UpdateAgent and closing of child agents
                        //  messages if they need to be called
                        ISyncMessagePosterService syncPoster = agent.Scene.RequestModuleInterface<ISyncMessagePosterService>();
                        if (syncPoster != null)
                        {
                            OSDMap map = syncPoster.Get(SyncMessageHelper.CrossAgent(crossingRegion, pos,
                                agent.Velocity, agentCircuit, cAgent, agent.Scene.RegionInfo.RegionHandle),
                                agent.Scene.RegionInfo.RegionHandle);
                            bool result = false;
                            if (map != null)
                                result = map["Success"].AsBoolean();
                            if (!result)
                            {
                                agent.ControllingClient.SendTeleportFailed(map["Reason"].AsString());
                                // If the cross was successful, this agent is a child agent
                                // Otherwise, put them back in the scene
                                if (!agent.IsChildAgent)
                                {
                                    bool m_flying = ((agent.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
                                    agent.AddToPhysicalScene(m_flying, false);
                                }

                                // In any case
                                agent.NotInTransit();
                                return agent;
                            }
                        }
                    }

                    agent.MakeChildAgent();

                    //Revolution- We already were in this region... we don't need updates about the avatars we already know about, right?
                    // OLD: now we have a child agent in this region. Request and send all interesting data about (root) agents in the sim
                    //agent.SendOtherAgentsAvatarDataToMe();
                    //agent.SendOtherAgentsAppearanceToMe();

                    //Kill the groups here, otherwise they will become ghost attachments 
                    //  and stay in the sim, they'll get readded below into the new sim
                    KillAttachments(agent);
                }
//.........这里部分代码省略.........
开发者ID:x8ball,项目名称:Aurora-Sim,代码行数:101,代码来源:EntityTransferModule.cs


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