本文整理汇总了C++中EntityManager::createEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::createEntity方法的具体用法?C++ EntityManager::createEntity怎么用?C++ EntityManager::createEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::createEntity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EntityManager
TEST(NAME, DispatchesDestroyEntityEventOnDestruction)
{
World w;
MockEntityManagerListener mock;
EntityManager* em = new EntityManager(&w);
em->event.addListener(&mock, "mock");
// uninteresting calls
EXPECT_CALL(mock, onCreateEntityHelper(testing::_))
.Times(testing::AtLeast(0));
EXPECT_CALL(mock, onEntitiesReallocatedHelper(testing::_))
.Times(testing::AtLeast(0));
// interesting calls
EXPECT_CALL(mock, onDestroyEntityHelper(testing::_))
.Times(1);
Entity& e = em->createEntity("entity");
delete em;
}
示例2: isUnique
void
CEntityBuilder::BuildEntity( TiXmlElement *pParent, EntityManager &em, Resources *pResources){
// Create entity (new id)
Entity *ent = em.createEntity();
if ( !ent){
LOG2ERR<<"Could not create entity\n";
throw "Could not create entity";
}
TiXmlElement* pChilds = pParent->FirstChildElement( "tags");
if ( pChilds ){
// Add tags
for(pChilds=pChilds->FirstChildElement( "tag" ); pChilds; pChilds = pChilds->NextSiblingElement() ){
std::string name;
if ( TIXML_SUCCESS == pChilds->QueryValueAttribute( "name", &name))
{
std::string unique;
bool isUnique(false);
if ( TIXML_SUCCESS == pChilds->QueryValueAttribute( "unique", &unique) ){
isUnique = ( unique=="true");
}
em.tagEntity( ent, name, isUnique);
}
}
}
// Add components
pChilds = pParent->FirstChildElement( "components");
if ( pChilds ){
for( pChilds=pChilds->FirstChildElement( "component" ); pChilds; pChilds = pChilds->NextSiblingElement() ){
std::string type;
if ( TIXML_SUCCESS == pChilds->QueryValueAttribute( "type", &type)){
//LOG2 <<name<<"\n";
buildComponents(pChilds, type, ent, pResources);
}
else {
LOG2ERR<<"Attribute [type] not found\n";
}
}
}
}
示例3: setup
//--------------------------------------------------------------
void testApp::setup() {
world = new World();
EntityManager * em = world->getEntityManager();
world->getSystemManager()->addSystem(new ecs::MotionSystem(world));
world->getSystemManager()->addSystem(new ecs::RenderSystem(world));
for (int i = 0; i < 100; i++) {
Entity * e = em->createEntity();
em->addComponent(e->id, new TransformComponent(rand() % 1024, rand() % 768));
em->addComponent(e->id, new MotionComponent(randPlusMinus(100), randPlusMinus(100)));
em->addComponent(e->id, new RenderComponent(new CircleRenderer(rand() % 5, rand() % 255, rand() % 255, rand() % 255)));
}
ofBackground(0, 0, 0);
}
示例4: GIVEN
using namespace std;
using namespace test;
using namespace tetra;
using namespace tetra::meta;
using namespace tetra::framework;
SCENARIO( "Using an EntityManager to manage a set of entities",
"[EntityManager]" )
{
GIVEN( "An empty EntityManager" )
{
EntityManager entityManager{};
THEN( "We should be able to create a new Entity" )
{
auto id = entityManager.createEntity();
Entity& entity = entityManager.getEntity( id );
}
THEN( "Attempting to access an entity which does not exist "
"should throw an EntityDoesNotExistException" )
{
REQUIRE_THROWS_AS( entityManager.getEntity( 5 ),
EntityDoesNotExistException );
}
THEN( "We should be able to get a list of all existing entities "
"and access them" )
{
auto id1 = entityManager.createEntity();