Esempio n. 1
0
        private bool PlayPath(string pathName, Pathing pType, bool forawrd, int index, SelfModify callback = null)
        {
            if (!_mut.WaitOne(1000))
            {
                Console.WriteLine("Asynchronous action taken on synchronic function.");
                return true;
            }

            var zoneId = Funcs.GetZoneId();
            HaltFlag = false;
            float heading;
            float tobeHeading;
            var count = 0;
            var rebuiltPath =
                RebuildList(_Waypoints.Zone.First(p => p.ID == zoneId).Path.First(i => i.Name == pathName).Point,
                    forawrd, pType, index);
            foreach (
                var waypoint in rebuiltPath)
            {
                if (callback != null)
                    callback(pathName, waypoint, forawrd);

                if (CorDelay)
                    Bolter.GlobalInterface.GlobalMovement.Status = WalkingStatus.Standing;

                RotateCharacter(waypoint);

                if (CamReset)
                    Bolter.GlobalInterface.GlobalInput.SendKeyPress(KeyStates.Toggled, Key.End);

                if (CorDelay)
                    Thread.Sleep(HeadToll);

                var decX = (Funcs.GetPOS(EntityType.PCMob, Axis.X, 0) > waypoint.x);

                var ttl = (long)(1000f * (Distance(Funcs.Get2DPos(), waypoint) / Bolter.GlobalInterface.GlobalMovement.ForwardSpeed));

                Bolter.GlobalInterface.GlobalMovement.Status = WalkingStatus.Autorun | WalkingStatus.Running;
                var timer = new Stopwatch();
                timer.Start();
                if (decX)
                {
                    while (Funcs.GetPOS(EntityType.PCMob, Axis.X, 0) > waypoint.x)
                    {
                        if (HaltFlag)
                        {
                            Bolter.GlobalInterface.GlobalMovement.Status = WalkingStatus.Standing;
                            timer.Stop();
                            goto CleanUpTrue;
                        }
                        if (AICorrection)
                        {
                            heading = Funcs.GetHeading(EntityType.PCMob, 0);

                            tobeHeading = HeadingToRad(Funcs.GetPOS(EntityType.PCMob, Axis.X, 0), Funcs.GetPOS(EntityType.PCMob, Axis.Y, 0), waypoint);

                            // Check if our heading is within our tolerance.
                            if (tobeHeading - heading < 0 ? tobeHeading - heading < -0.1f : tobeHeading - heading > 0.1f)
                                RotateCharacter(waypoint);
                        }
                        Thread.Sleep(10);
                        if (timer.ElapsedMilliseconds <= ttl + JumpTolerance) continue;
                        if (waypoint.Jump == false) continue;
                        if ((waypoint.Direction == PointDirection.Forward && forawrd) || (waypoint.Direction == PointDirection.Back && !forawrd) || (waypoint.Direction == PointDirection.Both))
                            Bolter.GlobalInterface.GlobalInput.SendKeyPress(KeyStates.Toggled, Key.Space);
                    }
                }
                else
                {
                    while (Funcs.GetPOS(EntityType.PCMob, Axis.X, 0) < waypoint.x)
                    {
                        if (HaltFlag)
                        {
                            Bolter.GlobalInterface.GlobalMovement.Status = WalkingStatus.Standing;
                            timer.Stop();
                            goto CleanUpTrue;
                        }
                        if (AICorrection)
                        {
                            heading = Funcs.GetHeading(EntityType.PCMob, 0);
                            tobeHeading = HeadingToRad(Funcs.GetPOS(EntityType.PCMob, Axis.X, 0), Funcs.GetPOS(EntityType.PCMob, Axis.Y, 0), waypoint);

                            // Check if our heading is within our tolerance.
                            if (tobeHeading - heading < 0 ? tobeHeading - heading < -0.1f : tobeHeading - heading > 0.1f)
                                RotateCharacter(waypoint);
                        }
                        Thread.Sleep(10);
                        if (timer.ElapsedMilliseconds <= ttl + JumpTolerance) continue;
                        if (waypoint.Jump == false) continue;
                        if ((waypoint.Direction == PointDirection.Forward && forawrd) || (waypoint.Direction == PointDirection.Back && !forawrd) || (waypoint.Direction == PointDirection.Both))
                            Bolter.GlobalInterface.GlobalInput.SendKeyPress(KeyStates.Toggled, Key.Space);
                    }
                }
                count++;
                timer.Stop();
            }
            Bolter.GlobalInterface.GlobalMovement.Status = WalkingStatus.Standing;
            _mut.ReleaseMutex();
            return false;
            CleanUpTrue:
            _mut.ReleaseMutex();
            return true;
        }
Esempio n. 2
0
 /// <summary>   Plays the given file. </summary>
 ///
 ///
 /// <param name="pathName" type="string">       Full pathname of the file. </param>
 /// <param name="pType" type="Pathing">         The type. </param>
 /// <param name="forward" type="bool">          (Optional) true to forward. </param>
 /// <param name="index" type="int">             (Optional) zero-based index of the. </param>
 /// <param name="callback" type="SelfModify">   (Optional) the callback. </param>
 public void Play(string pathName, Pathing pType, bool forward = true, int index = 0, SelfModify callback = null)
 {
     new Thread(() =>
     {
         var halted = PlayPath(pathName, pType, forward, index, callback);
         if (PathComplete != null)
             PathComplete(Thread.CurrentThread, halted, pathName, pType, forward, index);
     }).Start();
 }