本文整理汇总了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;
}
示例2:
Component::Component( Component& c){
this->id = c.GetID();
this->type = c.GetType();
this->name = c.GetName();
}
示例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() );
}
}
}
}