#include "asset_loader.h"
#include "file_manager.h"
#include "yaml/yaml.h"
#include <fstream>
namespace engineapi {
	void AssetLoader::Init() {
		ResourceManager::GetSingleton().RegisterLoader<AssetLoader>(".asset");
	}
	ResourceBundle AssetLoader::LoadFile(PackagePath handle, const MetaBundle& meta)
	{
		return ResourceBundle();
	}
	void AssetLoader::SaveFile(PackagePath handle, const ResourceBundle& bundle)
	{
		YAML::Node result;
		for (auto& elem : bundle.GetAll<Asset>()) {
			RscHandle<Asset> handle = elem.AsHandle<Asset>();
			YAML::Node meta;
			meta["name"] = string(handle->meta->name);
			meta["data"] = YAML::Text_Serialize(refl::Any{handle.res, handle->meta});
			result.push_back(meta);
		}
		//FileManager::SaveTextFile(handle, YAML::Dump(result));
	}
}
