69 lines
2.4 KiB
C++
69 lines
2.4 KiB
C++
namespace dk {
|
|
///--------------------------------------------------------------------------
|
|
///--------------------------------------------------------------------------
|
|
template <uint32_t D>
|
|
Tyler<D>::Tyler (const coords& parTileSize) :
|
|
m_size(0),
|
|
m_tilesize(parTileSize)
|
|
{
|
|
}
|
|
|
|
///--------------------------------------------------------------------------
|
|
///--------------------------------------------------------------------------
|
|
template <uint32_t D>
|
|
typename Tyler<D>::coords::scalar_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;
|
|
}
|
|
|
|
///--------------------------------------------------------------------------
|
|
///--------------------------------------------------------------------------
|
|
template <uint32_t D>
|
|
template <typename T>
|
|
Layer<T, D>& Tyler<D>::push_layer (BaseMapSource<D>* parTilemap, int parIndex) {
|
|
return push_layer<T>(parTilemap, coords(static_cast<CoordinateScalarType>(1)), parIndex);
|
|
}
|
|
|
|
///--------------------------------------------------------------------------
|
|
///--------------------------------------------------------------------------
|
|
template <uint32_t D>
|
|
template <typename T>
|
|
Layer<T, D>& Tyler<D>::push_layer (BaseMapSource<D>* parTilemap, const coords& parSubdiv, int parIndex) {
|
|
//TODO: store the index
|
|
(void)parIndex;
|
|
|
|
auto newLayer = new Layer<T, D>(m_tilesize / parSubdiv, m_tilesize, parTilemap);
|
|
if (m_size == coords(0)) {
|
|
m_size = newLayer->mapSize();
|
|
}
|
|
else {
|
|
DK_ASSERT(newLayer->mapSize() == m_size);
|
|
if (newLayer->mapSize() != m_size) {
|
|
throw SizeMismatchException();
|
|
}
|
|
}
|
|
DK_ASSERT(newLayer->count() == m_size * parSubdiv);
|
|
m_layers.push_back(LayerPtr(newLayer));
|
|
return *newLayer;
|
|
}
|
|
|
|
///--------------------------------------------------------------------------
|
|
///--------------------------------------------------------------------------
|
|
template <uint32_t D>
|
|
template <typename T>
|
|
void Tyler<D>::push_layer_void (BaseMapSource<D>* parTilemap, int parIndex) {
|
|
push_layer<T>(parTilemap, parIndex);
|
|
}
|
|
|
|
///--------------------------------------------------------------------------
|
|
///--------------------------------------------------------------------------
|
|
template <uint32_t D>
|
|
void Tyler<D>::preload (const coords& parFrom, const coords& parTo) {
|
|
for (auto& layer : m_layers) {
|
|
layer->preload(parFrom, parTo);
|
|
}
|
|
}
|
|
} //namespace dk
|