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


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

本文整理汇总了C++中EntityManager::AddEntity方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::AddEntity方法的具体用法?C++ EntityManager::AddEntity怎么用?C++ EntityManager::AddEntity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntityManager的用法示例。


在下文中一共展示了EntityManager::AddEntity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CreateEntity

EntityID EntityFactory::CreateEntity(std::string pTemplateName)
{
    EntityBlueprint tComponentMap = mEntityBlueprints[pTemplateName];
    EntityManager* tEntityManager = tEntityManager->GetInstance();
    ComponentTable* tComponentTable = tComponentTable->GetInstance();

    //create a new ID
    EntityID tNewEntityID = tEntityManager->AddEntity();

    //copy components
    for (EntityBlueprint::iterator iter = tComponentMap.begin(); iter != tComponentMap.end(); ++iter)
    {
        tComponentTable->AddComponent(tNewEntityID, iter->first);

        if (iter->first == ComponentType::PhysicType)
        {
            memcpy(GetComponent<PhysicComponent>(tNewEntityID), iter->second, sizeof(PhysicComponent));
        }
        else if (iter->first == ComponentType::TransformType)
        {
            memcpy(GetComponent<TransformComponent>(tNewEntityID), iter->second, sizeof(TransformComponent));
        }
        else if (iter->first == ComponentType::MeshType)
        {
            memcpy(GetComponent<MeshComponent>(tNewEntityID), iter->second, sizeof(MeshComponent));
        }
        else if (iter->first == ComponentType::LabelType)
        {
            memcpy(GetComponent<LabelComponent>(tNewEntityID), iter->second, sizeof(LabelComponent));
        }
        else if (iter->first == ComponentType::VelocityType)
        {
            memcpy(GetComponent<VelocityComponent>(tNewEntityID), iter->second, sizeof(VelocityComponent));
        }
        else if (iter->first == ComponentType::CollisionType)
        {
            memcpy(GetComponent<CollisionComponent>(tNewEntityID), iter->second, sizeof(CollisionComponent));
        }
        else if (iter->first == ComponentType::VelocityForceType)
        {
            memcpy(GetComponent<VelocityForceComponent>(tNewEntityID), iter->second, sizeof(VelocityForceComponent));
        }
        else if (iter->first == ComponentType::SoundCollisionType)
        {
            memcpy(GetComponent<SoundCollisionComponent>(tNewEntityID), iter->second, sizeof(SoundCollisionComponent));
        }
        else if (iter->first == ComponentType::AttachedType)
        {
            memcpy(GetComponent<AttachedComponent>(tNewEntityID), iter->second, sizeof(AttachedComponent));
        }
        else if (iter->first == ComponentType::ScoreValueType)
        {
            memcpy(GetComponent<ScoreValueComponent>(tNewEntityID), iter->second, sizeof(ScoreValueComponent));
        }
        else if (iter->first == ComponentType::MenyButtonType)
        {
            memcpy(GetComponent<MenyButtonComponent>(tNewEntityID), iter->second, sizeof(MenyButtonComponent));
        }
        else if (iter->first == ComponentType::PowerUpType)
        {
            memcpy(GetComponent<PowerUpComponent>(tNewEntityID), iter->second, sizeof(PowerUpComponent));
        }
        else if (iter->first == ComponentType::PowerUpContainType)
        {
            memcpy(GetComponent<PowerUpContainComponenet>(tNewEntityID), iter->second, sizeof(PowerUpContainComponenet));
        }
        else if (iter->first == ComponentType::EmitterType)
        {
            memcpy(GetComponent<EmitterComponent>(tNewEntityID), iter->second, sizeof(EmitterComponent));
        }


    }

    return tNewEntityID;
}
开发者ID:akerspoket,项目名称:TAJMS-Agil-Breakout,代码行数:76,代码来源:EntityFactory.cpp


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