#ifndef BLOCK_SPRITE_DESIGNER_HPP_
#define BLOCK_SPRITE_DESIGNER_HPP_

#include <BlockSprite/BlockSprite.hpp>
#include <unordered_map>
#include <memory>
#include <ScriptEngine/ScriptEngine.hpp>

/**
 * @brief Executes block sprite design scripts to generate the sprites.
 */
class BlockSpriteDesigner
{
private:
    std::string blockDir;
    std::string scriptPath;
    std::string dumpDir;
    std::string blockPureName;

    int nextSpriteId = 1;
    std::unordered_map<int, std::shared_ptr<VoxelSprite>> voxelSprites;
    std::unordered_map<std::string, std::shared_ptr<BlockSprite>> exportedSprites;

    ScriptEngine engine;

    void addScriptFuncs();

public:
    BlockSpriteDesigner(std::string blockPureName);

    void execute();
    std::shared_ptr<BlockSprite> tryGetSprite(std::string exportName);
    int addSprite(std::shared_ptr<VoxelSprite> vsp);
    void useFallbackScript(std::string path);

    friend class SpriteBlock;
};

#endif