#ifndef ITEM_EXTRACTOR_HPP_
#define ITEM_EXTRACTOR_HPP_

#include <Block/SpriteBlock/SpriteBlock.hpp>
#include <Machine/MItemExtractor/MItemExtractor.hpp>
#include <Block/MachineBlockMixin.hpp>

class ItemExtractor :
    public SpriteBlock,
    public MachineBlockMixin<MItemExtractor>
{
private:
    static std::vector<Sprite> makeSprites();

public:
    /*

        #         Item Extractor Meta Byte
        +-------+---+---+---+---+---+---+---+---+
        | Bit   | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
        +-------+---+---+---+---+---+---+---+---+
        | Field |   |   |   |   |   | A | output|
        +-------+---+---+---+---+---+---+---+---+

        output
            The output side (only the X and Y axis allowed).
        
        A
            If set, it means the extractor is active (motor is running).
    */

    static constexpr Side getMetaOutputSide(uint8_t meta)
    {
        return Side(meta & 3);
    }

    static constexpr uint8_t metaActive = 1 << 2;
    static constexpr uint8_t numStates = 1 << 3;

    ItemExtractor(std::string name);

    virtual bool canManuallyDig() override;
    virtual Sound& getBackgroundSound(uint8_t meta) override;
    virtual bool canPlace(LocalWorld &world, IWorldActor &actor, glm::ivec3 pos, Side side, uint8_t &meta) override;
    virtual void onInteract(LocalWorld &world, Player &player, glm::ivec3 pos, Side side, const RGBABytes &collisionKey) override;
};

#endif