Refactor out the junk randomizer and put it in rituals where it belongs.
This commit is contained in:
parent
05d54ff661
commit
521180b086
3 changed files with 25 additions and 14 deletions
15
systems.cpp
15
systems.cpp
|
@ -144,20 +144,7 @@ void System::distribute_loot(GameLevel &level, Position target_pos) {
|
|||
auto loot_entity = world.entity();
|
||||
|
||||
if(inventory_count > 0) {
|
||||
// this means the entity dropped loot, so make a lootable tombstone
|
||||
ritual::JunkPile pile;
|
||||
auto& junk = config.rituals["junk"];
|
||||
|
||||
ritual::JunkPile select_from;
|
||||
for(auto& el : junk.items()) {
|
||||
select_from.contents.push_back(el.key());
|
||||
}
|
||||
|
||||
for(int i = 0; i < inventory_count; i++) {
|
||||
size_t max_junk = select_from.contents.size();
|
||||
auto& item = select_from.contents.at(Random::uniform(size_t(0), max_junk-1));
|
||||
pile.contents.push_back(item);
|
||||
}
|
||||
auto pile = ritual::random_junk(config, inventory_count);
|
||||
|
||||
auto entity_data = config.devices["GRAVE_STONE"];
|
||||
components::configure_entity(world, loot_entity, entity_data["components"]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue