本文整理汇总了C++中EntityManager::removeComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::removeComponent方法的具体用法?C++ EntityManager::removeComponent怎么用?C++ EntityManager::removeComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::removeComponent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(EntityFilter, Single) {
EntityManager entityManager;
// Set up filter
EntityFilter<TestComponent<0>> filter;
filter.setEntityManager(&entityManager);
// Add component
EntityId entityId = entityManager.generateNewId();
entityManager.addComponent(
entityId,
make_unique<TestComponent<0>>()
);
// Check filter
auto filteredEntities = filter.entities();
EXPECT_EQ(1, filteredEntities.count(entityId));
EXPECT_EQ(1, filteredEntities.size());
// Remove component
entityManager.removeComponent(
entityId,
TestComponent<0>::TYPE_ID
);
entityManager.processRemovals();
// Check filter
filteredEntities = filter.entities();
EXPECT_EQ(0, filteredEntities.count(entityId));
EXPECT_EQ(0, filteredEntities.size());
}
示例2: filter
TEST(EntityFilter, Record) {
EntityManager entityManager;
using TestFilter = EntityFilter<
TestComponent<0>
>;
// Set up filter
TestFilter filter(true);
filter.setEntityManager(&entityManager);
TestFilter::EntityMap filteredEntities = filter.entities();
// Add first component
EntityId entityId = entityManager.generateNewId();
entityManager.addComponent(
entityId,
make_unique<TestComponent<0>>()
);
// Check added entities
EXPECT_EQ(1, filter.addedEntities().count(entityId));
// Remove component
entityManager.removeComponent(
entityId,
TestComponent<0>::TYPE_ID
);
entityManager.processRemovals();
// Check removed entities
EXPECT_EQ(1, filter.removedEntities().count(entityId));
}
示例3: removeComponent
void removeComponent()
{
entityManager->removeComponent(*this, ComponentTypeManager::getTypeFor<c>());
}