Server.Mobiles.PlayerMobile.GetDirection4 C# (CSharp) Method

GetDirection4() public static method

public static GetDirection4 ( Point3D from, Point3D to ) : Direction
from Point3D
to Point3D
return Direction
        public static Direction GetDirection4(Point3D from, Point3D to)
        {
            int dx = from.X - to.X;
            int dy = from.Y - to.Y;

            int rx = dx - dy;
            int ry = dx + dy;

            Direction ret;

            if (rx >= 0 && ry >= 0)
                ret = Direction.West;
            else if (rx >= 0 && ry < 0)
                ret = Direction.South;
            else if (rx < 0 && ry < 0)
                ret = Direction.East;
            else
                ret = Direction.North;

            return ret;
        }