First step in refactoring to allow for multiple levels. Next is to clean up the APIs and sort out how things will be notified that they have to switch levels.

This commit is contained in:
Zed A. Shaw 2025-01-24 06:22:43 -05:00
parent 3344181a47
commit c14efee9ea
9 changed files with 100 additions and 96 deletions

View file

@ -2,13 +2,16 @@
#include "worldbuilder.hpp"
#include "constants.hpp"
#include "save.hpp"
#include "systems.hpp"
using lighting::LightRender;
using std::shared_ptr, std::make_shared;
LevelManager::LevelManager() {
create_level();
}
size_t LevelManager::create_level() {
auto world = make_shared<DinkyECS::World>();
save::load_configs(*world);
@ -19,8 +22,14 @@ size_t LevelManager::create_level() {
size_t index = $levels.size();
auto collider = make_shared<SpatialMap>();
// not sure if this is still needed
world->set_the<SpatialMap>(*collider);
System::init_positions(*world, *collider);
$levels.emplace_back(index, map, world,
make_shared<LightRender>(map->width(), map->height()));
make_shared<LightRender>(map->width(), map->height()),
collider);
dbc::check(index == $levels.size() - 1, "Level index is not the same as $levels.size() - 1, off by one error");
return index;