#ifndef JETPACK_HPP_
#define JETPACK_HPP_

#include <Item/IEquipment.hpp>
#include <Item/IFluidContainingItem.hpp>
#include <Item/StatefulItem/StatefulItem.hpp>
#include <Serialize/Serialize.hpp>
#include <string>

struct JetpackState
{
    std::string fluidName;
    int amount = 0;

    inline bool operator==(const JetpackState &other) const
    {
        return fluidName == other.fluidName && other.amount == amount;
    }
};

DERIVE_STRUCT_SERIALIZER(JetpackState, self.fluidName, self.amount);

class Jetpack final :
    public StatefulItem<JetpackState>,
    public IFluidContainingItem,
    public IEquipment
{
private:
    bool canStoreFluid(const std::string &fluidName);

public:
    static constexpr int capacity = 10000;
    static constexpr float thrust = 0.013f;

    Jetpack(std::string name);

    virtual int getFluidAmount(const ItemStack &stack) override;
    virtual void draw(GraphicsContext &context, int x, int y, const ItemStack &stack) override;
    virtual std::string getDisplayName(const ItemStack &stack) override;
    virtual void draw3D(GraphicsContext &context, WorldDisplay &worldDisplay, glm::vec3 pos, ItemStack &stack) override;
    virtual void drawFlat(GraphicsContext &context, WorldDisplay &worldDisplay, glm::mat4 matrix, ItemStack &stack) override;
    virtual void getExtraToolTipLines(const ItemStack &stack, ToolTip &tip) override;
    virtual bool canMerge(const ItemStack &a, const ItemStack &b) override;
    virtual std::string getFluidName(const ItemStack &stack) override;
    virtual int pullFluid(ItemStack &stack, std::string fluidName, int maxToPull) override;
    virtual int pushFluid(ItemStack &stack, std::string fluidName, int amount) override;
    virtual float generateThrust(ItemStack &stack) override;
    virtual void onPlayerUpdating(Player &player, ItemStack &stack) override;
    virtual std::string getGadgetControllerID() override;
    virtual void getCheatStacks(ItemStack &baseStack, std::vector<ItemStack> &outStacks) override;
    virtual void onEquippedBy(Player &player, const ItemStack &stack) override;
};

#endif