コード例 #1
0
ファイル: Pather.cs プロジェクト: zneel/TheNoobBot
        public Point GetClosestPointOnTile(Point position, out bool success)
        {
            lock (_threadLocker)
            {
                float[] extents = new Point(20.0f, 2000.0f, 20.0f).ToFloatArray();
                float[] center  = position.ToRecast().ToFloatArray();

                float tx, ty;
                GetTileByLocation(position, out tx, out ty);
                int x = (int)Math.Floor(tx);
                int y = (int)Math.Floor(ty);
                LoadTile(x, y);

                dtPolyRef startRef = _query.FindNearestPolygon(center, extents, Filter);
                if (startRef == 0)
                {
                    success = false;
                    return(new Point());
                }
                float[]      result;
                DetourStatus status = _query.closestPointOnPolyBoundary(startRef, center, out result);
                if (status.HasFailed())
                {
                    success = false;
                    return(new Point());
                }
                success = true;
                return(new Point(result.ToWoW()));
            }
        }
コード例 #2
0
ファイル: Pather.cs プロジェクト: zneel/TheNoobBot
        public float GetZ(Point position, bool strict = false)
        {
            lock (_threadLocker)
            {
                float[] extents = strict ? new Point(0.5f, 2000.0f, 0.5f).ToFloatArray() : new Point(1.5f, 2000.0f, 1.5f).ToFloatArray();
                float[] center  = position.ToRecast().ToFloatArray();

                float tx, ty;
                GetTileByLocation(position, out tx, out ty);
                int x = (int)Math.Floor(tx);
                int y = (int)Math.Floor(ty);
                LoadTile(x, y);

                dtPolyRef startRef = _query.FindNearestPolygon(center, extents, Filter);
                if (startRef == 0)
                {
                    Logging.WriteDebug("There is no polygon in this location (Tile " + x + "," + y + "), coord: X:" +
                                       position.X + ", Y:" + position.Y);
                    return(0);
                }
                float z = _query.GetPolyHeight(startRef, center);
                if (z == 0 && !strict) // it failed but we are not strict, then search around
                {
                    float[]      result;
                    DetourStatus status = _query.closestPointOnPolyBoundary(startRef, center, out result);
                    z = status.HasFailed() ? 0 : result[1];
                }
                return(z);
            }
        }
コード例 #3
0
ファイル: Pather.cs プロジェクト: zneel/TheNoobBot
        public bool LoadTile(byte[] data)
        {
            lock (_threadLocker)
            {
                try
                {
                    if (CheckDungeon())
                    {
                        return(false);
                    }

                    MeshTile     tile;
                    DetourStatus ret = _mesh.AddTile(data, out tile);
                    if (ret.IsWrongVersion())
                    {
                        Logging.WriteNavigator("This mesh tile is outdated.");
                        return(false);
                    }
                    if (ret.HasFailed())
                    {
                        Logging.WriteNavigator("This mesh tile is corrupted.");
                        return(false);
                    }
                    AddMemoryPressure(data.LongLength);
                    // HandleConnections(tile);
                    return(true);
                }
                catch (Exception exception)
                {
                    Logging.WriteError("LoadTile(byte[] data): " + exception);
                    return(false);
                }
            }
        }