#ifndef BLOCK_BREAKER_HPP_
#define BLOCK_BREAKER_HPP_

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

class BlockBreaker : public SpriteBlock, public MachineBlockMixin<MBlockBreaker>
{
private:
    /*

        #            Block Breaker Meta Byte
        +-------+---+---+---+---+---+---+---+---+
        | Bit   | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
        +-------+---+---+---+---+---+---+---+---+
        | Field |   |   |   | A | frame | orient|
        +-------+---+---+---+---+---+---+---+---+

        orient
            The side towards which the conveyor belt points.
        
        frame
            The frame offset to apply to the animation.
        
        A
            If set, the belt is active.

    */

    static constexpr uint8_t metaActive = 1 << 4;
    static constexpr uint8_t numStates = 1 << 5;

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

    static constexpr int getMetaFrameOffset(uint8_t meta)
    {
        return (meta >> 2) & 3;
    }

    static const std::vector<std::string>& getStateNames();

public:
    BlockBreaker(std::string name);

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

    friend class MBlockBreaker;
};

#endif