#include "levelmanager.hpp" #include "worldbuilder.hpp" #include "constants.hpp" #include "save.hpp" using lighting::LightRender; using std::shared_ptr, std::make_shared; LevelManager::LevelManager() { } size_t LevelManager::create_level() { GameLevel level; level.index = $levels.size(); level.world = make_shared(); save::load_configs(*level.world); level.map = make_shared(GAME_MAP_X, GAME_MAP_Y); WorldBuilder builder(*level.map); builder.generate(*level.world); level.lights = make_shared(level.map->width(), level.map->height()); $levels.push_back(level); dbc::check(level.index == $levels.size() - 1, "Level index is not the same as $levels.size() - 1, off by one error"); return level.index; } GameLevel &LevelManager::next() { dbc::check($current_level < $levels.size(), "attempt to get next level when at end"); $current_level++; return $levels.at($current_level); } GameLevel &LevelManager::previous() { dbc::check($current_level > 0, "attempt to go to previous level when at 0"); $current_level--; return $levels.at($current_level); } GameLevel &LevelManager::current() { return $levels.at($current_level); } GameLevel &LevelManager::get(size_t index) { return $levels.at(index); }