/// <summary> /// A coroutine that moves the camera rig to the teleport location over time. /// </summary> /// <returns></returns> private IEnumerator Move() { if (teleportStatus == TeleportStatus.Moving) { yield break; } teleportStatus = TeleportStatus.Moving; VirtualFollower head = PuppetJumpManager.Instance.puppetRig.GetComponent <PuppetRigVR>().virtualFollowers.head; float i = 0; float rate = 1 / teleportSpeed; while (i < 1) { teleportStatus = TeleportStatus.Moving; i += rate * Time.deltaTime; PuppetJumpManager.Instance.puppetRig.transform.position = Vector3.Lerp(initialPos, finalPos, teleportCurve.Evaluate(i)); // update the height and center charcater controller float newHeight = head.transform.localPosition.y; PuppetJumpManager.Instance.puppetRig.characterController.height = newHeight; Vector3 newCenter = PuppetJumpManager.Instance.puppetRig.characterController.center; newCenter = new Vector3(head.transform.localPosition.x, PuppetJumpManager.Instance.puppetRig.transform.position.y + (newHeight * 0.5f), head.transform.localPosition.z); PuppetJumpManager.Instance.puppetRig.characterController.center = newCenter; yield return(null); } teleportStatus = TeleportStatus.Idle; }
public void EndSearchForTeleport() { if (teleportStatus == TeleportStatus.Searching) { teleportStatus = TeleportStatus.StartTeleporting; } }
public EnemyInfo UpdateRecall(TeleportType t, TeleportStatus s, int dur, int st) { IncomingDamage.Clear(); LockedTarget = false; EstimatedShootT = 0; if (t == TeleportType.Recall && s == TeleportStatus.Abort) { abduration = dur; abstart = st; AbortedT = Utils.TickCount; } else { AbortedT = 0; } type = t; status = s; if (s == TeleportStatus.Start) { duration = dur; } start = st; Console.WriteLine("" + t + " " + s + " " + duration + " " + start + ""); return(EnemyInfo); }
public RecallInf(int netid, TeleportStatus stat, TeleportType tpe, int dura, int star = 0) { NetworkID = netid; Status = stat; Type = tpe; Duration = dura; Start = star; }
public virtual void Start() { // initialize the move coroutine move = Move(); // set the initial state of the teleporter teleportStatus = TeleportStatus.Idle; // hide the reticle ShowReticle(false); }
private void Avatar_OnTeleportMessage(string message, TeleportStatus status) { Console.WriteLine(message); if (status == TeleportStatus.Finished || status == TeleportStatus.Failed) { DoneTeleporting = true; } }
private static void OnTeleport(Obj_AI_Base sender, Teleport.TeleportEventArgs args) { if (sender.IsAlly || sender.IsMe) { return; } teleport = args.Status; if (!(sender is AIHeroClient)) { return; } var unit = Recalls.Find(h => h.Unit.NetworkId == sender.NetworkId); if (unit == null || args.Type != TeleportType.Recall) { return; } switch (teleport) { case TeleportStatus.Start: { unit.Status = RecallStatus.Active; unit.Started = Game.Time; unit.Duration = (float)args.Duration / 1000; break; } case TeleportStatus.Abort: { unit.Status = RecallStatus.Abort; unit.Ended = Game.Time; if (Game.Time == unit.Ended) { Core.DelayAction(() => unit.Status = RecallStatus.Inactive, 2000); } break; } case TeleportStatus.Finish: { unit.Status = RecallStatus.Finished; unit.Ended = Game.Time; if (Game.Time == unit.Ended) { Core.DelayAction(() => unit.Status = RecallStatus.Inactive, 2000); } break; } } }
public RecallInfo(EnemyInfo enemyInfo) { EnemyInfo = enemyInfo; type = TeleportType.Unknown; status = TeleportStatus.Unknown; duration = 0; start = 0; abduration = 0; abstart = 0; IncomingDamage = new Dictionary <int, float>(); }
/// <summary> /// /// </summary> /// <param name="regionHandle"></param> /// <param name="position"></param> /// <param name="lookAt"></param> /// <returns></returns> public bool Teleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt) { TeleportStat = TeleportStatus.None; 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); // Start the timeout check TeleportTimeout = false; TeleportTimer.Start(); Client.Network.SendPacket(teleport); while (TeleportStat != TeleportStatus.Failed && TeleportStat != TeleportStatus.Finished && !TeleportTimeout) { Client.Tick(); } TeleportTimer.Stop(); if (TeleportTimeout) { TeleportMessage = "Teleport timed out."; TeleportStat = TeleportStatus.Failed; if (OnTeleport != null) { OnTeleport(TeleportMessage, TeleportStat); } } else { if (OnTeleport != null) { OnTeleport(TeleportMessage, TeleportStat); } } return(TeleportStat == TeleportStatus.Finished); }
/// <summary> /// Uses a controller to change the status of the teleporter. /// Then handles that status. /// </summary> void Update() { if (teleportStatus == TeleportStatus.Idle && teleportStatusCheck != TeleportStatus.Idle) { ClearLine(); ShowReticle(false); teleportStatusCheck = TeleportStatus.Idle; } if (teleportStatus == TeleportStatus.Searching) { //continually check for teleport if (pointerType == PointerTypes.Straight) { SearchForTeleportStraight(); } else if (pointerType == PointerTypes.FallOff) { SearchForTeleportFallOff(); } teleportStatusCheck = TeleportStatus.Searching; } if (teleportStatus == TeleportStatus.StartTeleporting && teleportStatusCheck != TeleportStatus.StartTeleporting) { //if on a spot that could be teleported to if (onTeleportSpot) { Teleport(); } teleportStatusCheck = TeleportStatus.StartTeleporting; if (instantTeleport) { teleportStatus = TeleportStatus.Idle; } } if (teleportStatus == TeleportStatus.Moving && teleportStatusCheck != TeleportStatus.Moving) { ClearLine(); ShowReticle(false); teleportStatusCheck = TeleportStatus.Moving; } }
/// <summary> /// /// </summary> /// <param name="simName"></param> /// <param name="position"></param> /// <param name="lookAt"></param> /// <returns></returns> public bool Teleport(string simName, LLVector3 position, LLVector3 lookAt) { int attempts = 0; TeleportStat = TeleportStatus.None; simName = simName.ToLower(); GridRegion region = Client.Grid.GetGridRegion(simName); if (region != null) { return(Teleport(region.RegionHandle, position, lookAt)); } else { while (attempts++ < 5) { region = Client.Grid.GetGridRegion(simName); if (region != null) { return(Teleport(region.RegionHandle, position, lookAt)); } else { // Request the region info again Client.Grid.AddSim(simName); System.Threading.Thread.Sleep(1000); } } } if (OnTeleport != null) { TeleportMessage = "Unable to resolve name: " + simName; TeleportStat = TeleportStatus.Failed; OnTeleport(TeleportMessage, TeleportStat); } return(false); }
/// <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="simName"></param> /// <param name="position"></param> /// <param name="lookAt"></param> /// <returns></returns> public bool Teleport(string simName, LLVector3 position, LLVector3 lookAt) { int attempts = 0; TeleportStat = TeleportStatus.None; simName = simName.ToLower(); GridRegion region = Client.Grid.GetGridRegion(simName); if (region != null) { return Teleport(region.RegionHandle, position, lookAt); } else { while (attempts++ < 5) { region = Client.Grid.GetGridRegion(simName); if (region != null) { return Teleport(region.RegionHandle, position, lookAt); } else { // Request the region info again Client.Grid.AddSim(simName); System.Threading.Thread.Sleep(1000); } } } if (OnTeleport != null) { TeleportMessage = "Unable to resolve name: " + simName; TeleportStat = TeleportStatus.Failed; OnTeleport(TeleportMessage, TeleportStat); } return false; }
public RecallInfo(EnemyInfo enemyInfo) { EnemyInfo = enemyInfo; type = TeleportType.Unknown; status = TeleportStatus.Unknown; duration = 0; start = 0; abduration = 0; abstart = 0; IncomingDamage = new Dictionary<int, float>(); }
/// <summary>Process an incoming packet and raise the appropriate events</summary> /// <param name="sender">The sender</param> /// <param name="e">The EventArgs object containing the packet data</param> protected void TeleportHandler(object sender, PacketReceivedEventArgs e) { Packet packet = e.Packet; Simulator simulator = e.Simulator; bool finished = false; TeleportFlags flags = TeleportFlags.Default; if (packet.Type == PacketType.TeleportStart) { TeleportStartPacket start = (TeleportStartPacket)packet; teleportMessage = "Teleport started"; flags = (TeleportFlags)start.Info.TeleportFlags; teleportStat = TeleportStatus.Start; Logger.DebugLog("TeleportStart received, Flags: " + flags.ToString(), Client); } else if (packet.Type == PacketType.TeleportProgress) { TeleportProgressPacket progress = (TeleportProgressPacket)packet; teleportMessage = Utils.BytesToString(progress.Info.Message); flags = (TeleportFlags)progress.Info.TeleportFlags; teleportStat = TeleportStatus.Progress; Logger.DebugLog("TeleportProgress received, Message: " + teleportMessage + ", Flags: " + flags.ToString(), Client); } else if (packet.Type == PacketType.TeleportFailed) { TeleportFailedPacket failed = (TeleportFailedPacket)packet; teleportMessage = Utils.BytesToString(failed.Info.Reason); teleportStat = TeleportStatus.Failed; finished = true; Logger.DebugLog("TeleportFailed received, Reason: " + teleportMessage, Client); } else if (packet.Type == PacketType.TeleportFinish) { TeleportFinishPacket finish = (TeleportFinishPacket)packet; flags = (TeleportFlags)finish.Info.TeleportFlags; string seedcaps = Utils.BytesToString(finish.Info.SeedCapability); finished = true; Logger.DebugLog("TeleportFinish received, Flags: " + flags.ToString(), Client); // Connect to the new sim Simulator newSimulator = Client.Network.Connect(new IPAddress(finish.Info.SimIP), finish.Info.SimPort, finish.Info.RegionHandle, true, seedcaps); if (newSimulator != null) { teleportMessage = "Teleport finished"; teleportStat = TeleportStatus.Finished; Logger.Log("Moved to new sim " + newSimulator.ToString(), Helpers.LogLevel.Info, Client); } else { teleportMessage = "Failed to connect to the new sim after a teleport"; teleportStat = TeleportStatus.Failed; // We're going to get disconnected now Logger.Log(teleportMessage, Helpers.LogLevel.Error, Client); } } else if (packet.Type == PacketType.TeleportCancel) { //TeleportCancelPacket cancel = (TeleportCancelPacket)packet; teleportMessage = "Cancelled"; teleportStat = TeleportStatus.Cancelled; finished = true; Logger.DebugLog("TeleportCancel received from " + simulator.ToString(), Client); } else if (packet.Type == PacketType.TeleportLocal) { TeleportLocalPacket local = (TeleportLocalPacket)packet; teleportMessage = "Teleport finished"; flags = (TeleportFlags)local.Info.TeleportFlags; teleportStat = TeleportStatus.Finished; relativePosition = local.Info.Position; Movement.Camera.LookDirection(local.Info.LookAt); // This field is apparently not used for anything //local.Info.LocationID; finished = true; Logger.DebugLog("TeleportLocal received, Flags: " + flags.ToString(), Client); } if (m_Teleport != null) { OnTeleport(new TeleportEventArgs(teleportMessage, teleportStat, flags)); } if (finished) teleportEvent.Set(); }
/// <summary> /// Teleport agent to another region /// </summary> /// <param name="regionHandle">handle of region to teleport agent to</param> /// <param name="position"><seealso cref="Vector3"/> position in destination sim to teleport to</param> /// <param name="lookAt"><seealso cref="Vector3"/> direction in destination sim agent will look at</param> /// <returns>true on success, false on failure</returns> /// <remarks>This call is blocking</remarks> public bool Teleport(ulong regionHandle, Vector3 position, Vector3 lookAt) { if (Network.CurrentSim == null || Network.CurrentSim.Caps == null || !Network.CurrentSim.Caps.IsEventQueueRunning) { // Wait a bit to see if the event queue comes online AutoResetEvent queueEvent = new AutoResetEvent(false); NetworkManager.EventQueueRunningCallback queueCallback = delegate(Simulator simulator) { if (simulator == Network.CurrentSim) queueEvent.Set(); }; Network.OnEventQueueRunning += queueCallback; queueEvent.WaitOne(10 * 1000, false); Network.OnEventQueueRunning -= queueCallback; } teleportStat = TeleportStatus.None; teleportEvent.Reset(); RequestTeleport(regionHandle, position, lookAt); teleportEvent.WaitOne(TeleportTimeout, false); if (teleportStat == TeleportStatus.None || teleportStat == TeleportStatus.Start || teleportStat == TeleportStatus.Progress) { teleportMessage = "Teleport timed out."; teleportStat = TeleportStatus.Failed; } return (teleportStat == TeleportStatus.Finished); }
/// <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; } }
public EnemyInfo UpdateRecall(TeleportType t, TeleportStatus s, int dur, int st) { IncomingDamage.Clear(); LockedTarget = false; EstimatedShootT = 0; if (t == TeleportType.Recall && s == TeleportStatus.Abort) { abduration = dur; abstart = st; AbortedT = Utils.TickCount; } else { AbortedT = 0; } type = t; status = s; if (s == TeleportStatus.Start) { duration = dur; } start = st; Console.WriteLine("" + t + " " + s + " " + duration + " " + start + ""); return EnemyInfo; }
public void StartSearchForTeleport() { cameraRig = PuppetJumpManager.Instance.cameraRig; teleportStatus = TeleportStatus.Searching; }
/// <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) { bool finished = false; TeleportFlags flags = TeleportFlags.Default; if (packet.Type == PacketType.TeleportStart) { TeleportStartPacket start = (TeleportStartPacket)packet; teleportMessage = "Teleport started"; flags = (TeleportFlags)start.Info.TeleportFlags; teleportStat = TeleportStatus.Start; Client.DebugLog("TeleportStart received, Flags: " + flags.ToString()); } else if (packet.Type == PacketType.TeleportProgress) { TeleportProgressPacket progress = (TeleportProgressPacket)packet; teleportMessage = Helpers.FieldToUTF8String(progress.Info.Message); flags = (TeleportFlags)progress.Info.TeleportFlags; teleportStat = TeleportStatus.Progress; Client.DebugLog("TeleportProgress received, Message: " + teleportMessage + ", Flags: " + flags.ToString()); } else if (packet.Type == PacketType.TeleportFailed) { TeleportFailedPacket failed = (TeleportFailedPacket)packet; teleportMessage = Helpers.FieldToUTF8String(failed.Info.Reason); teleportStat = TeleportStatus.Failed; finished = true; Client.DebugLog("TeleportFailed received, Reason: " + teleportMessage); } else if (packet.Type == PacketType.TeleportFinish) { TeleportFinishPacket finish = (TeleportFinishPacket)packet; flags = (TeleportFlags)finish.Info.TeleportFlags; string seedcaps = Helpers.FieldToUTF8String(finish.Info.SeedCapability); finished = true; Client.DebugLog("TeleportFinish received, Flags: " + flags.ToString()); // Connect to the new sim Simulator newSimulator = Client.Network.Connect(new IPAddress(finish.Info.SimIP), finish.Info.SimPort, finish.Info.RegionHandle, true, seedcaps); if (newSimulator != null) { teleportMessage = "Teleport finished"; teleportStat = TeleportStatus.Finished; // Disconnect from the previous sim Client.Network.DisconnectSim(simulator, true); Client.Log("Moved to new sim " + newSimulator.ToString(), Helpers.LogLevel.Info); } else { teleportMessage = "Failed to connect to the new sim after a teleport"; teleportStat = TeleportStatus.Failed; // We're going to get disconnected now Client.Log(teleportMessage, Helpers.LogLevel.Error); } } else if (packet.Type == PacketType.TeleportCancel) { //TeleportCancelPacket cancel = (TeleportCancelPacket)packet; teleportMessage = "Cancelled"; teleportStat = TeleportStatus.Cancelled; finished = true; Client.DebugLog("TeleportCancel received from " + simulator.ToString()); } else if (packet.Type == PacketType.TeleportLocal) { TeleportLocalPacket local = (TeleportLocalPacket)packet; teleportMessage = "Teleport finished"; flags = (TeleportFlags)local.Info.TeleportFlags; teleportStat = TeleportStatus.Finished; relativePosition = local.Info.Position; Movement.Camera.LookDirection(local.Info.LookAt); // This field is apparently not used for anything //local.Info.LocationID; finished = true; Client.DebugLog("TeleportLocal received, Flags: " + flags.ToString()); } if (OnTeleport != null) { try { OnTeleport(teleportMessage, teleportStat, flags); } catch (Exception e) { Client.Log(e.ToString(), Helpers.LogLevel.Error); } } if (finished) teleportEvent.Set(); }
/// <summary> /// Teleport agent to a landmark /// </summary> /// <param name="landmark"><seealso cref="UUID"/> of the landmark to teleport agent to</param> /// <returns>true on success, false on failure</returns> public bool Teleport(UUID landmark) { teleportStat = TeleportStatus.None; teleportEvent.Reset(); TeleportLandmarkRequestPacket p = new TeleportLandmarkRequestPacket(); p.Info = new TeleportLandmarkRequestPacket.InfoBlock(); p.Info.AgentID = Client.Self.AgentID; p.Info.SessionID = Client.Self.SessionID; p.Info.LandmarkID = landmark; Client.Network.SendPacket(p); teleportEvent.WaitOne(Client.Settings.TELEPORT_TIMEOUT, false); if (teleportStat == TeleportStatus.None || teleportStat == TeleportStatus.Start || teleportStat == TeleportStatus.Progress) { teleportMessage = "Teleport timed out."; teleportStat = TeleportStatus.Failed; } return (teleportStat == TeleportStatus.Finished); }
/// <summary> /// Teleport agent to another region /// </summary> /// <param name="regionHandle">handle of region to teleport agent to</param> /// <param name="position"><seealso cref="Vector3"/> position in destination sim to teleport to</param> /// <param name="lookAt"><seealso cref="Vector3"/> direction in destination sim agent will look at</param> /// <returns>true on success, false on failure</returns> /// <remarks>This call is blocking</remarks> public bool Teleport(ulong regionHandle, Vector3 position, Vector3 lookAt) { if (Client.Network.CurrentSim == null || Client.Network.CurrentSim.Caps == null || !Client.Network.CurrentSim.Caps.IsEventQueueRunning) { // Wait a bit to see if the event queue comes online AutoResetEvent queueEvent = new AutoResetEvent(false); EventHandler<EventQueueRunningEventArgs> queueCallback = delegate(object sender, EventQueueRunningEventArgs e) { if (e.Simulator == Client.Network.CurrentSim) queueEvent.Set(); }; Client.Network.EventQueueRunning += queueCallback; queueEvent.WaitOne(10 * 1000, false); Client.Network.EventQueueRunning -= queueCallback; } teleportStat = TeleportStatus.None; teleportEvent.Reset(); RequestTeleport(regionHandle, position, lookAt); teleportEvent.WaitOne(Client.Settings.TELEPORT_TIMEOUT, false); if (teleportStat == TeleportStatus.None || teleportStat == TeleportStatus.Start || teleportStat == TeleportStatus.Progress) { teleportMessage = "Teleport timed out."; teleportStat = TeleportStatus.Failed; } return (teleportStat == TeleportStatus.Finished); }
/// <summary> /// Teleport agent to another region /// </summary> /// <param name="regionHandle">handle of region to teleport agent to</param> /// <param name="position"><seealso cref="libsecondlife.LLVector3"/> position in destination sim to teleport to</param> /// <param name="lookAt"><seealso cref="libsecondlife.LLVector3"/> direction in destination sim agent will look at</param> /// <returns>true on success, false on failure</returns> /// <remarks>This call is blocking</remarks> public bool Teleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt) { teleportStat = TeleportStatus.None; teleportEvent.Reset(); RequestTeleport(regionHandle, position, lookAt); teleportEvent.WaitOne(Client.Settings.TELEPORT_TIMEOUT, false); if (teleportStat == TeleportStatus.None || teleportStat == TeleportStatus.Start || teleportStat == TeleportStatus.Progress) { teleportMessage = "Teleport timed out."; teleportStat = TeleportStatus.Failed; } return (teleportStat == TeleportStatus.Finished); }
public TeleportEventArgs(int unitNetworkId, TeleportStatus status, TeleportType type) { _unitNetworkId = unitNetworkId; _status = status; _type = type; }
public TeleportStatusEventArgs(string message, TeleportStatus status, TeleportFlags flags) { this.message = message; this.status = status; this.flags = flags; }
/// <summary> /// Attempt to look up a simulator name and teleport to the discovered /// destination /// </summary> /// <param name="simName">Region name to look up</param> /// <param name="position">Position to teleport to</param> /// <param name="lookAt">Target to look at</param> /// <returns>True if the lookup and teleport were successful, otherwise /// false</returns> public bool Teleport(string simName, Vector3 position, Vector3 lookAt) { if (Client.Network.CurrentSim == null) return false; teleportStat = TeleportStatus.None; if (simName != Client.Network.CurrentSim.Name) { // Teleporting to a foreign sim GridRegion region; if (Client.Grid.GetGridRegion(simName, GridLayerType.Objects, out region)) { return Teleport(region.RegionHandle, position, lookAt); } else { teleportMessage = "Unable to resolve name: " + simName; teleportStat = TeleportStatus.Failed; return false; } } else { // Teleporting to the sim we're already in return Teleport(Client.Network.CurrentSim.Handle, position, lookAt); } }
/// <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; } }
/// <summary> /// Request teleport to a another simulator /// </summary> /// <param name="regionHandle">handle of region to teleport agent to</param> /// <param name="position"><seealso cref="Vector3"/> position in destination sim to teleport to</param> /// <param name="lookAt"><seealso cref="Vector3"/> direction in destination sim agent will look at</param> public void RequestTeleport(ulong regionHandle, Vector3 position, Vector3 lookAt) { if (Client.Network.CurrentSim != null && Client.Network.CurrentSim.Caps != null && Client.Network.CurrentSim.Caps.IsEventQueueRunning) { TeleportLocationRequestPacket teleport = new TeleportLocationRequestPacket(); teleport.AgentData.AgentID = Client.Self.AgentID; teleport.AgentData.SessionID = Client.Self.SessionID; teleport.Info.LookAt = lookAt; teleport.Info.Position = position; teleport.Info.RegionHandle = regionHandle; Logger.Log("Requesting teleport to region handle " + regionHandle.ToString(), Helpers.LogLevel.Info, Client); Client.Network.SendPacket(teleport); } else { teleportMessage = "CAPS event queue is not running"; teleportEvent.Set(); teleportStat = TeleportStatus.Failed; } }
/// <summary> /// /// </summary> /// <param name="regionHandle"></param> /// <param name="position"></param> /// <param name="lookAt"></param> /// <returns></returns> public bool Teleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt) { TeleportStat = TeleportStatus.None; 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); // Start the timeout check TeleportTimeout = false; TeleportTimer.Start(); Client.Network.SendPacket(teleport); while (TeleportStat != TeleportStatus.Failed && TeleportStat != TeleportStatus.Finished && !TeleportTimeout) { Client.Tick(); } TeleportTimer.Stop(); if (TeleportTimeout) { TeleportMessage = "Teleport timed out."; TeleportStat = TeleportStatus.Failed; if (OnTeleport != null) { OnTeleport(TeleportMessage, TeleportStat); } } else { if (OnTeleport != null) { OnTeleport(TeleportMessage, TeleportStat); } } return (TeleportStat == TeleportStatus.Finished); }
public TeleportEventArgs(string message, TeleportStatus status, TeleportFlags flags) { this.m_Message = message; this.m_Status = status; this.m_Flags = flags; }
/// <summary> /// Attempt to look up a simulator name and teleport to the discovered /// destination /// </summary> /// <param name="simName">Region name to look up</param> /// <param name="position">Position to teleport to</param> /// <param name="lookAt">Target to look at</param> /// <returns>True if the lookup and teleport were successful, otherwise /// false</returns> public bool Teleport(string simName, LLVector3 position, LLVector3 lookAt) { TeleportStat = TeleportStatus.None; simName = simName.ToLower(); if (simName != Client.Network.CurrentSim.Name.ToLower()) { // Teleporting to a foreign sim GridRegion region; if (Client.Grid.GetGridRegion(simName, out region)) { return Teleport(region.RegionHandle, position, lookAt); } else { teleportMessage = "Unable to resolve name: " + simName; TeleportStat = TeleportStatus.Failed; return false; } } else { // Teleporting to the sim we're already in return Teleport(Client.Network.CurrentSim.Handle, position, lookAt); } }