/******************************************************************************
*	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 "definitions.h"
#include <core/types.h>
#include <utils/op_res.h>
#include <map>

namespace lunarium { class IGraphics; }

namespace lunarium { namespace editor 
{
    class TileSet;

    class TileMap
    {
    public:
        TileMap(Sizei tile_size);
        [[NoDiscard]] OpRes AddTileSet(int id, TileSet*);

        void MarkClean();
        bool IsDirty() const;

        void SetTile(TileRef, Vec2i location);
        TileRef GetTile(Vec2i location);

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

        Sizei GetSizeInTiles();
        Sizei GetSizeInPixels();
        Sizei GetTileSize();

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

    private:
        TileRef** mpMap;
        Sizei mSizeInTiles;
        Sizei mTileSize;
        std::map<int, TileSet*> mTileSets;
        bool mIsDirty;

    };
}}

#endif  // TILE_MAP_H_