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


C++ Component::GetType方法代码示例

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


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

示例1: CloneRecursive

Node* Node::CloneRecursive(Node* parent, SceneResolver& resolver, CreateMode mode)
{
    // Create clone node
    Node* cloneNode = parent->CreateChild(0, (mode == REPLICATED && id_ < FIRST_LOCAL_ID) ? REPLICATED : LOCAL);
    resolver.AddNode(id_, cloneNode);

    // Copy attributes
    const Vector<AttributeInfo>* attributes = GetAttributes();
    for (unsigned j = 0; j < attributes->Size(); ++j)
    {
        const AttributeInfo& attr = attributes->At(j);
        // Do not copy network-only attributes, as they may have unintended side effects
        if (attr.mode_ & AM_FILE)
            cloneNode->SetAttribute(j, GetAttribute(j));
    }

    // Clone components
    for (Vector<SharedPtr<Component> >::ConstIterator i = components_.Begin(); i != components_.End(); ++i)
    {
        Component* component = *i;
        Component* cloneComponent = cloneNode->SafeCreateComponent(component->GetTypeName(), component->GetType(), 
            (mode == REPLICATED && component->GetID() < FIRST_LOCAL_ID) ? REPLICATED : LOCAL, 0);
        if (!cloneComponent)
        {
            LOGERROR("Could not clone component " + component->GetTypeName());
            continue;
        }
        resolver.AddComponent(component->GetID(), cloneComponent);

        const Vector<AttributeInfo>* compAttributes = component->GetAttributes();
        if (compAttributes)
        {
            for (unsigned j = 0; j < compAttributes->Size(); ++j)
            {
                const AttributeInfo& attr = compAttributes->At(j);
                if (attr.mode_ & AM_FILE)
                    cloneComponent->SetAttribute(j, component->GetAttribute(j));
            }
        }
    }

    // Clone child nodes recursively
    for (Vector<SharedPtr<Node> >::ConstIterator i = children_.Begin(); i != children_.End(); ++i)
    {
        Node* node = *i;
        node->CloneRecursive(cloneNode, resolver, mode);
    }

    return cloneNode;
}
开发者ID:Canardian,项目名称:Urho3D,代码行数:50,代码来源:Node.cpp

示例2:

Component::Component( Component& c){
    this->id = c.GetID();
    this->type = c.GetType();
    this->name = c.GetName();
}
开发者ID:yi-cheng-kuo,项目名称:GMSProject-ConsoleMode,代码行数:5,代码来源:component.cpp

示例3:

//------------------------------------------------------------------------
// 
//------------------------------------------------------------------------
void game::ObjectFactory::Serialize( const Object * pObj_p, text::GfigElementA * pGFig_p )
{

	// NOTE:
	// saving an object that uses a prefab should optmize out data that equals the prefab.
	// currently, data discarded on the gfigs consider only the defaults..
	// so, for example:
	// default color = rgba(1,1,1,1)
	// prefab color = rgba(1,1,0.5,0.5)
	// obj color = rgba(1,1,0.5,1)
	// 
	// prefab gfig = ba(0.5,0.5)
	// obj gfig = a(1)
	// the only way is create a new factory function for components, that receives a prefab compo for reference
	// TODO

	
	int nCompos = (int)pObj_p->m_components.Size();

	if( pObj_p->m_prefab == -1 ){

		pGFig_p->m_subElements.emplace_back(
			GfigElementA(pObj_p->m_szName,  "" )
			);

		for( int itCompo = 0 ; itCompo < nCompos; ++itCompo ){

			Component * pCompo = pObj_p->m_components[itCompo].Get();

			m_pLayerOwner->m_componentFactory.Serialize( pCompo, &pGFig_p->m_subElements.back() );
		}
	}
	else{

		pGFig_p->m_subElements.emplace_back(
			GfigElementA(pObj_p->m_szName,   pObj_p->m_prefab )
			);

		Object * pPrefab = m_prefabs[pObj_p->m_prefab].pObj.Get();
		//int nPrefCompos = (int)pPrefab->m_components.Size();

		for( int itCompo = 0 ; itCompo < nCompos; ++itCompo ){

			Component * pCompo = pObj_p->m_components[itCompo].Get();
			Component * pPrefCompo = pPrefab->GetFirstOfComponent(pCompo->GetType()).Get();				

			// how to solve multiple of the same compo type? new int on compo?

			if( pCompo->GetType() == COMPONENT_TYPE(AABB2DColliderComponent)
				||
				pCompo->GetType() == COMPONENT_TYPE(TransformComponent)
				||
				pCompo->GetType() == COMPONENT_TYPE(SpriteComponent_)
				||
				pCompo->GetType() == COMPONENT_TYPE(SpriteAnimCompo_)){ // testing just with AABB2d

				if( pPrefCompo != nullptr ){

					m_pLayerOwner->m_componentFactory.Serialize( pCompo, pPrefCompo, &pGFig_p->m_subElements.back() );
				}
				else{

					m_pLayerOwner->m_componentFactory.Serialize(
						pCompo,
						m_pLayerOwner->m_componentFactory.GetDefaultCompo(pCompo->GetType()),
						&pGFig_p->m_subElements.back() );
				}
			}
			else{

				m_pLayerOwner->m_componentFactory.Serialize( pCompo, &pGFig_p->m_subElements.back() );
			}
		}
	}
}
开发者ID:Suminsky,项目名称:redesigningv1,代码行数:78,代码来源:ObjectFactory.cpp


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