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

@ -7,6 +7,13 @@
using namespace fmt;
using namespace components;
inline void check_player(DinkyECS::World &world) {
auto player = world.get_the<Player>();
fmt::println("PLAYER ENTITY: {}", player.entity);
auto tile = world.get<Tile>(player.entity);
dbc::check(tile.chr == "\ua66b", format("PLAYER TILE CHANGED {} != {}", tile.chr, "\ua66b"));
}
inline int make_split(Room &cur, bool horiz) {
size_t dimension = horiz ? cur.height : cur.width;
int min = dimension / WORLDBUILD_DIVISION;
@ -215,10 +222,11 @@ void WorldBuilder::randomize_entities(DinkyECS::World &world, GameConfig &config
int rand_entity = Random::uniform<int>(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);
(void)entity;
fmt::println("ENTITY: {}", entity);
}
}
@ -228,6 +236,11 @@ void WorldBuilder::place_entities(DinkyECS::World &world) {
if(world.has_the<Player>()) {
fmt::println("PLAYER ALREADY EXISTS LEAVING ALONE");
auto& player = world.get_the<Player>();
Point pos_out;
bool placed = $map.place_entity(0, pos_out);
dbc::check(placed, "failed to randomly place item in room");
world.set<Position>(player.entity, {pos_out.x+1, pos_out.y+1});
} else {
auto player_data = config.enemies["PLAYER_TILE"];
auto player_ent = configure_entity_in_map(world, $map, player_data, 0);