Levels are now expanded out as you travel down and the stairs are only placed at the end of the level instead of randomly.
This commit is contained in:
parent
82216b8307
commit
59a6882b70
11 changed files with 57 additions and 10 deletions
|
@ -216,8 +216,12 @@ void WorldBuilder::randomize_entities(DinkyECS::World &world, GameConfig &config
|
|||
json& entity_db = select_entity_type(config, gen_config);
|
||||
|
||||
std::vector<std::string> keys;
|
||||
for(auto &el : entity_db.items()) {
|
||||
keys.push_back(el.key());
|
||||
for(auto& el : entity_db.items()) {
|
||||
auto& data = el.value();
|
||||
|
||||
if(data["placement"] == nullptr) {
|
||||
keys.push_back(el.key());
|
||||
}
|
||||
}
|
||||
|
||||
int rand_entity = Random::uniform<int>(0, keys.size() - 1);
|
||||
|
@ -230,6 +234,14 @@ void WorldBuilder::randomize_entities(DinkyECS::World &world, GameConfig &config
|
|||
}
|
||||
}
|
||||
|
||||
inline void place_stairs(DinkyECS::World& world, GameConfig& config, Map& map) {
|
||||
auto& device_config = config.devices.json();
|
||||
auto entity_data = device_config["STAIRS_DOWN"];
|
||||
int last_room = map.room_count() - 1;
|
||||
auto entity = configure_entity_in_map(world, map, entity_data, last_room);
|
||||
check_player(world, entity);
|
||||
}
|
||||
|
||||
void WorldBuilder::place_entities(DinkyECS::World &world) {
|
||||
auto &config = world.get_the<GameConfig>();
|
||||
// configure a player as a fact of the world
|
||||
|
@ -251,6 +263,7 @@ void WorldBuilder::place_entities(DinkyECS::World &world) {
|
|||
}
|
||||
|
||||
randomize_entities(world, config);
|
||||
place_stairs(world, config, $map);
|
||||
}
|
||||
|
||||
void WorldBuilder::generate(DinkyECS::World &world) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue