2014-12-09 21:30:06 +00:00
|
|
|
namespace dk {
|
2014-12-09 22:53:09 +00:00
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2015-05-24 23:37:20 +00:00
|
|
|
Tyler<D>::Tyler (const coords& parTileSize) :
|
|
|
|
m_size(0),
|
2014-12-11 22:58:52 +00:00
|
|
|
m_tilesize(parTileSize)
|
2014-12-09 21:30:06 +00:00
|
|
|
{
|
|
|
|
}
|
2014-12-09 22:53:09 +00:00
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-09 22:53:09 +00:00
|
|
|
typename Tyler<D>::coords::value_type Tyler<D>::tiles_count() const {
|
|
|
|
typename coords::value_type retval = 1;
|
|
|
|
for (size_t d = 0; d < D; ++d) {
|
|
|
|
retval *= m_size[d];
|
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-09 22:53:09 +00:00
|
|
|
template <typename T>
|
2015-05-24 23:37:20 +00:00
|
|
|
Layer<T, D>& Tyler<D>::push_layer (BaseMapSource<T, D>* parTilemap) {
|
|
|
|
return push_layer(parTilemap, coords(static_cast<CoordinateScalarType>(1)));
|
2014-12-11 22:58:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-11 22:58:52 +00:00
|
|
|
template <typename T>
|
2015-05-24 23:37:20 +00:00
|
|
|
Layer<T, D>& Tyler<D>::push_layer (BaseMapSource<T, D>* parTilemap, const coords& parSubdiv) {
|
2014-12-29 15:17:59 +00:00
|
|
|
auto newLayer = new Layer<T, D>(m_tilesize / parSubdiv, m_tilesize, parTilemap);
|
2015-05-24 23:37:20 +00:00
|
|
|
if (m_size == coords(0)) {
|
|
|
|
m_size = newLayer->mapSize();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
DK_ASSERT(newLayer->mapSize() == m_size);
|
|
|
|
if (newLayer->mapSize() != m_size) {
|
|
|
|
throw SizeMismatchException();
|
|
|
|
}
|
|
|
|
}
|
2014-12-29 15:17:59 +00:00
|
|
|
DK_ASSERT(newLayer->count() == m_size * parSubdiv);
|
2014-12-12 19:04:48 +00:00
|
|
|
m_layers.push_back(LayerPtr(newLayer));
|
|
|
|
return *newLayer;
|
2014-12-09 22:53:09 +00:00
|
|
|
}
|
2014-12-14 12:13:10 +00:00
|
|
|
|
|
|
|
///--------------------------------------------------------------------------
|
|
|
|
///--------------------------------------------------------------------------
|
2015-01-08 11:20:17 +00:00
|
|
|
template <uint32_t D>
|
2014-12-14 12:13:10 +00:00
|
|
|
void Tyler<D>::preload (const coords& parFrom, const coords& parTo) {
|
|
|
|
for (auto& layer : m_layers) {
|
|
|
|
layer->preload(parFrom, parTo);
|
|
|
|
}
|
|
|
|
}
|
2014-12-09 21:30:06 +00:00
|
|
|
} //namespace dk
|