Implement a way to map entities to their names, which comes up often enough.

This commit is contained in:
Zed A. Shaw 2025-07-07 10:54:23 -04:00
parent e1d61dc2c1
commit ad78c186c6
3 changed files with 12 additions and 0 deletions

View file

@ -47,6 +47,7 @@ namespace guecs {
std::unordered_map<std::type_index, EntityMap> $components;
std::unordered_map<std::type_index, std::any> $component_storages;
std::unordered_map<string, Entity> $name_ents;
std::unordered_map<Entity, string> $ents_name;
shared_ptr<sf::Font> $font = nullptr;
lel::Parser $parser;
string $grid = "";
@ -60,6 +61,7 @@ namespace guecs {
Entity init_entity(const string& name);
Entity entity(const string& name);
Entity entity(const string& name, int id);
const std::string& name_for(Entity gui_id);
inline lel::CellMap& cells() {
return $parser.cells;