public void GenerateGeometry(MovingBlockSet movingBlockSet)
        {
            Point3 point = default(Point3);

            point.X = ((movingBlockSet.CurrentVelocity.X > 0f) ? ((int)MathUtils.Floor(movingBlockSet.Position.X)) : (point.X = (int)MathUtils.Ceiling(movingBlockSet.Position.X)));
            point.Y = ((movingBlockSet.CurrentVelocity.Y > 0f) ? ((int)MathUtils.Floor(movingBlockSet.Position.Y)) : (point.Y = (int)MathUtils.Ceiling(movingBlockSet.Position.Y)));
            point.Z = ((movingBlockSet.CurrentVelocity.Z > 0f) ? ((int)MathUtils.Floor(movingBlockSet.Position.Z)) : (point.Z = (int)MathUtils.Ceiling(movingBlockSet.Position.Z)));
            if (!(point != movingBlockSet.GeometryGenerationPosition))
            {
                return;
            }
            Point3 p      = new Point3(movingBlockSet.Box.Left, movingBlockSet.Box.Top, movingBlockSet.Box.Near);
            Point3 point2 = new Point3(movingBlockSet.Box.Width, movingBlockSet.Box.Height, movingBlockSet.Box.Depth);

            point2.Y = MathUtils.Min(point2.Y, 254);
            if (m_blockGeometryGenerator == null)
            {
                int x = 2;
                x = (int)MathUtils.NextPowerOf2((uint)x);
                m_blockGeometryGenerator = new BlockGeometryGenerator(new Terrain(), m_subsystemTerrain, null, base.Project.FindSubsystem <SubsystemFurnitureBlockBehavior>(throwOnError: true), null, base.Project.FindSubsystem <SubsystemPalette>(throwOnError: true));
                for (int i = 0; i < x; i++)
                {
                    for (int j = 0; j < x; j++)
                    {
                        m_blockGeometryGenerator.Terrain.AllocateChunk(i, j);
                    }
                }
            }
            Terrain terrain = m_subsystemTerrain.Terrain;

            for (int k = 0; k < point2.X + 2; k++)
            {
                for (int l = 0; l < point2.Z + 2; l++)
                {
                    int x2         = k + p.X + point.X - 1;
                    int z          = l + p.Z + point.Z - 1;
                    int shaftValue = terrain.GetShaftValue(x2, z);
                    m_blockGeometryGenerator.Terrain.SetTemperature(k, l, Terrain.ExtractTemperature(shaftValue));
                    m_blockGeometryGenerator.Terrain.SetHumidity(k, l, Terrain.ExtractHumidity(shaftValue));
                    for (int m = 0; m < point2.Y + 2; m++)
                    {
                        int y     = m + p.Y + point.Y - 1;
                        int light = Terrain.ExtractLight(terrain.GetCellValue(x2, y, z));
                        m_blockGeometryGenerator.Terrain.SetCellValueFast(k, m, l, Terrain.MakeBlockValue(0, light, 0));
                    }
                }
            }
            m_blockGeometryGenerator.Terrain.SeasonTemperature = terrain.SeasonTemperature;
            m_blockGeometryGenerator.Terrain.SeasonHumidity    = terrain.SeasonHumidity;
            foreach (MovingBlock block in movingBlockSet.Blocks)
            {
                int x3    = block.Offset.X - p.X + 1;
                int y2    = block.Offset.Y - p.Y + 1;
                int z2    = block.Offset.Z - p.Z + 1;
                int value = Terrain.ReplaceLight(light: m_blockGeometryGenerator.Terrain.GetCellLightFast(x3, y2, z2), value: block.Value);
                m_blockGeometryGenerator.Terrain.SetCellValueFast(x3, y2, z2, value);
            }
            m_blockGeometryGenerator.ResetCache();
            movingBlockSet.Vertices.Clear();
            movingBlockSet.Indices.Clear();
            for (int n = 1; n < point2.X + 1; n++)
            {
                for (int num = 1; num < point2.Y + 1; num++)
                {
                    for (int num2 = 1; num2 < point2.Z + 1; num2++)
                    {
                        int cellValueFast = m_blockGeometryGenerator.Terrain.GetCellValueFast(n, num, num2);
                        int num3          = Terrain.ExtractContents(cellValueFast);
                        if (num3 != 0)
                        {
                            BlocksManager.Blocks[num3].GenerateTerrainVertices(m_blockGeometryGenerator, movingBlockSet.Geometry, cellValueFast, n, num, num2);
                        }
                    }
                }
            }
            movingBlockSet.GeometryOffset             = new Vector3(p) - new Vector3(1f);
            movingBlockSet.GeometryGenerationPosition = point;
        }