Exemplo n.º 1
0
        private static int GetHeighestSurrounding(int x, int z, ChunkColumn chunk, IBlockAccess level)
        {
            int h = chunk.GetHeight(x, z);

            if (h == 255)
            {
                return(h);
            }

            if (x == 0 || x == 15 || z == 0 || z == 15)
            {
                var coords = new BlockCoordinates(x + (chunk.X * 16), h, z + (chunk.Z * 16));

                //h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.Up));
                h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.West));
                h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.East));
                h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.North));
                h = Math.Max(h, level.GetHeight(coords + BlockCoordinates.South));
                if (h > 255)
                {
                    h = 255;
                }
                if (h < 0)
                {
                    h = 0;
                }
                return(h);
            }

            //if (z < 15) h = Math.Max(h, chunk.GetHeight(x, z + 1));
            //if (z > 0) h = Math.Max(h, chunk.GetHeight(x, z - 1));
            //if (x < 15) h = Math.Max(h, chunk.GetHeight(x + 1, z));
            //if (x < 15 && z > 0) h = Math.Max(h, chunk.GetHeight(x + 1, z - 1));
            //if (x < 15 && z < 15) h = Math.Max(h, chunk.GetHeight(x + 1, z + 1));
            //if (x > 0) h = Math.Max(h, chunk.GetHeight(x - 1, z));
            //if (x > 0 && z > 0) h = Math.Max(h, chunk.GetHeight(x - 1, z - 1));
            //if (x > 0 && z < 15) h = Math.Max(h, chunk.GetHeight(x - 1, z + 1));

            h = Math.Max(h, chunk.GetHeight(x, z + 1));
            h = Math.Max(h, chunk.GetHeight(x, z - 1));
            h = Math.Max(h, chunk.GetHeight(x + 1, z));
            //h = Math.Max(h, chunk.GetHeight(x + 1, z - 1));
            //h = Math.Max(h, chunk.GetHeight(x + 1, z + 1));
            h = Math.Max(h, chunk.GetHeight(x - 1, z));
            //h = Math.Max(h, chunk.GetHeight(x - 1, z - 1));
            //h = Math.Max(h, chunk.GetHeight(x - 1, z + 1));

            return(h);
        }
Exemplo n.º 2
0
        public static int GetHeight(BlockCoordinates blockCoordinates, ChunkColumn chunk)
        {
            if (chunk == null)
            {
                return(256);
            }

            return(chunk.GetHeight(blockCoordinates.X & 0x0f, blockCoordinates.Z & 0x0f));
        }