There's now a config to control the random world gen a bit.
This commit is contained in:
parent
b16405cfdc
commit
7acbd0379f
4 changed files with 22 additions and 19 deletions
|
@ -5,7 +5,8 @@
|
|||
"player": {
|
||||
|
||||
},
|
||||
"type": {
|
||||
"TEST": 1234
|
||||
"worldgen": {
|
||||
"enemy_probability": 60,
|
||||
"empty_room_probability": 20
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"description": "A torch that barely lights the way. You wonder if it'd be better to not see the person who murders you.",
|
||||
"inventory_count": 1,
|
||||
"components": [
|
||||
{"type": "LightSource", "config": {"strength": 100, "radius": 4.0}},
|
||||
{"type": "LightSource", "config": {"strength": 70, "radius": 2.0}},
|
||||
{"type": "Tile", "config": {"chr": "\u0f08"}}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -13,8 +13,8 @@ namespace lighting {
|
|||
float radius = 1.0f;
|
||||
};
|
||||
|
||||
const int MIN = 35;
|
||||
const int MAX = 95;
|
||||
const int MIN = 30;
|
||||
const int MAX = 105;
|
||||
|
||||
class LightRender {
|
||||
public:
|
||||
|
|
|
@ -187,26 +187,28 @@ DinkyECS::Entity configure_entity_in_map(DinkyECS::World &world, Map &game_map,
|
|||
|
||||
|
||||
void WorldBuilder::randomize_entities(DinkyECS::World &world, GameConfig &config) {
|
||||
int rand_type = Random::uniform<int>(0,1);
|
||||
json entity_db = rand_type == 0 ? config.enemies.json() : config.items.json();
|
||||
auto &gen_config = config.game["worldgen"];
|
||||
|
||||
std::vector<std::string> keys;
|
||||
for(auto &el : entity_db.items()) {
|
||||
keys.push_back(el.key());
|
||||
}
|
||||
|
||||
for(size_t room_num = $map.room_count() - 1; room_num > 0; room_num--) {
|
||||
int has_entity = Random::uniform<int>(0, 1);
|
||||
int empty_room = Random::uniform<int>(0, 100);
|
||||
if(empty_room < gen_config["empty_room_probability"]) continue;
|
||||
|
||||
if(has_entity == 0) {
|
||||
int rand_entity = Random::uniform<int>(0, keys.size() - 1);
|
||||
std::string key = keys[rand_entity];
|
||||
auto entity_data = entity_db[key];
|
||||
int rand_type = Random::uniform<int>(0,100);
|
||||
json& entity_db = rand_type < gen_config["enemy_probability"] ? config.enemies.json() : config.items.json();
|
||||
|
||||
// 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;
|
||||
std::vector<std::string> keys;
|
||||
for(auto &el : entity_db.items()) {
|
||||
keys.push_back(el.key());
|
||||
}
|
||||
|
||||
int rand_entity = Random::uniform<int>(0, keys.size() - 1);
|
||||
std::string key = keys[rand_entity];
|
||||
auto entity_data = entity_db[key];
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue