#ifndef CHUNK_H__
#define CHUNK_H__
#include "array3d.h"
#include "vertexbuffer.h"
#include "blockinfo.h"
#include "perlin.h"
#include <iostream>

class Chunk
{
    public:
    Chunk();
    Chunk(float x, float z);
    ~Chunk();

    void RemoveBlock(int x, int y, int z);
    void SetBlock(int x, int y, int z, BlockType type);
    BlockType GetBlock(int x, int y, int z);
    void Update(BlockInfo bi[BTYPE_LAST]);
    void AddBlockToMesh(VertexBuffer::VertexData* vd, int& count, BlockType bt, int x, int y, int z, BlockInfo bi[BTYPE_LAST]);
    void Render() const;
    bool IsDirty() const;

    private:
    Array3d<BlockType> m_blocks;
    VertexBuffer m_vertexBuffer;
    bool m_isDirty;
    float m_posx;
    float m_posz;
    float m_posy = -10;
};

#endif // CHUNK_H__