namespace { \
struct AutoRegisterComp_##Counter { \
AutoRegisterComp_##Counter() { \
size_t scopePos = refl.
name.rfind(
"::"); \
if (scopePos != std::string::npos) refl.
name = refl.
name.substr(scopePos + 2); \
if (refl.
name.size() > 9 && refl.
name.rfind(
"Component") == refl.
name.size() - 9) { \
} \
std::string _path = MenuPath; \
size_t _slash = _path.rfind('/'); \
if (_slash != std::string::npos) { \
refl.
category = _path.substr(0, _slash); \
} else { \
} \
refl.
has = [](Registry& reg,
Entity e) {
return reg.
has<Type>(e); }; \
refl.
get = [](Registry& reg,
Entity e) {
return static_cast<void*
>(reg.
get<Type>(e)); }; \
auto init = InitFunc; \
init(refl); \
Engine::ComponentReflectionRegistry::getInstance().registerComponent(refl); \
} \
}; \
static AutoRegisterComp_##Counter global_autoRegComp_##Counter; \
}
bool has(Entity e)
Checks if an entity possesses a component of type T.
Definition Registry.hpp:172
T * get(Entity e)
Retrieves a pointer to a component of type T on an entity.
Definition Registry.hpp:146
void remove(Entity e)
Removes a component of type T from an entity.
Definition Registry.hpp:126
T & emplace(Entity e, T &&comp)
Emplaces a component on an entity.
Definition Registry.hpp:106
@ Entity
Definition ComponentReflection.hpp:22
Reflection metadata and ECS callbacks for a component.
Definition ComponentReflection.hpp:48
std::string name
Internal component name (derived from type, e.g. "SpriteRenderer").
Definition ComponentReflection.hpp:50
std::function< void *(Registry &, Entity)> get
Definition ComponentReflection.hpp:62
std::function< void(Registry &, Entity)> remove
Definition ComponentReflection.hpp:61
std::function< void(Registry &, Entity)> add
Definition ComponentReflection.hpp:59
std::string displayName
Human-readable label inside the category submenu (e.g. "Sprite Renderer"). If empty the editor derive...
Definition ComponentReflection.hpp:55
std::string category
Top-level menu group shown in "Add Component" (e.g. "Rendering & Lights").
Definition ComponentReflection.hpp:52
std::function< bool(Registry &, Entity)> has
Definition ComponentReflection.hpp:60