From bbef37950db8378b80a07aaf21c9fd6ee29c0588 Mon Sep 17 00:00:00 2001 From: Ricardo Antunes Date: Tue, 21 Nov 2023 08:53:53 +0000 Subject: [PATCH] feat(ecs): add untyped World::registerComponent --- core/include/cubos/core/ecs/world.hpp | 19 +++++++++---------- core/src/cubos/core/ecs/world.cpp | 6 ++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/core/include/cubos/core/ecs/world.hpp b/core/include/cubos/core/ecs/world.hpp index 6d34d372b..50e550c7b 100644 --- a/core/include/cubos/core/ecs/world.hpp +++ b/core/include/cubos/core/ecs/world.hpp @@ -53,10 +53,16 @@ namespace cubos::core::ecs void registerResource(TArgs... args); /// @brief Registers a component type. - /// @note Should be called before other operations, aside from @ref registerResource(). + /// @param type Component type. + void registerComponent(const reflection::Type& type); + + /// @brief Registers a component type. /// @tparam T Component type. - template - void registerComponent(); + template + void registerComponent() + { + this->registerComponent(reflection::reflect()); + } /// @brief Locks a resource for reading and returns it. /// @tparam T Resource type. @@ -376,13 +382,6 @@ namespace cubos::core::ecs mResourceManager.add(args...); } - template - void World::registerComponent() - { - CUBOS_TRACE("Registered component '{}'", reflection::reflect().name()); - mComponentManager.registerType(reflection::reflect()); - } - template ReadResource World::read() const { diff --git a/core/src/cubos/core/ecs/world.cpp b/core/src/cubos/core/ecs/world.cpp index 29e672070..af895b490 100644 --- a/core/src/cubos/core/ecs/world.cpp +++ b/core/src/cubos/core/ecs/world.cpp @@ -14,6 +14,12 @@ World::World(std::size_t initialCapacity) // Edu: BAH! } +void World::registerComponent(const reflection::Type& type) +{ + CUBOS_TRACE("Registered component '{}'", type.name()); + mComponentManager.registerType(type); +} + Entity World::create() { Entity::Mask mask{};