VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
Registry.cpp
1#include "components/ECS/Registry.hpp"
2#include <unordered_map>
3#include <string>
4
5namespace vex {
6
7uint32_t ComponentType::get_id_by_name(const char* name) {
8 static std::unordered_map<std::string, uint32_t> type_map;
9 static uint32_t next_type_id = 0;
10
11 std::string typeName(name);
12
13 auto it = type_map.find(typeName);
14 if (it != type_map.end()) {
15 return it->second;
16 }
17
18 uint32_t id = next_type_id++;
19 type_map[typeName] = id;
20 return id;
21}
22
23}