Esempio n. 1
0
        protected PathBuffer GetPathBuffer()
        {
            InitBufferMgr();
            PathBuffer ret = m_BufferMgr.GetObject();

            return(ret);
        }
Esempio n. 2
0
 private void ResetBuffer(PathBuffer buffer)
 {
     if (buffer != null)
     {
         buffer.SetDataCount(0);
     }
 }
Esempio n. 3
0
 public static void StopPathBuffer(PathBuffer buffer)
 {
     if (m_Map == null)
     {
         return;
     }
     m_Map.StorePathBuffer(buffer);
 }
Esempio n. 4
0
        private PathBuffer CreateBuffer()
        {
            PathBuffer buffer = new PathBuffer();

            uint[] buf = new uint[m_MaxPathBufferCount];
            buffer.Init(buf);
            return(buffer);
        }
Esempio n. 5
0
 protected void StorePathBuffer(PathBuffer buffer)
 {
     if (buffer == null)
     {
         return;
     }
     InitBufferMgr();
     m_BufferMgr.Store(buffer);
 }
Esempio n. 6
0
        public PathBuffer _FindPath(Vector3 start, Vector3 end, Vector3 extends, NavmeshQueryFilter filter = null)
        {
            var query = this.Query;

            if (query == null)
            {
                return(null);
            }
            if (filter == null)
            {
                filter = this.DefaultQueryFilter;
            }
            NavmeshPoint startPoint;
            var          status = query.GetNearestPoint(start, extends, filter, out startPoint);

            if (NavUtil.Failed(status))
            {
                return(null);
            }
            NavmeshPoint endPoint;

            status = query.GetNearestPoint(end, extends, filter, out endPoint);
            if (NavUtil.Failed(status))
            {
                return(null);
            }

            PathBuffer pathBuf = GetPathBuffer();

            if (pathBuf == null || pathBuf.Buffer == null)
            {
                return(null);
            }
            try
            {
                int dataCount;
                status = query.FindPath(ref startPoint, ref endPoint, extends, filter, pathBuf.Buffer, out dataCount);
                if (NavUtil.Failed(status))
                {
                    return(null);
                }

                pathBuf.SetDataCount(dataCount);

                return(pathBuf);
            } catch
            {
                StorePathBuffer(pathBuf);
            }
            return(null);
        }