DoorKeeper/include/components/layer.hpp
King_DuckZ c9381a4585 Advancing in the design of Tyler.
Iterating through tiles in viewports now works fine.
You can pass in a custom device as the data source for the tile map.
2014-12-29 16:17:59 +01:00

63 lines
1.6 KiB
C++

#ifndef idD3EDC396AA314474B3D909559FFC0247
#define idD3EDC396AA314474B3D909559FFC0247
#include "primitivetypes.hpp"
#include "components/tileiterator.hpp"
#include "components/tilemapdata.hpp"
#include "implem/helpers.hpp"
#include <algorithm>
#include <vector>
#include <memory>
namespace dk {
template <size_t D>
class Viewport;
template <size_t D>
class LayerBase {
public:
typedef Vector<CoordinateScalarType, D> coords;
LayerBase ( const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize );
virtual ~LayerBase ( void ) noexcept = default;
virtual void preload ( const coords& parFrom, const coords& parTo ) = 0;
coords count ( void ) const { return m_mastersize / m_tilesize * m_count; }
const coords& mapSize ( void ) const { return m_count; }
protected:
coords m_count;
coords m_tilesize;
coords m_mastersize;
private:
};
template <typename T, size_t D>
class Layer : public LayerBase<D> {
friend class Viewport<D>;
public:
typedef typename LayerBase<D>::coords coords;
typedef TileIterator<T, D> iterator;
Layer ( const Layer& ) = delete;
Layer ( Layer&& ) = default;
Layer ( const coords& parTileSize, const coords& parMasterTileSize, TileMapData<T, D>& parTilemap );
virtual ~Layer ( void ) noexcept = default;
Layer& operator= ( const Layer& ) = delete;
iterator begin ( void );
iterator end ( void );
virtual void preload ( const coords& parFrom, const coords& parTo );
private:
std::vector<T> m_tiles;
TileMapData<T, D>& m_tilemap;
};
} //namespace dk
#include "implem/layer.inl"
#endif