Turns out I don't need to remove so much when I simply don't want to display something. Closes #82.

This commit is contained in:
Zed A. Shaw 2025-08-17 10:51:08 -04:00
parent 20fa95bd93
commit 25a143cf22
3 changed files with 5 additions and 10 deletions

View file

@ -24,6 +24,8 @@ using namespace DinkyECS;
using lighting::LightSource;
void System::set_position(World& world, SpatialMap& collision, Entity entity, Position pos) {
dbc::check(world.has<Tile>(entity), "entity doesn't have tile");
world.set<Position>(entity, pos);
bool has_collision = world.has<Collision>(entity);
collision.insert(pos.location, entity, has_collision);
@ -146,14 +148,14 @@ void System::distribute_loot(GameLevel &level, Position target_pos) {
if(inventory_count > 0) {
auto pile = ritual::random_junk(config, inventory_count);
auto entity_data = config.devices["DEAD_BODY_LOOTABLE"];
auto& entity_data = config.devices["DEAD_BODY_LOOTABLE"];
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>(loot_entity, {inventory_count, entity_data});
} else {
// this creates a dead body on the ground
auto entity_data = config.devices["DEAD_BODY"];
auto& entity_data = config.devices["DEAD_BODY"];
components::configure_entity(world, loot_entity, entity_data["components"]);
}
@ -309,7 +311,7 @@ void System::collision(GameLevel &level) {
void System::remove_from_world(GameLevel &level, Entity entity) {
auto& item_pos = level.world->get<Position>(entity);
level.collision->remove(item_pos.location, entity);
level.world->remove<Tile>(entity);
// level.world->remove<Tile>(entity);
// if you don't do this you get the bug that you can pickup
// an item and it'll also be in your inventory
level.world->remove<Position>(entity);