#ifndef MSTEAM_GENERATOR_HPP_
#define MSTEAM_GENERATOR_HPP_

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

class MSteamGenerator final :
    public Machine,
    public IInventory,
    public IFluidMachine,
    public IElectricMachine
{
private:
    std::vector<ItemStack> stacks;
    uint32_t temperature;
    uint32_t fuelCurrent;
    uint32_t fuelBatch;

    ItemStack& fuelSlot();
    ItemStack& waterSlot();
    ItemStack& rechargeSlot();
    Side getOutputSide();

public:
    static constexpr int waterCapacity = 20000;
    static constexpr int energyCapacity = 1000;

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

    /**
     * @brief Return the current temperature.
     */
    uint32_t getTemperature();

    /**
     * @brief Return the current water level (ml).
     */
    int getWaterLevel();

    /**
     * @brief Return the current remaining amount of fuel.
     */
    uint32_t getFuelCurrent();

    /**
     * @brief Return the amount of fuel in the current batch.
     */
    uint32_t getFuelBatch();

    /**
     * @brief Return the current amount of energy stored (J).
     */
    int getStoredEnergy();

    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 canConnectFluidPipe(Side side) override;
    virtual int getMaxFluidToAccept(std::optional<Side> side, std::string fluidName) override;

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

#endif
