Added helper functions to check if Scene nodes are active

This commit is contained in:
maverickdgg 2022-11-13 05:31:18 +08:00
parent 4d0598a7f5
commit 258c07e857
1 changed files with 51 additions and 0 deletions

View File

@ -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<typename ...ComponentTypes>
static std::enable_if_t<(... && std::is_base_of_v<SHComponent, ComponentTypes>), bool> CheckNodeAndComponentsActive(EntityID eid)
{
return CheckNodeActive(eid) && (... && SHComponentManager::GetComponent_s<ComponentTypes>(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<typename ...ComponentTypes>
static std::enable_if_t<(... && std::is_base_of_v<SHComponent, ComponentTypes>), bool> CheckNodeAndHasComponentsActive(EntityID eid)
{
return CheckNodeActive(eid)
&& (... && SHComponentManager::HasComponent<ComponentTypes>(eid))
&& (... && SHComponentManager::GetComponent_s<ComponentTypes>(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