2014-12-09 22:53:09 +00:00
|
|
|
#ifndef idD3EDC396AA314474B3D909559FFC0247
|
|
|
|
#define idD3EDC396AA314474B3D909559FFC0247
|
|
|
|
|
2015-01-06 15:38:52 +00:00
|
|
|
#include "doorkeeper/primitivetypes.hpp"
|
|
|
|
#include "doorkeeper/components/tileiterator.hpp"
|
|
|
|
#include "doorkeeper/components/tilemapdata.hpp"
|
|
|
|
#include "doorkeeper/implem/helpers.hpp"
|
2014-12-09 22:53:09 +00:00
|
|
|
#include <algorithm>
|
|
|
|
#include <vector>
|
2014-12-29 15:17:59 +00:00
|
|
|
#include <memory>
|
2015-01-08 11:20:17 +00:00
|
|
|
#include <cstdint>
|
2014-12-09 22:53:09 +00:00
|
|
|
|
|
|
|
namespace dk {
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-12 19:04:48 +00:00
|
|
|
class Viewport;
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-09 22:53:09 +00:00
|
|
|
class LayerBase {
|
|
|
|
public:
|
|
|
|
typedef Vector<CoordinateScalarType, D> coords;
|
|
|
|
|
2014-12-12 19:04:48 +00:00
|
|
|
LayerBase ( const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize );
|
2014-12-09 22:53:09 +00:00
|
|
|
virtual ~LayerBase ( void ) noexcept = default;
|
|
|
|
|
2015-01-05 17:01:28 +00:00
|
|
|
void preload ( const coords& parFrom, const coords& parTo );
|
2014-12-14 12:13:10 +00:00
|
|
|
coords count ( void ) const { return m_mastersize / m_tilesize * m_count; }
|
2014-12-29 15:17:59 +00:00
|
|
|
const coords& mapSize ( void ) const { return m_count; }
|
2014-12-14 12:13:10 +00:00
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
protected:
|
2014-12-12 19:04:48 +00:00
|
|
|
coords m_count;
|
2014-12-11 22:58:52 +00:00
|
|
|
coords m_tilesize;
|
|
|
|
coords m_mastersize;
|
2014-12-29 15:17:59 +00:00
|
|
|
|
|
|
|
private:
|
2015-01-05 17:01:28 +00:00
|
|
|
virtual void onPreload ( const coords& parFrom, const coords& parTo ) = 0;
|
|
|
|
|
|
|
|
coords m_haveFrom;
|
|
|
|
coords m_haveTo;
|
2014-12-09 22:53:09 +00:00
|
|
|
};
|
|
|
|
|
2015-01-08 11:20:17 +00:00
|
|
|
template <typename T, uint32_t D>
|
2014-12-09 22:53:09 +00:00
|
|
|
class Layer : public LayerBase<D> {
|
2014-12-14 12:13:10 +00:00
|
|
|
friend class Viewport<D>;
|
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
public:
|
|
|
|
typedef typename LayerBase<D>::coords coords;
|
2014-12-12 19:04:48 +00:00
|
|
|
typedef TileIterator<T, D> iterator;
|
2014-12-30 16:53:15 +00:00
|
|
|
typedef TileIterator<const T, D> const_iterator;
|
2014-12-09 22:53:09 +00:00
|
|
|
|
|
|
|
Layer ( const Layer& ) = delete;
|
|
|
|
Layer ( Layer&& ) = default;
|
2014-12-29 15:17:59 +00:00
|
|
|
Layer ( const coords& parTileSize, const coords& parMasterTileSize, TileMapData<T, D>& parTilemap );
|
2014-12-09 22:53:09 +00:00
|
|
|
virtual ~Layer ( void ) noexcept = default;
|
|
|
|
|
|
|
|
Layer& operator= ( const Layer& ) = delete;
|
|
|
|
|
2014-12-12 19:04:48 +00:00
|
|
|
iterator begin ( void );
|
2014-12-14 12:13:10 +00:00
|
|
|
iterator end ( void );
|
2014-12-12 19:04:48 +00:00
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
private:
|
2015-01-05 17:01:28 +00:00
|
|
|
virtual void onPreload ( const coords& parFrom, const coords& parTo );
|
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
std::vector<T> m_tiles;
|
2014-12-29 15:17:59 +00:00
|
|
|
TileMapData<T, D>& m_tilemap;
|
2014-12-09 22:53:09 +00:00
|
|
|
};
|
|
|
|
} //namespace dk
|
|
|
|
|
2015-01-06 15:38:52 +00:00
|
|
|
#include "doorkeeper/implem/layer.inl"
|
2014-12-09 22:53:09 +00:00
|
|
|
|
|
|
|
#endif
|