//-------------------------------------------------- //-------------------------------------------------- public void ExitTunnel() //-------------------------------------------------- { if (null == m_scientistPlayer.transform.parent) // player already in control room { return; } teleportCallback = ExitTunnelAfterFade; EventsManager.Teleport(teleportCallback); }
//-------------------------------------------------- //-------------------------------------------------- public void TeleportToRover() //-------------------------------------------------- { if (m_roverManagers.Count <= 0) { return; } teleportCallback = TeleportToRoverAfterFade; EventsManager.Teleport(teleportCallback); }
//-------------------------------------------------- //-------------------------------------------------- IEnumerator FadeOutCR(TeleportCallback teleportCallback) //-------------------------------------------------- { fadePanelUp.enabled = true; fadePanelUp.canvasRenderer.SetAlpha(0.1f); fadePanelUp.CrossFadeAlpha(1f, 1f, false); yield return(new WaitForSeconds(1f)); teleportCallback(); StartCoroutine(FadeInCR()); }
/// <summary> /// /// </summary> /// <param name="regionHandle"></param> /// <param name="position"></param> /// <param name="lookAt"></param> /// <param name="tc"></param> public void BeginTeleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt, TeleportCallback tc) { OnBeginTeleport = tc; TeleportLocationRequestPacket teleport = new TeleportLocationRequestPacket(); teleport.AgentData.AgentID = Client.Network.AgentID; teleport.AgentData.SessionID = Client.Network.SessionID; teleport.Info.LookAt = lookAt; teleport.Info.Position = position; teleport.Info.RegionHandle = regionHandle; Client.Log("Teleporting to region " + regionHandle.ToString(), Helpers.LogLevel.Info); Client.Network.SendPacket(teleport); }
/// <summary> /// /// </summary> /// <param name="packet"></param> /// <param name="simulator"></param> private void TeleportHandler(Packet packet, Simulator simulator) { if (packet.Type == PacketType.TeleportStart) { TeleportMessage = "Teleport started"; TeleportStat = TeleportStatus.Start; if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } } else if (packet.Type == PacketType.TeleportProgress) { TeleportMessage = Helpers.FieldToString(((TeleportProgressPacket)packet).Info.Message); TeleportStat = TeleportStatus.Progress; if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } } else if (packet.Type == PacketType.TeleportFailed) { TeleportMessage = Helpers.FieldToString(((TeleportFailedPacket)packet).Info.Reason); TeleportStat = TeleportStatus.Failed; if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } OnBeginTeleport = null; } else if (packet.Type == PacketType.TeleportFinish) { TeleportFinishPacket finish = (TeleportFinishPacket)packet; // Connect to the new sim Simulator sim = Client.Network.Connect(new IPAddress((long)finish.Info.SimIP), finish.Info.SimPort, simulator.CircuitCode, true); if (sim != null) { TeleportMessage = "Teleport finished"; TeleportStat = TeleportStatus.Finished; // Move the avatar in to the new sim CompleteAgentMovementPacket move = new CompleteAgentMovementPacket(); move.AgentData.AgentID = Client.Network.AgentID; move.AgentData.SessionID = Client.Network.SessionID; move.AgentData.CircuitCode = simulator.CircuitCode; Client.Network.SendPacket((Packet)move); Client.DebugLog(move.ToString()); Client.Log("Moved to new sim " + Client.Network.CurrentSim.Region.Name + "(" + Client.Network.CurrentSim.IPEndPoint.ToString() + ")", Helpers.LogLevel.Info); if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } else { // Sleep a little while so we can collect parcel information System.Threading.Thread.Sleep(1000); } } else { TeleportMessage = "Failed to connect to the new sim after a teleport"; TeleportStat = TeleportStatus.Failed; Client.Log(TeleportMessage, Helpers.LogLevel.Warning); if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } } OnBeginTeleport = null; } }
/// <summary> /// /// </summary> /// <param name="regionHandle"></param> /// <param name="position"></param> /// <param name="tc"></param> public void BeginTeleport(ulong regionHandle, LLVector3 position, TeleportCallback tc) { BeginTeleport(regionHandle, position, new LLVector3(position.X + 1.0f, position.Y, position.Z), tc); }
/// <summary> /// /// </summary> /// <param name="packet"></param> /// <param name="simulator"></param> private void TeleportHandler(Packet packet, Simulator simulator) { if (packet.Type == PacketType.TeleportStart) { TeleportMessage = "Teleport started"; TeleportStat = TeleportStatus.Start; if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } } else if (packet.Type == PacketType.TeleportProgress) { TeleportMessage = Helpers.FieldToString(((TeleportProgressPacket)packet).Info.Message); TeleportStat = TeleportStatus.Progress; if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } } else if (packet.Type == PacketType.TeleportFailed) { TeleportMessage = Helpers.FieldToString(((TeleportFailedPacket)packet).Info.Reason); TeleportStat = TeleportStatus.Failed; if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } OnBeginTeleport = null; } else if (packet.Type == PacketType.TeleportFinish) { TeleportFinishPacket finish = (TeleportFinishPacket)packet; // Connect to the new sim Simulator sim = Client.Network.Connect(new IPAddress((long)finish.Info.SimIP), finish.Info.SimPort, simulator.CircuitCode, true); if ( sim != null) { TeleportMessage = "Teleport finished"; TeleportStat = TeleportStatus.Finished; // Move the avatar in to the new sim CompleteAgentMovementPacket move = new CompleteAgentMovementPacket(); move.AgentData.AgentID = Client.Network.AgentID; move.AgentData.SessionID = Client.Network.SessionID; move.AgentData.CircuitCode = simulator.CircuitCode; Client.Network.SendPacket((Packet)move); Client.DebugLog(move.ToString()); Client.Log("Moved to new sim " + Client.Network.CurrentSim.Region.Name + "(" + Client.Network.CurrentSim.IPEndPoint.ToString() + ")", Helpers.LogLevel.Info); if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } else { // Sleep a little while so we can collect parcel information System.Threading.Thread.Sleep(1000); } } else { TeleportMessage = "Failed to connect to the new sim after a teleport"; TeleportStat = TeleportStatus.Failed; Client.Log(TeleportMessage, Helpers.LogLevel.Warning); if (OnBeginTeleport != null) { OnBeginTeleport(TeleportMessage, TeleportStat); } } OnBeginTeleport = null; } }
/// <summary> /// Handler for teleport Requests /// </summary> /// <param name="packet">Incoming TeleportHandler packet</param> /// <param name="simulator">Simulator sending teleport information</param> private void TeleportHandler(Packet packet, Simulator simulator) { if (packet.Type == PacketType.TeleportStart) { Client.DebugLog("TeleportStart received from " + simulator.ToString()); teleportMessage = "Teleport started"; TeleportStat = TeleportStatus.Start; if (OnBeginTeleport != null) { OnBeginTeleport(Client.Network.CurrentSim, teleportMessage, TeleportStat); } } else if (packet.Type == PacketType.TeleportProgress) { Client.DebugLog("TeleportProgress received from " + simulator.ToString()); teleportMessage = Helpers.FieldToString(((TeleportProgressPacket)packet).Info.Message); TeleportStat = TeleportStatus.Progress; if (OnBeginTeleport != null) { OnBeginTeleport(Client.Network.CurrentSim, teleportMessage, TeleportStat); } } else if (packet.Type == PacketType.TeleportFailed) { Client.DebugLog("TeleportFailed received from " + simulator.ToString()); teleportMessage = Helpers.FieldToString(((TeleportFailedPacket)packet).Info.Reason); TeleportStat = TeleportStatus.Failed; if (OnBeginTeleport != null) { OnBeginTeleport(Client.Network.CurrentSim, teleportMessage, TeleportStat); } OnBeginTeleport = null; } else if (packet.Type == PacketType.TeleportFinish) { Client.DebugLog("TeleportFinish received from " + simulator.ToString()); TeleportFinishPacket finish = (TeleportFinishPacket)packet; Simulator previousSim = Client.Network.CurrentSim; // Connect to the new sim String seedcaps = Encoding.UTF8.GetString(finish.Info.SeedCapability).Replace("\x00",""); Simulator sim = Client.Network.Connect(new IPAddress((long)finish.Info.SimIP), finish.Info.SimPort, simulator.CircuitCode, true, seedcaps); if (sim != null) { teleportMessage = "Teleport finished"; TeleportStat = TeleportStatus.Finished; // Move the avatar in to the new sim CompleteAgentMovementPacket move = new CompleteAgentMovementPacket(); move.AgentData.AgentID = Client.Network.AgentID; move.AgentData.SessionID = Client.Network.SessionID; move.AgentData.CircuitCode = simulator.CircuitCode; Client.Network.SendPacket(move, sim); // Disconnect from the previous sim Client.Network.DisconnectSim(previousSim); Client.Log("Moved to new sim " + sim.ToString(), Helpers.LogLevel.Info); if (OnBeginTeleport != null) { OnBeginTeleport(sim, teleportMessage, TeleportStat); } else { // Sleep a little while so we can collect parcel information // NOTE: This doesn't belong in libsecondlife // System.Threading.Thread.Sleep(1000); } } else { teleportMessage = "Failed to connect to the new sim after a teleport"; TeleportStat = TeleportStatus.Failed; // FIXME: Set the previous CurrentSim to the current simulator again Client.Log(teleportMessage, Helpers.LogLevel.Warning); if (OnBeginTeleport != null) { OnBeginTeleport(Client.Network.CurrentSim, teleportMessage, TeleportStat); } } OnBeginTeleport = null; } }
//-------------------------------------------------- #endregion //-------------------------------------------------- void FadeOutThenTeleport(TeleportCallback teleportCallback) //-------------------------------------------------- { StopAllCoroutines(); StartCoroutine(FadeOutCR(teleportCallback)); }