|
|
|
@ -144,11 +144,10 @@ void System::distribute_loot(GameLevel &level, Position target_pos) { |
|
|
|
|
auto& world = *level.world; |
|
|
|
|
auto& config = world.get_the<GameConfig>(); |
|
|
|
|
int inventory_count = Random::uniform(0, 3); |
|
|
|
|
auto loot_entity = world.entity(); |
|
|
|
|
|
|
|
|
|
if(inventory_count > 0) { |
|
|
|
|
// do a clone of the things we need, like Position
|
|
|
|
|
auto junk_entity = world.entity(); |
|
|
|
|
|
|
|
|
|
// this means the entity dropped loot, so make a lootable tombstone
|
|
|
|
|
ritual::JunkPile pile; |
|
|
|
|
auto& junk = config.rituals["junk"]; |
|
|
|
|
|
|
|
|
@ -164,23 +163,20 @@ void System::distribute_loot(GameLevel &level, Position target_pos) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
auto entity_data = config.devices["GRAVE_STONE"]; |
|
|
|
|
components::configure_entity(world, junk_entity, entity_data["components"]); |
|
|
|
|
world.set<ritual::JunkPile>(junk_entity, pile); |
|
|
|
|
components::configure_entity(world, loot_entity, entity_data["components"]); |
|
|
|
|
world.set<ritual::JunkPile>(loot_entity, pile); |
|
|
|
|
// BUG: inventory_count here isn't really used to remove it
|
|
|
|
|
world.set<InventoryItem>(junk_entity, {inventory_count, entity_data}); |
|
|
|
|
world.set<InventoryItem>(loot_entity, {inventory_count, entity_data}); |
|
|
|
|
|
|
|
|
|
set_position(world, *level.collision, junk_entity, target_pos); |
|
|
|
|
set_position(world, *level.collision, loot_entity, target_pos); |
|
|
|
|
|
|
|
|
|
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, junk_entity, {}); |
|
|
|
|
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, loot_entity, {}); |
|
|
|
|
} else { |
|
|
|
|
dbc::log("DEAD BODY NOT IMPLEMENTED, for now just removing enemy"); |
|
|
|
|
// BUG: should maybe add a component to the world for "dead thing no loot" that
|
|
|
|
|
// has no collision or goes away after some kind of animation
|
|
|
|
|
// Something like:
|
|
|
|
|
// auto entity_data = config.devices["DEAD_BODY"];
|
|
|
|
|
// components::configure_entity(world, ent, entity_data["components"]);
|
|
|
|
|
// then give it a collision device that makes it go away and make a sound
|
|
|
|
|
// or maybe you can walk over dead bodies and they make a noise
|
|
|
|
|
// this creates a dead body on the ground
|
|
|
|
|
auto entity_data = config.devices["DEAD_BODY"]; |
|
|
|
|
components::configure_entity(world, loot_entity, entity_data["components"]); |
|
|
|
|
set_position(world, *level.collision, loot_entity, target_pos); |
|
|
|
|
level.world->send<Events::GUI>(Events::GUI::ENTITY_SPAWN, loot_entity, {}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|