You can now go down to new levels but the whole setup isn't very good. I need to now move to having a global/master World and one for each level so I don't copy the player and other important things around on each level.

This commit is contained in:
Zed A. Shaw 2025-01-25 14:07:02 -05:00
parent 2825faf038
commit 58fae858ff
2 changed files with 21 additions and 2 deletions

View file

@ -20,12 +20,16 @@ size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
auto map = make_shared<Map>(GAME_MAP_X, GAME_MAP_Y);
if(prev_world != nullptr) {
auto player = prev_world->get_the<Player>();
auto& player = prev_world->get_the<Player>();
player.entity = world->entity();
world->set_the<Player>(player);
auto inventory = prev_world->get<Inventory>(player.entity);
world->set<Inventory>(player.entity, inventory);
auto light = prev_world->get<LightSource>(player.entity);
world->set<LightSource>(player.entity, light);
world->set_the<Debug>(prev_world->get_the<Debug>());
auto& combat = prev_world->get<Combat>(player.entity);
world->set<Combat>(player.entity, combat);
@ -34,6 +38,8 @@ size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
world->set<Motion>(player.entity, motion);
auto& tile = prev_world->get<Tile>(player.entity);
fmt::println("player tile is: {}", tile.chr);
world->set<Tile>(player.entity, tile);
}