/******************************************************************************
*	File		-	tile_map.h
*	Author		-	Joey Pollack
*	Date		-	2022/02/15 (y/m/d)
*	Mod Date	-	2022/02/15 (y/m/d)
*	Description	-	Contains a single tile map
******************************************************************************/

#ifndef TILE_MAP_H_
#define TILE_MAP_H_

#include <core/types.h>
#include <map>

namespace lunarium { class IGraphics; }

namespace lunarium { namespace editor 
{
    class TileSet;

    // Allows tiles from multiple tilesets to be used in one map
    // A tile ID of -1 will mean "no tile" and result in a transparent spot
    // when rendered
    struct TileRef
    {
        int TileSetID;
        Vec2i TileIndex;
    };

    class TileMap
    {
    public:
        TileMap(std::map<int, TileSet*>* tilesets);
        void SetTile(TileRef, Vec2i location);
        TileRef GetTile(Vec2i location);

        void ClearMap();
        void ResizeMap(Sizei size);

        Sizei GetSizeInTiles();
        Sizei GetSizeInPixels();

        // Call during render to texture phase
        void Render(lunarium::IGraphics* g);

    private:
        TileRef** mpMap;
        Sizei mSizeInTiles;
        std::map<int, TileSet*>* mpTileSets;

    };
}}

#endif  // TILE_MAP_H_