#ifndef ASSET_MANAGER_HPP_
#define ASSET_MANAGER_HPP_

#include <string>
#include <unordered_map>

/**
 * @brief Manager responsible for finding game assets.
 */
class AssetManager final
{
private:
    std::string assetsDir = "assets";
    std::unordered_map<std::string, std::string> assetsIndex;

    void loadFromIndex(const std::string &casDir, const std::string &indexPath);

public:
    /**
     * @brief Initialize the assets manager based on env settings etc.
     */
    void init();

    /**
     * @brief Resolve an asset path.
     * 
     * This takes a path relative to the `assets` folder in the source, and returns the
     * actual filesystem path to be used to read the asset.
     */
    std::string resolve(const std::string &assetPath);

    /**
     * @brief Returns true if an asset matching the path exists.
     */
    bool exists(const std::string &assetPath);
};

/**
 * @brief The singleton instance of the asset manager.
 */
extern AssetManager assets;

#endif