Beispiel #1
0
    private static bool TreeBlocked(int x, int y, int z, int h, TerrainGenerator t)
    {
        // Surrounding blocks
        int[] patternX = new int[] { -1, -1, -1, 0, 1, 1, 1, 0 };
        int[] patternZ = new int[] { -1, 0, 1, 1, 1, 0, -1, -1 };

        for (int i = 1; i < h + 2; i++)
        {
            // If wood is blocked
            if (!t.AllowOverwrite(t.terrainEngine.WorldGetBlock(x, y + i, z)))
            {
                return(true);
            }

            // Don't check surroundings for the first wood block
            if (i == 1)
            {
                continue;
            }

            // If surrounding blocks are blocked
            for (int j = 0; j < 8; j++)
            {
                if (!t.AllowOverwrite(t.terrainEngine.WorldGetBlock(x + patternX[j], y + i, z + patternZ[j])))
                {
                    return(true);
                }
            }
        }

        // All clear
        return(false);
    }