World copying with facts and constants is working so now new levels are possible, but need to work on previous level motion.

This commit is contained in:
Zed A. Shaw 2025-01-27 13:48:20 -05:00
parent 2735a0ac1f
commit 82216b8307
6 changed files with 52 additions and 32 deletions

View file

@ -15,33 +15,14 @@ LevelManager::LevelManager() {
size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
auto world = make_shared<DinkyECS::World>();
save::load_configs(*world);
auto map = make_shared<Map>(GAME_MAP_X, GAME_MAP_Y);
if(prev_world != nullptr) {
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);
auto& motion = prev_world->get<Motion>(player.entity);
world->set<Motion>(player.entity, motion);
auto& tile = prev_world->get<Tile>(player.entity);
world->set<Tile>(player.entity, tile);
prev_world->clone_into(*world);
} else {
save::load_configs(*world);
}
auto map = make_shared<Map>(GAME_MAP_X, GAME_MAP_Y);
WorldBuilder builder(*map);
builder.generate(*world);
@ -49,7 +30,6 @@ size_t LevelManager::create_level(shared_ptr<DinkyECS::World> prev_world) {
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,