Standardized on using only DinkyECS:Entity for most inventory:::Model operations, then create swap based on the same entities.

This commit is contained in:
Zed A. Shaw 2025-07-02 14:25:44 -04:00
parent 8c8d6dc9e7
commit 784f753e72
6 changed files with 62 additions and 53 deletions

View file

@ -6,21 +6,19 @@
// dance when using it. Idea is the System:: ops for this would get it
// and then look at the bool and add the constant ops as needed.
namespace inventory {
using Slot = std::string;
struct Model {
std::unordered_map<Slot, DinkyECS::Entity> by_slot;
std::unordered_map<DinkyECS::Entity, Slot> by_entity;
std::unordered_map<std::string, DinkyECS::Entity> by_slot;
std::unordered_map<DinkyECS::Entity, std::string> by_entity;
bool add(const Slot &in_slot, DinkyECS::Entity ent);
Slot& get(DinkyECS::Entity ent);
DinkyECS::Entity get(const Slot& slot);
bool add(const std::string &in_slot, DinkyECS::Entity ent);
const std::string& get(DinkyECS::Entity ent);
DinkyECS::Entity get(const std::string& slot);
bool has(DinkyECS::Entity ent);
bool has(const Slot& slot);
void remove(const Slot& slot, DinkyECS::Entity ent);
bool has(const std::string& slot);
void remove(DinkyECS::Entity ent);
void remove(const Slot& slot);
void invariant();
void dump();
void swap(DinkyECS::Entity a_ent, DinkyECS::Entity b_ent);
size_t count();
};
}