#ifndef MACCUMULATOR_HPP_
#define MACCUMULATOR_HPP_

#include <vector>

#include <Machine/Machine.hpp>
#include <ItemStack/ItemStack.hpp>
#include <Item/IInventory.hpp>
#include <Machine/IElectricMachine.hpp>

/**
 * @brief The accumulator machine.
 */
class MAccumulator :
    public Machine,
    public IInventory,
    public IElectricMachine
{
private:
    std::vector<ItemStack> stacks;

    ItemStack& inputSlot();
    ItemStack& outputSlot();

    Side getInputSide();

public:
    static constexpr int capacity = 100000;

    MAccumulator(LocalWorld &world, glm::ivec3 pos);

    /**
     * @brief Get the energy stored (J).
     */
    int getEnergy();

    virtual void serializeState(std::vector<uint8_t> &outBytes) override;
    virtual void deserializeState(const uint8_t *data, size_t size) override;
    virtual int getNumSlots() override;
    virtual ItemStack getStackInSlot(int slot) override;
    virtual void setStackInSlot(int slot, ItemStack stack) override;
    virtual bool isAllowedStackInSlot(int slot, ItemStack stack) override;
    
    virtual void update() override;

    virtual bool canConnectElectricWire(Side side) override;
    virtual bool canDrainEnergyFromSide(Side side) override;
};

#endif