#ifndef _H_MAP_H
#define _H_MAP_H

#include <vector>
#include <memory>

#include "graphics/instancedraw.h"
#include "graphics/renderer.h"

class Shader;
class Camera;
class ResourceManager;
struct MapData;
struct TileSetData;

class Map : public Drawable
{
public:
	Map(const MapData* mapData, const unsigned shaderID, std::shared_ptr<ResourceManager> resourceManager);

	const std::vector<std::vector<int>> getCollisionMap() const { return collisionMap; }

	void draw() override;

private:
	void loadMap();
	void createCollisionMap();

	size_t getTileSetIndex(int id) const;

	const MapData* mapData;
	std::vector<const TileSetData*> tileSetData;

	std::vector<std::shared_ptr<TileTextureInstance>> instanceHandles;
	std::vector<std::vector<std::vector<int>>> tileIds;
	std::vector<std::vector<int>> collisionMap;
	std::vector<std::vector<InstanceData>> tileData;
};

#endif
