#ifndef MSOLAR_PANEL_HPP_
#define MSOLAR_PANEL_HPP_

#include <bitset>
#include <Machine/Machine.hpp>
#include <Machine/IFluidMachine.hpp>
#include <Machine/IElectricMachine.hpp>
#include <Side/Side.hpp>

class MSolarPanel final :
    public Machine,
    public IElectricMachine
{
private:
    static constexpr int sunlightCheckHeight = 128;

    float bufferedEnergy = 0.0f;
    bool chunkMonitoringDone = false;
    std::bitset<sunlightCheckHeight> blockCovering;

public:
    MSolarPanel(LocalWorld &world, glm::ivec3 pos);

    virtual void serializeState(std::vector<uint8_t> &outBytes) override;
    virtual void deserializeState(const uint8_t *data, size_t size) override;
    virtual void update() override;
    virtual bool canConnectElectricWire(Side side) override;
    virtual bool canDrainEnergyFromSide(Side side) override;
    virtual void onEnergyDrained(int amount) override;
};

#endif