コード例 #1
0
        /// <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;
        }
コード例 #2
0
 public void EndSearchForTeleport()
 {
     if (teleportStatus == TeleportStatus.Searching)
     {
         teleportStatus = TeleportStatus.StartTeleporting;
     }
 }
コード例 #3
0
ファイル: BaseUlt.cs プロジェクト: lightduy94/PortAIO-2
        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);
        }
コード例 #4
0
 public RecallInf(int netid, TeleportStatus stat, TeleportType tpe, int dura, int star = 0)
 {
     NetworkID = netid;
     Status    = stat;
     Type      = tpe;
     Duration  = dura;
     Start     = star;
 }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: Teleport.cs プロジェクト: ap0110/libsecondlife-svn
        private void Avatar_OnTeleportMessage(string message, TeleportStatus status)
        {
            Console.WriteLine(message);

            if (status == TeleportStatus.Finished || status == TeleportStatus.Failed)
            {
                DoneTeleporting = true;
            }
        }
コード例 #7
0
        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;
            }
            }
        }
コード例 #8
0
ファイル: BaseUlt.cs プロジェクト: lightduy94/PortAIO-2
 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>();
 }
コード例 #9
0
ファイル: Avatar.cs プロジェクト: ap0110/libsecondlife-svn
        /// <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);
        }
コード例 #10
0
        /// <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;
            }
        }
コード例 #11
0
ファイル: Avatar.cs プロジェクト: ap0110/libsecondlife-svn
        /// <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);
        }
コード例 #12
0
        /// <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;
            }
        }
コード例 #13
0
        /// <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;
        }
コード例 #14
0
ファイル: BaseUlt.cs プロジェクト: Xelamats/PortAIO
 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>();
 }
コード例 #15
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
        /// <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();
        }
コード例 #16
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
        /// <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);
        }
コード例 #17
0
ファイル: Avatar.cs プロジェクト: ap0110/libsecondlife-svn
        /// <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;
            }
        }
コード例 #18
0
ファイル: BaseUlt.cs プロジェクト: Xelamats/PortAIO
        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;
        }
コード例 #19
0
 public void StartSearchForTeleport()
 {
     cameraRig      = PuppetJumpManager.Instance.cameraRig;
     teleportStatus = TeleportStatus.Searching;
 }
コード例 #20
0
        private void Avatar_OnTeleportMessage(string message, TeleportStatus status)
        {
            Console.WriteLine(message);

            if (status == TeleportStatus.Finished || status == TeleportStatus.Failed)
            {
                DoneTeleporting = true;
            }
        }
コード例 #21
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
        /// <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();
        }
コード例 #22
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
        /// <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);
        }
コード例 #23
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
        /// <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);
        }
コード例 #24
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
        /// <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);
        }
コード例 #25
0
 public TeleportEventArgs(int unitNetworkId, TeleportStatus status, TeleportType type)
 {
     _unitNetworkId = unitNetworkId;
     _status        = status;
     _type          = type;
 }
コード例 #26
0
        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;
                    }
            }
        }
コード例 #27
0
 public TeleportStatusEventArgs(string message, TeleportStatus status, TeleportFlags flags)
 {
     this.message = message;
     this.status  = status;
     this.flags   = flags;
 }
コード例 #28
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
        /// <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);
            }
        }
コード例 #29
0
        /// <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;
            }
        }
コード例 #30
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
        /// <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;
            }
        }
コード例 #31
0
        /// <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);
        }
コード例 #32
0
ファイル: AgentManager.cs プロジェクト: RavenB/gridsearch
 public TeleportEventArgs(string message, TeleportStatus status, TeleportFlags flags)
 {
     this.m_Message = message;
     this.m_Status = status;
     this.m_Flags = flags;
 }
コード例 #33
0
ファイル: MainAvatar.cs プロジェクト: RavenB/gridsearch
        /// <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);
            }
        }