public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt,
                                       uint teleportFlags)
        {
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
            if (finalDestination == null)
            {
                sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
                return;
            }

            MainConsole.Instance.DebugFormat("[Entity transfer]: Request Teleport to {0}:{1}/{2}",
                                             finalDestination.ServerURI, finalDestination.RegionName, position);

            sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");
            sp.SetAgentLeaving(finalDestination);

            // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
            // both regions
            if (sp.ParentID != UUID.Zero)
            {
                sp.StandUp();
            }

            AgentCircuitData agentCircuit = BuildCircuitDataForPresence(sp, position);

            AgentData agent = new AgentData();

            sp.CopyTo(agent);
            // Fix the position
            agent.Position = position;

            ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface <ISyncMessagePosterService> ();

            if (syncPoster != null)
            {
                // This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
                //  messages if they need to be called and deals with the callback
                syncPoster.PostToServer(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
                                                                        agentCircuit,
                                                                        agent,
                                                                        teleportFlags,
                                                                        finalDestination,
                                                                        sp.Scene.RegionInfo.RegionID));
            }
        }
Exemplo n.º 2
0
        public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
        {
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
            if (finalDestination == null)
            {
                sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
                return;
            }

            m_log.DebugFormat(
                "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}",
                finalDestination.ServerURI, finalDestination.RegionName, position);

            sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");

            // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
            // both regions
            if (sp.ParentID != UUID.Zero)
            {
                sp.StandUp();
            }

            //Make sure that all attachments are ready for the teleport
            IAttachmentsModule attModule = sp.Scene.RequestModuleInterface <IAttachmentsModule>();

            if (attModule != null)
            {
                attModule.ValidateAttachments(sp.UUID);
            }

            AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();

            agentCircuit.startpos = position;
            //The agent will be a root agent
            agentCircuit.child = false;
            //Make sure the appearnace is right
            IAvatarAppearanceModule appearance = sp.RequestModuleInterface <IAvatarAppearanceModule> ();

            agentCircuit.Appearance = appearance.Appearance;

            AgentData agent = new AgentData();

            sp.CopyTo(agent);
            //Fix the position
            agent.Position = position;

            IEventQueueService eq = sp.Scene.RequestModuleInterface <IEventQueueService>();

            if (eq != null)
            {
                ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface <ISyncMessagePosterService>();
                if (syncPoster != null)
                {
                    //This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
                    //  messages if they need to be called and deals with the callback
                    OSDMap map = syncPoster.Get(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
                                                                                agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle),
                                                sp.Scene.RegionInfo.RegionHandle);
                    bool result = map["Success"].AsBoolean();
                    if (!result)
                    {
                        // Fix the agent status
                        sp.IsChildAgent = false;
                        sp.ControllingClient.SendTeleportFailed(map["Reason"].AsString());
                        return;
                    }
                }
            }

            //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(sp);

            // Well, this is it. The agent is over there.
            KillEntity(sp.Scene, sp);

            //Make it a child agent for now... the grid will kill us later if we need to close
            sp.MakeChildAgent();
        }