예제 #1
0
        public MyNavigationPrimitive FindClosestPrimitive(Vector3D point, bool highLevel, ref double closestDistSq, MyCubeGrid grid = null)
        {
            if (highLevel)
            {
                return(null);
            }
            MyNavigationPrimitive primitive = null;

            if (grid != null)
            {
                MyGridNavigationMesh mesh = null;
                if (this.m_navigationMeshes.TryGetValue(grid, out mesh))
                {
                    primitive = mesh.FindClosestPrimitive(point, highLevel, ref closestDistSq);
                }
            }
            else
            {
                foreach (KeyValuePair <MyCubeGrid, MyGridNavigationMesh> pair in this.m_navigationMeshes)
                {
                    MyNavigationPrimitive primitive2 = pair.Value.FindClosestPrimitive(point, highLevel, ref closestDistSq);
                    if (primitive2 != null)
                    {
                        primitive = primitive2;
                    }
                }
            }
            return(primitive);
        }
예제 #2
0
        public MyNavigationPrimitive FindClosestPrimitive(Vector3D point, bool highLevel, ref double closestDistSq, MyCubeGrid grid = null)
        {
            if (highLevel == true)
            {
                return(null);
            }

            MyNavigationPrimitive retval = null;

            if (grid != null)
            {
                MyGridNavigationMesh mesh = null;
                if (m_navigationMeshes.TryGetValue(grid, out mesh))
                {
                    retval = mesh.FindClosestPrimitive(point, highLevel, ref closestDistSq);
                }
            }
            else
            {
                foreach (var entry in m_navigationMeshes)
                {
                    MyNavigationPrimitive closest = entry.Value.FindClosestPrimitive(point, highLevel, ref closestDistSq);
                    if (closest != null)
                    {
                        retval = closest;
                    }
                }
            }

            return(retval);
        }