Ndk/Algorithm: Added Is[Component|System] function
Former-commit-id: 946f5081cea0b8df7faf0e95cfea2a3e5dd9f7bb
This commit is contained in:
parent
3b8449ebc4
commit
3f423239f5
|
|
@ -11,11 +11,16 @@
|
|||
|
||||
namespace Ndk
|
||||
{
|
||||
class BaseComponent;
|
||||
class BaseSystem;
|
||||
|
||||
template<unsigned int N> ComponentId BuildComponentId(const char (&name)[N]);
|
||||
template<typename ComponentType> constexpr ComponentIndex GetComponentIndex();
|
||||
template<typename SystemType> constexpr SystemIndex GetSystemIndex();
|
||||
template<typename ComponentType, unsigned int N> ComponentIndex InitializeComponent(const char (&name)[N]);
|
||||
template<typename SystemType> SystemIndex InitializeSystem();
|
||||
template<typename ComponentType> bool IsComponent(BaseComponent& component);
|
||||
template<typename SystemType> bool IsSystem(BaseSystem& system);
|
||||
}
|
||||
|
||||
#include <Ndk/Algorithm.inl>
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||
|
||||
#include <Nazara/Core/Endianness.hpp>
|
||||
#include <Ndk/BaseComponent.hpp>
|
||||
#include <Ndk/BaseSystem.hpp>
|
||||
|
||||
namespace Ndk
|
||||
{
|
||||
|
|
@ -44,4 +46,16 @@ namespace Ndk
|
|||
SystemType::systemIndex = SystemType::RegisterSystem();
|
||||
return SystemType::systemIndex;
|
||||
}
|
||||
|
||||
template<typename ComponentType>
|
||||
bool IsComponent(BaseComponent& component)
|
||||
{
|
||||
return component.GetIndex() == GetComponentIndex<ComponentType>();
|
||||
}
|
||||
|
||||
template<typename SystemType>
|
||||
bool IsSystem(BaseSystem& system)
|
||||
{
|
||||
return system.GetIndex() == GetSystemIndex<SystemType>();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue