#pragma once

#include "basicPipe.h"
#include <game/interface/selectable.h>
#include <game/interface/withGui.h>


namespace game{

class pipe: public basicPipe, public selectable, public withGui
{
public:
    pipe(const vec2f &pos, level*);
    virtual ~pipe();

    uint getItemType() const noexcept;

    virtual float add(uint item, float amount) noexcept;

    virtual void draw();

    virtual void onGui() noexcept;

    virtual void select() noexcept;
    virtual void hover() noexcept;

    virtual void onNeighbourCreated(entity*);
    virtual void beforeNeighbourDestroyed(entity*);

protected:

    bool _addUndergroundPipe(pipe*,uint32_t,bool);
    void _removeUndergroundPipe(pipe*,uint32_t,bool);
    pipe *_findPipe(uint32_t);

    void _drawWindow();
    void _drawShortInfo();

    void _mathMask();

    int _lockedItem;

    pipe *_undergroundConnections[4];
    bool _needShowGui, _needShowShortInfo, _needRemathMask;
    uint _drawMask, _type;
};

}
