private void Update()
    {
        if (pendingUpdate)
        {
            GenerateMesh();
        }

        for (int i = 0; i < updateBlocks.Count; i++)
        {
            if (updateBlocks[i] != null)
            {
                if (updateBlocks[i] as Block_Liquid != null)
                {
                    Block_Liquid auxBlock = updateBlocks[i] as Block_Liquid;

                    if (auxBlock != null)
                    {
                        if (auxBlock.pendingUpdate)
                        {
                            auxBlock.UpdateBlock();
                        }
                    }
                }
            }
        }

        ViewChunkCorners();

        int aux = 0;

        for (int i = 0; i < 8; i++)
        {
            if (adjChunks[i])
            {
                aux++;
            }
        }

        if (adjLen != aux)
        {
            adjLen = aux;
        }
    }
Beispiel #2
0
    public override void Destroy()
    {
        // If block is NOT on the border of the chunk
        if (position.x > 0 && position.x < BlockChunk.depth - 1 && position.z > 0 && position.z < BlockChunk.width - 1)
        {
            Block_Liquid auxBlock = chunk.chunkData[position.x - 1, position.y, position.z] as Block_Liquid;

            if (auxBlock != null)
            {
                auxBlock.pendingUpdate = true;
            }

            auxBlock = chunk.chunkData[position.x + 1, position.y, position.z] as Block_Liquid;

            if (auxBlock != null)
            {
                auxBlock.pendingUpdate = true;
            }

            auxBlock = chunk.chunkData[position.x, position.y, position.z - 1] as Block_Liquid;

            if (auxBlock != null)
            {
                auxBlock.pendingUpdate = true;
            }

            auxBlock = chunk.chunkData[position.x, position.y, position.z + 1] as Block_Liquid;

            if (auxBlock != null)
            {
                auxBlock.pendingUpdate = true;
            }

            auxBlock = chunk.chunkData[position.x, position.y, position.z - 1] as Block_Liquid;

            if (auxBlock != null)
            {
                auxBlock.pendingUpdate = true;
            }
        }
    }