예제 #1
0
        public virtual void InternalCross(IScenePresence agent, Vector3 attemptedPos, bool isFlying,
                                          GridRegion crossingRegion)
        {
            MainConsole.Instance.DebugFormat("[EntityTransferModule]: Crossing agent {0} to region {1}", agent.Name,
                                             crossingRegion.RegionName);

            try
            {
                agent.SetAgentLeaving(crossingRegion);

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

                AgentCircuitData agentCircuit = BuildCircuitDataForPresence(agent, attemptedPos);
                agentCircuit.TeleportFlags = (uint)TeleportFlags.ViaRegionID;

                //This does UpdateAgent and closing of child agents
                //  messages if they need to be called
                ISyncMessagePosterService syncPoster =
                    agent.Scene.RequestModuleInterface <ISyncMessagePosterService>();
                if (syncPoster != null)
                {
                    syncPoster.PostToServer(SyncMessageHelper.CrossAgent(crossingRegion, attemptedPos,
                                                                         agent.Velocity, agentCircuit, cAgent,
                                                                         agent.Scene.RegionInfo.RegionID));
                }
            }
            catch (Exception ex)
            {
                MainConsole.Instance.Warn("[EntityTransferModule]: Exception in crossing: " + ex);
            }
        }
예제 #2
0
        public void OnConnectionClose(IClientAPI client)
        {
            IScenePresence sp = null;

            client.Scene.TryGetScenePresence(client.AgentId, out sp);
            if (sp == null)
            {
                return;         // unable to find agent
            }
            if (client.IsLoggingOut && !sp.IsChildAgent)
            {
                MainConsole.Instance.InfoFormat("[Activity detector]: Detected logout of user {0} in region {1}",
                                                client.Name,
                                                client.Scene.RegionInfo.RegionName);

                //Inform the grid service about it

                if (m_zombieAgents.Contains(client.AgentId))
                {
                    m_zombieAgents.Remove(client.AgentId);
                    return; //They are a known zombie, just clear them out and go on with life!
                }
                AgentPosition agentpos = new AgentPosition {
                    AgentID  = sp.UUID,
                    AtAxis   = sp.CameraAtAxis,
                    Center   = sp.CameraPosition,
                    Far      = sp.DrawDistance,
                    LeftAxis = Vector3.Zero,
                    Position = sp.AbsolutePosition
                };
                if (agentpos.Position.X > sp.Scene.RegionInfo.RegionSizeX)
                {
                    agentpos.Position.X = sp.Scene.RegionInfo.RegionSizeX;
                }
                if (agentpos.Position.Y > sp.Scene.RegionInfo.RegionSizeY)
                {
                    agentpos.Position.Y = sp.Scene.RegionInfo.RegionSizeY;
                }
                if (agentpos.Position.Z > sp.Scene.RegionInfo.RegionSizeZ)
                {
                    agentpos.Position.Z = sp.Scene.RegionInfo.RegionSizeZ;
                }
                if (agentpos.Position.X < 0)
                {
                    agentpos.Position.X = 0;
                }
                if (agentpos.Position.Y < 0)
                {
                    agentpos.Position.Y = 0;
                }
                if (agentpos.Position.Z < 0)
                {
                    agentpos.Position.Z = 0;
                }
                agentpos.RegionHandle     = sp.Scene.RegionInfo.RegionHandle;
                agentpos.Size             = sp.PhysicsActor != null ? sp.PhysicsActor.Size : new Vector3(0, 0, 1.8f);
                agentpos.UpAxis           = Vector3.Zero;
                agentpos.Velocity         = sp.Velocity;
                agentpos.UserGoingOffline = true; //Don't attempt to add us into other regions

                //Send the child agent data update
                ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface <ISyncMessagePosterService> ();
                if (syncPoster != null)
                {
                    syncPoster.PostToServer(SyncMessageHelper.AgentLoggedOut(client.AgentId,
                                                                             client.Scene.RegionInfo.RegionID, agentpos));
                }
            }
        }