Refactored inventory some so that the UI is not so knowing of the internals.

This commit is contained in:
Zed A. Shaw 2025-02-23 23:57:46 -05:00
parent e0e7a1027c
commit 0878a9e978
8 changed files with 90 additions and 92 deletions

View file

@ -141,6 +141,7 @@ void System::death(GameLevel &level, components::ComponentMap& components) {
auto entity_data = config.items["GRAVE_STONE"];
components::configure_entity(components, world, ent, entity_data["components"]);
if(entity_data["inventory_count"] > 0) {
// right here use a std::any that's already converted instead?
world.set<InventoryItem>(ent, {entity_data["inventory_count"], entity_data});
}
}
@ -248,15 +249,6 @@ void System::collision(GameLevel &level) {
}
}
void System::pickup(DinkyECS::World &world, DinkyECS::Entity actor, DinkyECS::Entity item) {
dbc::pre("System::pickup actor doesn't have inventory", world.has<Inventory>(actor));
dbc::pre("System::pickup item isn't configured with InventoryItem.", world.has<InventoryItem>(item));
auto& inventory = world.get<Inventory>(actor);
auto& invitem = world.get<InventoryItem>(item);
inventory.add(invitem);
}
void System::device(DinkyECS::World &world, DinkyECS::Entity actor, DinkyECS::Entity item) {
auto& device = world.get<Device>(item);