#include <Decoration/OilReservoir/OilReservoir.hpp>

OilReservoir::OilReservoir(int groundID) : groundID(groundID) {}

void OilReservoir::build(ISculptor &sculptor, GeneratorNode node, glm::ivec3 pos)
{
    glm::ivec3 offset;
    for (offset.z = -reservoirDepth; offset.z < 0; offset.z++)
    {
        for (offset.y = -1; offset.y < reservoirWidth + 1; offset.y++)
        {
            for (offset.x = -1; offset.x < reservoirWidth + 1; offset.x++)
            {
                sculptor.place(pos + offset, "main:sand");
            }
        }

        if (offset.z != -reservoirDepth)
        {
            for (offset.y = 0; offset.y < reservoirWidth; offset.y++)
            {
                for (offset.x = 0; offset.x < reservoirWidth; offset.x++)
                {
                    sculptor.place(pos + offset, "main:oilBlock", 0xFF);
                }
            }
        }
    }
}

double OilReservoir::getAverageDensity(const TerrainGenerator::Cell &cell, GeneratorNode node)
{
    if (cell.topID != groundID)
    {
        return 0.0;
    }

    return 0.2;
}