diff --git a/modules/ecs/CMakeLists.txt b/modules/ecs/CMakeLists.txt index a71cef7d..834323cb 100644 --- a/modules/ecs/CMakeLists.txt +++ b/modules/ecs/CMakeLists.txt @@ -2,7 +2,7 @@ add_library(antara_ecs_shared_sources INTERFACE) target_sources(antara_ecs_shared_sources INTERFACE antara/gaming/ecs/base.system.cpp antara/gaming/ecs/system.manager.cpp) target_include_directories(antara_ecs_shared_sources INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(antara_ecs_shared_sources INTERFACE EnTT strong_type expected range-v3 antara::refl-cpp antara::default_settings antara::timer) +target_link_libraries(antara_ecs_shared_sources INTERFACE EnTT strong_type expected range-v3 antara::refl-cpp antara::default_settings antara::timer antara::event) add_library(antara::ecs_shared_sources ALIAS antara_ecs_shared_sources) diff --git a/modules/ecs/antara/gaming/ecs/antara.ecs.system.manager.tests.cpp b/modules/ecs/antara/gaming/ecs/antara.ecs.system.manager.tests.cpp index 60e526c1..64111e33 100644 --- a/modules/ecs/antara/gaming/ecs/antara.ecs.system.manager.tests.cpp +++ b/modules/ecs/antara/gaming/ecs/antara.ecs.system.manager.tests.cpp @@ -137,6 +137,8 @@ namespace antara::gaming::ecs::tests CHECK_FALSE(manager.disable_systems()); CHECK_EQ(0ull, manager.update()); CHECK_EQ(0ull, manager.nb_systems()); + manager.get_systems(); + c_mgr.get_systems(); } } } \ No newline at end of file diff --git a/modules/ecs/antara/gaming/ecs/system.manager.hpp b/modules/ecs/antara/gaming/ecs/system.manager.hpp index 90652bc4..f0e87a2a 100644 --- a/modules/ecs/antara/gaming/ecs/system.manager.hpp +++ b/modules/ecs/antara/gaming/ecs/system.manager.hpp @@ -28,6 +28,7 @@ #include "antara/gaming/ecs/system.hpp" #include "antara/gaming/ecs/system.type.hpp" #include "antara/gaming/timer/time.step.hpp" +#include "antara/gaming/event/fatal.error.event.hpp" namespace antara::gaming::ecs { @@ -113,7 +114,7 @@ namespace antara::gaming::ecs * \tparam TSystem Represents the system that needs to be marked * \return true if the system has been marked, false otherwise */ - template + template bool mark_system() noexcept; /** @@ -123,7 +124,7 @@ namespace antara::gaming::ecs * \details This function recursively calls the mark_system function * \see mark_system */ - template + template bool mark_systems() noexcept; /** @@ -131,7 +132,7 @@ namespace antara::gaming::ecs * \tparam TSystem Represents the system that needs to be enabled. * \return true if the system has been enabled, false otherwise */ - template + template bool enable_system() noexcept; /** @@ -141,7 +142,7 @@ namespace antara::gaming::ecs * \details This function recursively calls the enable_system function * \see enable_system */ - template + template bool enable_systems() noexcept; /** @@ -150,7 +151,7 @@ namespace antara::gaming::ecs * \return true if the the system has been disabled, false otherwise * \attention If you deactivate a system, it will not be destroyed but simply ignore during the game loop */ - template + template bool disable_system() noexcept; /** @@ -159,7 +160,7 @@ namespace antara::gaming::ecs * \return true if the list of systems has been disabled, false otherwise * \details This function recursively calls the disable_system function */ - template + template bool disable_systems() noexcept; /** @@ -208,7 +209,7 @@ namespace antara::gaming::ecs clock::time_point start_{clock::now()}; timer::time_step timestep_; [[maybe_unused]] entt::registry &entity_registry_; - [[maybe_unused]] entt::dispatcher &dispatcher_; + [[maybe_unused]] entt::dispatcher &dispatcher_; system_registry systems_{{}}; bool need_to_sweep_systems_{false}; }; @@ -220,10 +221,8 @@ namespace antara::gaming::ecs template const TSystem &system_manager::get_system() const noexcept { - const auto ret = get_system_().or_else([](const std::error_code &ec) { - //! TODO: error handling for get_system (const and non const) - static_cast(ec); - //this->dispatcher_.trigger(ec); + const auto ret = get_system_().or_else([this](const std::error_code &ec) { + this->dispatcher_.trigger(ec); }); return (*ret).get(); } @@ -231,9 +230,8 @@ namespace antara::gaming::ecs template TSystem &system_manager::get_system() noexcept { - auto ret = get_system_().or_else([](const std::error_code &ec) { - static_cast(ec); - //this->dispatcher_.trigger(ec); + auto ret = get_system_().or_else([this](const std::error_code &ec) { + this->dispatcher_.trigger(ec); }); return (*ret).get(); } @@ -287,7 +285,7 @@ namespace antara::gaming::ecs return (has_system() && ...); } - template + template bool system_manager::mark_system() noexcept { if (has_system()) { @@ -299,13 +297,13 @@ namespace antara::gaming::ecs return false; } - template + template bool system_manager::mark_systems() noexcept { return (mark_system() && ...); } - template + template bool system_manager::enable_system() noexcept { if (has_system()) { @@ -315,13 +313,13 @@ namespace antara::gaming::ecs return false; } - template + template bool system_manager::enable_systems() noexcept { return (enable_system() && ...); } - template + template bool system_manager::disable_system() noexcept { if (has_system()) { @@ -331,7 +329,7 @@ namespace antara::gaming::ecs return false; } - template + template bool system_manager::disable_systems() noexcept { return (disable_system() && ...); diff --git a/modules/event/antara/gaming/event/fatal.error.event.hpp b/modules/event/antara/gaming/event/fatal.error.event.hpp index 26eb3c5f..b4b1bee2 100644 --- a/modules/event/antara/gaming/event/fatal.error.event.hpp +++ b/modules/event/antara/gaming/event/fatal.error.event.hpp @@ -23,7 +23,7 @@ namespace antara::gaming::event { struct fatal_error { - explicit fatal_error(std::error_code ec); + fatal_error(std::error_code ec); std::error_code ec_; }; } diff --git a/modules/event/antara/gaming/event/quit.game.event.hpp b/modules/event/antara/gaming/event/quit.game.event.hpp index 64d7305d..2fbcf00e 100644 --- a/modules/event/antara/gaming/event/quit.game.event.hpp +++ b/modules/event/antara/gaming/event/quit.game.event.hpp @@ -20,7 +20,7 @@ namespace antara::gaming::event { struct quit_game { - explicit quit_game(int return_value = 0) noexcept; + quit_game(int return_value = 0) noexcept; int return_value_; }; } \ No newline at end of file