#ifndef _H_RESOURCEMANAGER_H
#define _H_RESOURCEMANAGER_H

#include <unordered_map>
#include <memory>
#include <string>

#include "utility/xmlloader.h"
#include <cassert>

class Sprite;
class Shader;
class Weapon;
class Script;
class AIScript;
class WeaponScript;
class TileSet;
class SpriteComponent;

class ResourceManager
{
public:
	ResourceManager() : 
		xmlLoader(std::make_shared<XMLLoader>()) 
	{ 
		xmlLoader->loadWeapons("weapons"); 
		xmlLoader->loadScenes("scenes"); 
	};

	std::shared_ptr<Sprite>			loadSpriteAnimated		(const std::string& path, float frameSize);
	std::shared_ptr<Sprite>			loadSpriteDirAnimated	(const std::string& path, float frameSize);
	std::shared_ptr<Sprite>			loadSpriteStatic		(const std::string& path);
	std::shared_ptr<AIScript>		loadAIScript			(const std::string& path);
	std::shared_ptr<WeaponScript>	loadWeaponScript		(const std::string& path);
	std::shared_ptr<TileSet>		loadTileSet				(const std::string& path, float frameSize);

	std::shared_ptr<Shader>		loadShader	(const std::string& name, const std::string& vertexPath, const std::string& fragPath);
	std::shared_ptr<Weapon>		loadWeapon	(const std::string& name, std::shared_ptr<Shader> weaponShader, std::shared_ptr<Shader> bulletShader);
	std::shared_ptr<SceneData>	loadScene	(const std::string& id);

	void clearResources();

private:
	std::unordered_map<std::string, std::shared_ptr<Sprite>>	 sprites;
	std::unordered_map<std::string, std::shared_ptr<Shader>>	 shaders;
	std::unordered_map<std::string, std::shared_ptr<Weapon>>	 weapons;
	std::unordered_map<std::string, std::shared_ptr<Script>>	 scripts;
	std::unordered_map<std::string, std::shared_ptr<TileSet>>	 tileSets;
	//std::unordered_map<std::string, std::shared_ptr<EntityData>> entityData;
	//std::unordered_map<std::string, std::shared_ptr<SceneData>>	 scenes;
	//std::unordered_map<std::string, std::shared_ptr<MapData>>	 maps;
	//std::unordered_map<std::string, std::shared_ptr<TileType>>	 tiles;

	std::shared_ptr<XMLLoader> xmlLoader;
};

#endif // _H_RESOURCEMANAGER_H