public void CompleteMovement(IClientAPI client)
{
DateTime startTime = DateTime.Now;
m_log.DebugFormat(
"[SCENE PRESENCE]: Completing movement of {0} into region {1}",
client.Name, Scene.RegionInfo.RegionName);
Vector3 look = Velocity;
if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
{
look = new Vector3(0.99f, 0.042f, 0);
}
// Prevent teleporting to an underground location
// (may crash client otherwise)
//
Vector3 pos = AbsolutePosition;
float ground = m_scene.GetGroundHeight(pos.X, pos.Y);
if (pos.Z < ground + 1.5f)
{
pos.Z = ground + 1.5f;
AbsolutePosition = pos;
}
m_isChildAgent = false;
bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
MakeRootAgent(AbsolutePosition, m_flying);
if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
{
m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
m_callbackURI = null;
}
//m_log.DebugFormat("Completed movement");
m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
SendInitialData();
// Create child agents in neighbouring regions
if (!m_isChildAgent)
{
IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
if (m_agentTransfer != null)
m_agentTransfer.EnableChildAgents(this);
else
m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
if (friendsModule != null)
friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
}
m_log.DebugFormat(
"[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
}