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
|
|
|
LayerBase<D>::LayerBase (const coords& parCount, const coords& parTileSize, const coords& parMasterTileSize) :
|
2014-12-29 15:17:59 +00:00
|
|
|
m_count(parCount / (parMasterTileSize / parTileSize)),
|
2014-12-11 22:58:52 +00:00
|
|
|
m_tilesize(parTileSize),
|
2015-01-05 17:01:28 +00:00
|
|
|
m_mastersize(parMasterTileSize),
|
|
|
|
m_haveFrom(0),
|
|
|
|
m_haveTo(0)
|
2014-12-09 22:53:09 +00:00
|
|
|
{
|
2014-12-11 22:58:52 +00:00
|
|
|
DK_ASSERT((parMasterTileSize / parTileSize) * parTileSize == parMasterTileSize);
|
2014-12-09 22:53:09 +00:00
|
|
|
}
|
|
|
|
|
2015-01-05 17:01:28 +00:00
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2015-01-05 17:01:28 +00:00
|
|
|
void LayerBase<D>::preload (const coords& parFrom, const coords& parTo) {
|
|
|
|
if (parFrom < m_haveFrom or parTo > m_haveTo) {
|
|
|
|
this->onPreload(parFrom, parTo);
|
|
|
|
m_haveFrom = parFrom;
|
|
|
|
m_haveTo = parTo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-09 22:53:09 +00:00
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <typename T, uint32_t D>
|
2014-12-29 15:17:59 +00:00
|
|
|
Layer<T, D>::Layer (const coords& parTileSize, const coords& parMasterTileSize, TileMapData<T, D>& parTilemap) :
|
|
|
|
LayerBase<D>(parTilemap.mapSize(), parTileSize, parMasterTileSize),
|
|
|
|
m_tilemap(parTilemap)
|
2014-12-09 22:53:09 +00:00
|
|
|
{
|
|
|
|
}
|
2014-12-12 19:04:48 +00:00
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <typename T, uint32_t D>
|
2014-12-12 19:04:48 +00:00
|
|
|
typename Layer<T, D>::iterator Layer<T, D>::begin() {
|
|
|
|
return iterator(&m_tiles, coords(0), this->m_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <typename T, uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
typename Layer<T, D>::iterator Layer<T, D>::end() {
|
|
|
|
return iterator(&m_tiles, implem::buildPastEndCoordinate<D>(coords(0), this->m_count), this->m_count);
|
|
|
|
}
|
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <typename T, uint32_t D>
|
2015-01-05 17:01:28 +00:00
|
|
|
void Layer<T, D>::onPreload (const coords& parFrom, const coords& parTo) {
|
2014-12-12 19:04:48 +00:00
|
|
|
m_tiles.clear();
|
2014-12-29 15:17:59 +00:00
|
|
|
m_tilemap.fetch(m_tiles, parFrom, parTo);
|
2014-12-12 19:04:48 +00:00
|
|
|
}
|
2014-12-09 22:53:09 +00:00
|
|
|
}
|