#ifndef PUMP_CONTROLLER_HPP_
#define PUMP_CONTROLLER_HPP_

#include <Controller/InventoryController/InventoryController.hpp>
#include <memory>
#include <Controller/Controller.hpp>
#include <Entity/PhysicsEntity/CameraEntity/Player/Player.hpp>
#include <Machine/MPump/MPump.hpp>

class PumpController final : public InventoryController
{
private:
    std::shared_ptr<MPump> pump;
    std::string bufferedFluidName;
    uint32_t pumpRate = 1000;
    uint32_t bufferedAmount = 0;
    bool isSwitchedOnPriv = false;
    std::optional<std::string> fluidFilter;

    Command<uint32_t, uint32_t> pumpManually;
    Command<uint32_t, std::string, uint32_t, uint32_t, bool, std::optional<std::string>> updatePumpState;
    Command<uint32_t, bool> setSwitch;
    Command<uint32_t, uint32_t> setPumpRate;
    Command<uint32_t, std::optional<std::string>> setFluidFilter;

    static constexpr uint32_t minPumpRate = 1;
    static constexpr uint32_t maxPumpRate = 1000;

public:
    PumpController(ControllerChannel &channel);

    void onConnect(std::shared_ptr<Machine> pumpMachine);

    virtual Widget* getRightPanel() override;
    virtual bool isBusy() override;
    virtual void update() override;
};

#endif