From 2735a0ac1ff84df40440ce80cba43045c39f7853 Mon Sep 17 00:00:00 2001 From: "Zed A. Shaw" Date: Mon, 27 Jan 2025 11:52:33 -0500 Subject: [PATCH] Initial level management works and can go down levels but need to rework the ecs a bit to have the concept of 'constant' information and make copying it easy. --- dinkyecs.hpp | 10 ++++++++++ levelmanager.cpp | 1 - worldbuilder.cpp | 9 ++++----- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dinkyecs.hpp b/dinkyecs.hpp index 5b39593..ade2e87 100644 --- a/dinkyecs.hpp +++ b/dinkyecs.hpp @@ -29,10 +29,20 @@ namespace DinkyECS { std::unordered_map $components; std::unordered_map $facts; std::unordered_map $events; + std::vector constants; Entity entity() { return ++entity_count; } +/* + void clone_into(DinkyECS::World &from_world, DinkyECS::World &to_world) { + + } + + void update_constants(DinkyECS::World &from_world, DinkyECS::World &to_world) { + + } + */ template EntityMap& entity_map_for() { diff --git a/levelmanager.cpp b/levelmanager.cpp index 50b4b11..f51ea6c 100644 --- a/levelmanager.cpp +++ b/levelmanager.cpp @@ -39,7 +39,6 @@ size_t LevelManager::create_level(shared_ptr prev_world) { auto& tile = prev_world->get(player.entity); - fmt::println("player tile is: {}", tile.chr); world->set(player.entity, tile); } diff --git a/worldbuilder.cpp b/worldbuilder.cpp index 2b12643..9e157d1 100644 --- a/worldbuilder.cpp +++ b/worldbuilder.cpp @@ -7,9 +7,10 @@ using namespace fmt; using namespace components; -inline void check_player(DinkyECS::World &world) { +inline void check_player(DinkyECS::World &world, DinkyECS::Entity entity) { auto player = world.get_the(); - fmt::println("PLAYER ENTITY: {}", player.entity); + dbc::check(player.entity != entity, "player shouldn't be added to world"); + auto tile = world.get(player.entity); dbc::check(tile.chr == "\ua66b", format("PLAYER TILE CHANGED {} != {}", tile.chr, "\ua66b")); } @@ -222,11 +223,10 @@ void WorldBuilder::randomize_entities(DinkyECS::World &world, GameConfig &config int rand_entity = Random::uniform(0, keys.size() - 1); std::string key = keys[rand_entity]; auto entity_data = entity_db[key]; - check_player(world); // pass that to the config as it'll be a generic json auto entity = configure_entity_in_map(world, $map, entity_data, room_num); - fmt::println("ENTITY: {}", entity); + check_player(world, entity); } } @@ -235,7 +235,6 @@ void WorldBuilder::place_entities(DinkyECS::World &world) { // configure a player as a fact of the world if(world.has_the()) { - fmt::println("PLAYER ALREADY EXISTS LEAVING ALONE"); auto& player = world.get_the(); Point pos_out; bool placed = $map.place_entity(0, pos_out);