#pragma once

#include <Model3D.h>

#include "Area.h"
#include "BlockType.h"
#include "FactoryCraftModel.h"
#include "ModelInfo.h"

using namespace Framework;

class BasicBlockItemType;
class Chunk;

class Block : public FactoryCraftModel
{
protected:
    float hp;
    float maxHP;
    const BlockType* zType;
    bool sideVisible[6];
    Vec3<int> location;
    unsigned char lightData[6 * 6];
    char needRequestModelInfo;
    int partOfModel;
    char flowOptions;
    char distanceToSource;
    bool passable;
    float speedModifier;
    Direction frontDirection;
    ModelInfo* currentModelInfo;

    void beforeRender(
        GraphicsApi* api, Shader* zVertexShader, Shader* zPixelShader) override;

public:
    Block(const BlockType* zType,
        Vec3<int> position,
        Model3DData* model,
        Model3DTexture* texture,
        int maxHp,
        bool transparent,
        bool needRequestModelInfo,
        float size,
        bool passable,
        float speedModifier,
        Direction frontDirection);
    virtual ~Block();

    void setFlow(char flowOptions, char distanceToSource);
    void api(char* message);
    void copyLightTo(Block* zB);
    void setLightData(Direction dir, unsigned char* data, Chunk* zC);
    void setPartOfModel(int type, bool part);
    __int64 getMaxLight() const;
    const unsigned char* getLightData(Direction dir) const;
    bool isVisible() const;
    Direction getFrontDirection() const;

    Vec3<int> getLocation() const;
    const BlockType* zBlockType() const;
    Skeleton* zSkeleton() const;
    Text printLightInfo();
    int getPartOfModels() const;
    char getFlowOptions() const;
    char getDistanceToSource() const;
    const ModelInfo& getCurrentModelInfo() const;

    friend Chunk;
};