Ndk/BaseSystem: Added "one of" style requirement

Former-commit-id: ce4399561f4198290d639d001a6a56665baa0714
This commit is contained in:
Lynix
2015-05-03 19:50:42 +02:00
parent 9bffaaaa84
commit 3ebf967f30
3 changed files with 33 additions and 1 deletions

View File

@@ -87,11 +87,31 @@ namespace Ndk
m_requiredComponents.UnboundedSet(index);
}
template<typename ComponentType>
void BaseSystem::RequiresAny()
{
static_assert(std::is_base_of<BaseComponent, ComponentType>(), "ComponentType is not a component");
RequiresAnyComponent(GetComponentIndex<ComponentType>());
}
template<typename ComponentType1, typename ComponentType2, typename... Rest>
void BaseSystem::RequiresAny()
{
RequiresAny<ComponentType1>();
RequiresAny<ComponentType2, Rest...>();
}
inline void BaseSystem::RequiresAnyComponent(ComponentIndex index)
{
m_requiredAnyComponents.UnboundedSet(index);
}
inline void BaseSystem::AddEntity(Entity* entity)
{
NazaraAssert(entity, "Invalid entity");
m_entities.push_back(entity->CreateHandle());
m_entities.emplace_back(entity);
m_entityBits.UnboundedSet(entity->GetId(), true);
entity->RegisterSystem(m_systemIndex);