#pragma once

#include <Image.h>

#pragma pack(push, 1)

// stores the color aof the map at a specific height
struct MapBlock
{
    unsigned char height;
    int color;
};

// stores the colors at all heights of a specific x and y position on the map.
// there can by only 256 colors stored per position
struct MapPixel
{
    unsigned char len;
    MapBlock* blocks;
};

#pragma pack(pop)

class ChunkMap : public Framework::ReferenceCounter
{
private:
    MapPixel* pixels;
    unsigned char* heightMap;
    Framework::Point chunkCenter;
    Framework::Image rendered;
    unsigned char maxHeight;
    
public:
    ChunkMap(Framework::StreamReader* zReader);
    ChunkMap(Framework::Point center);
    ~ChunkMap();
    
    void setMaxHeight(unsigned char maxHeight);
    
    const Framework::Image &getRenderedImage() const;
    unsigned char* getHeightMap() const;
    Framework::Point getChunkCenter() const;
};