All pastes #405462 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-21 19:27 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using LavishVMAPI; 

namespace Bytebot
{
    public class Navigator
    {
        const int FacePrecision = 15;
        const int DirectMoveRange = 40;

        private Thread _thread;
        private LavishScriptAPI.Point3f _finaldestination;
        private LavishScriptAPI.Point3f _currentdestination;
        private LavishScriptAPI.Point3f _startlocation;

        #region Constructor
        public Navigator()
        {
            _thread = new Thread(new ThreadStart(Worker));
            _thread.Name = "Navigator";
            _thread.IsBackground = true;
            _thread.Start();
        }
        #endregion

        #region Worker
        private static void Worker()
        {
            do
            {
                Thread.Sleep(50);
            }
            while (true);
        }
        #endregion

        #region Public methods
        public void Face(double X, double Y, bool Exact)
        {
            double Heading = 180;
            double HeadingTo = 0;

            if (!Exact)
            {
                Frame.Lock();
                Heading = Bytebot.Global.WoW.Me.Heading;
                HeadingTo = Bytebot.Global.WoW.Me.HeadingTo(X, Y);
                Frame.Unlock();
            }

            if (Math.Abs(Heading-HeadingTo) > FacePrecision)
            {
                Bytebot.Global.WoW.Face(X, Y);
            }
        }

        public void Face(double X, double Y)
        {
            Face(X,Y);
        }

        public void Face(LavishScriptAPI.Point3f Point)
        {
            Face(Point.X, Point.Y, false);
        }

        public void MoveTo(double X, double Y, double Z)
        {
            _finaldestination.X = X;
            _finaldestination.Y = Y;
            _finaldestination.Z = Z;

            _currentdestination.X = X;
            _currentdestination.Y = Y;
            _currentdestination.Z = Z;

            _startlocation = Bytebot.Global.WoW.Me.Location;

            
            if ((Bytebot.Global.Distance(_startlocation, _finaldestination) < DirectMoveRange) && !Bytebot.Global.WoW.Me.IsPathObstructed(_finaldestination.X,_finaldestination.Y,_finaldestination.Z,DirectMoveRange))
            {
            }
            else
            {
            }
        }

        public void MoveTo(LavishScriptAPI.Point3f Point)
        {
            MoveTo(Point.X, Point.Y, Point.Z);
        }

        #endregion
    }
}