The next little game in the series where I make a fancy rogue game.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
roguish/levelmanager.cpp

50 lines
1.2 KiB

#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<DinkyECS::World>();
save::load_configs(*level.world);
level.map = make_shared<Map>(GAME_MAP_X, GAME_MAP_Y);
WorldBuilder builder(*level.map);
builder.generate(*level.world);
level.lights = make_shared<LightRender>(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);
}