#pragma once

#include <DXBuffer.h>
#include <GraphicsApi.h>
#include <Model3D.h>
#include <Texture.h>

class FactoryCraftModel : public Framework::Model3D
{
private:
    Framework::DXBuffer* vertexLightBuffer;
    Framework::DXBuffer* fallbackVertexLightBuffer;
    __int64* lightBuffer;
    int vertexLightBufferCount;
    bool visible;
    float destroyedState;
    Framework::Texture* breakTextur;
    bool effectAlpha;
    unsigned char averageLight[8];

protected:
    void beforeRender(Framework::GraphicsApi* api,
        Framework::Shader* zVertexShader,
        Framework::Shader* zPixelShader) override;
    void afterRender(Framework::GraphicsApi* api,
        Framework::Shader* zVertexShader,
        Framework::Shader* zPixelShader) override;

public:
    FactoryCraftModel();
    ~FactoryCraftModel();
    void setVertexLightBuffer(__int64* data, int vertexCount);
    __int64* zLightBuffer();
    void copyLightToGPU();
    void setVisible(bool visible);
    void setDestroyedState(float percentage);
    void setUseEffectAlpha(bool useAlpha);
    bool needRenderPolygon(int index) override;
    Framework::Texture* zEffectTexture() override;
    float getEffectPercentage() override;
    void setAverageLight(unsigned char light[3]);
};