当前位置: 首页>>代码示例>>C++>>正文


C++ EntityManager::createEntity方法代码示例

本文整理汇总了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;
}
开发者ID:TheComet93,项目名称:ontology,代码行数:20,代码来源:test_EntityManager.cpp

示例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";
      }
    }
  }
}
开发者ID:slowfrog,项目名称:chickenpix,代码行数:40,代码来源:EntityBuilder.cpp

示例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);
}
开发者ID:jimmytheleaf,项目名称:OpenFrameworksSandbox,代码行数:23,代码来源:testApp.cpp

示例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();
开发者ID:projectTetra,项目名称:tetra-framework,代码行数:31,代码来源:EntityManagerTest.cpp


注:本文中的EntityManager::createEntity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。