From 258c07e8578d956aefa948795b08ce763c2ee61d Mon Sep 17 00:00:00 2001 From: maverickdgg Date: Sun, 13 Nov 2022 05:31:18 +0800 Subject: [PATCH] Added helper functions to check if Scene nodes are active --- SHADE_Engine/src/Scene/SHSceneManager.h | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/SHADE_Engine/src/Scene/SHSceneManager.h b/SHADE_Engine/src/Scene/SHSceneManager.h index 23d13261..8f03b352 100644 --- a/SHADE_Engine/src/Scene/SHSceneManager.h +++ b/SHADE_Engine/src/Scene/SHSceneManager.h @@ -21,6 +21,7 @@ #include "SH_API.h" #include "ECS_Base/General/SHFamily.h" #include "Assets/SHAssetMacros.h" +#include "ECS_Base/Managers/SHComponentManager.h" namespace SHADE { @@ -116,6 +117,56 @@ namespace SHADE sceneChanged = true; } + /******************************************************************** + * \brief + * Check if the Entity's scene node is active and all the + * components specified are active. + * This does not check if the entity HasComponent. Please use + * CheckNodeAndHasComponentActive for that. + * \param eid + * EntityID of the entity to check for. + * \return + * true if scene node is active and all the components specified + * are also active. + ********************************************************************/ + template + static std::enable_if_t<(... && std::is_base_of_v), bool> CheckNodeAndComponentsActive(EntityID eid) + { + return CheckNodeActive(eid) && (... && SHComponentManager::GetComponent_s(eid)->isActive); + } + + /******************************************************************** + * \brief + * Check if the Entity's scene node is active and all the + * components specified are active. + * This also checks to verify that the entity has such components. + * \param eid + * EntityID of the entity to check for. + * \return + * true if scene node is active and all the components specified + * are also active. + ********************************************************************/ + template + static std::enable_if_t<(... && std::is_base_of_v), bool> CheckNodeAndHasComponentsActive(EntityID eid) + { + return CheckNodeActive(eid) + && (... && SHComponentManager::HasComponent(eid)) + && (... && SHComponentManager::GetComponent_s(eid)->isActive); + } + + /******************************************************************** + * \brief + * Check if Scene node is active. + * \param eid + * EntityID of the entity to check for. + * \return + * true if scene node is active + ********************************************************************/ + static bool CheckNodeActive(EntityID eid) + { + return GetCurrentSceneGraph().IsActiveInHierarchy(eid); + } + /*!************************************************************************* * \brief