public void DrawMovingBlockSet(Camera camera, MovingBlockSet movingBlockSet)
 {
     if (m_vertices.Count <= 20000 && camera.ViewFrustum.Intersection(movingBlockSet.BoundingBox(extendToFillCells: false)))
     {
         GenerateGeometry(movingBlockSet);
         int      count = m_vertices.Count;
         ushort[] array = movingBlockSet.Indices.Array;
         _ = movingBlockSet.Indices.Count;
         Vector3         vector = movingBlockSet.Position + movingBlockSet.GeometryOffset;
         TerrainVertex[] array2 = movingBlockSet.Vertices.Array;
         int             count2 = movingBlockSet.Vertices.Count;
         for (int i = 0; i < count2; i++)
         {
             TerrainVertex item = array2[i];
             item.X += vector.X;
             item.Y += vector.Y;
             item.Z += vector.Z;
             m_vertices.Add(item);
         }
         for (int j = 0; j < movingBlockSet.Indices.Count; j++)
         {
             m_indices.Add((ushort)(array[j] + count));
         }
     }
 }
        public void Draw(Camera camera, int drawOrder)
        {
            if (!m_componentMiner.DigCellFace.HasValue || !(m_componentMiner.DigProgress > 0f) || !(m_componentMiner.DigTime > 0.2f))
            {
                return;
            }
            Point3 point     = m_componentMiner.DigCellFace.Value.Point;
            int    cellValue = m_subsystemTerrain.Terrain.GetCellValue(point.X, point.Y, point.Z);
            int    num       = Terrain.ExtractContents(cellValue);
            Block  block     = BlocksManager.Blocks[num];

            if (m_geometry == null || cellValue != m_value || point != m_point)
            {
                m_geometry = new Geometry();
                block.GenerateTerrainVertices(m_subsystemTerrain.BlockGeometryGenerator, m_geometry, cellValue, point.X, point.Y, point.Z);
                m_point = point;
                m_value = cellValue;
                m_vertices.Clear();
                CracksVertex item = default(CracksVertex);
                for (int i = 0; i < m_geometry.SubsetOpaque.Vertices.Count; i++)
                {
                    TerrainVertex terrainVertex = m_geometry.SubsetOpaque.Vertices.Array[i];
                    byte          b             = (byte)((terrainVertex.Color.R + terrainVertex.Color.G + terrainVertex.Color.B) / 3);
                    item.X     = terrainVertex.X;
                    item.Y     = terrainVertex.Y;
                    item.Z     = terrainVertex.Z;
                    item.Tx    = (float)terrainVertex.Tx / 32767f * 16f;
                    item.Ty    = (float)terrainVertex.Ty / 32767f * 16f;
                    item.Color = new Color(b, b, b, (byte)128);
                    m_vertices.Add(item);
                }
            }
            Vector3 viewPosition          = camera.ViewPosition;
            Vector3 v                     = new Vector3(MathUtils.Floor(viewPosition.X), 0f, MathUtils.Floor(viewPosition.Z));
            Matrix  value                 = Matrix.CreateTranslation(v - viewPosition) * camera.ViewMatrix.OrientationMatrix * camera.ProjectionMatrix;
            DynamicArray <ushort> indices = m_geometry.SubsetOpaque.Indices;
            float x    = m_subsystemSky.ViewFogRange.X;
            float y    = m_subsystemSky.ViewFogRange.Y;
            int   num2 = MathUtils.Clamp((int)(m_componentMiner.DigProgress * 8f), 0, 7);

            Display.BlendState        = BlendState.NonPremultiplied;
            Display.DepthStencilState = DepthStencilState.Default;
            Display.RasterizerState   = RasterizerState.CullCounterClockwiseScissor;
            m_shader.GetParameter("u_origin").SetValue(v.XZ);
            m_shader.GetParameter("u_viewProjectionMatrix").SetValue(value);
            m_shader.GetParameter("u_viewPosition").SetValue(camera.ViewPosition);
            m_shader.GetParameter("u_texture").SetValue(m_textures[num2]);
            m_shader.GetParameter("u_samplerState").SetValue(SamplerState.PointWrap);
            m_shader.GetParameter("u_fogColor").SetValue(new Vector3(m_subsystemSky.ViewFogColor));
            m_shader.GetParameter("u_fogStartInvLength").SetValue(new Vector2(x, 1f / (y - x)));
            Display.DrawUserIndexed(PrimitiveType.TriangleList, m_shader, CracksVertex.VertexDeclaration, m_vertices.Array, 0, m_vertices.Count, indices.Array, 0, indices.Count);
        }