本文整理汇总了C++中IStatObj::GetParentObject方法的典型用法代码示例。如果您正苦于以下问题:C++ IStatObj::GetParentObject方法的具体用法?C++ IStatObj::GetParentObject怎么用?C++ IStatObj::GetParentObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStatObj
的用法示例。
在下文中一共展示了IStatObj::GetParentObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindHelperObject_Extended
// TODO: this whole function should be removed and FindHelperObject_Basic integrated back into FindHelperObject.
// It manages some undefined cases that appeared in C2, but it should not be needed with a strict definition of how the grabAndThrow helpers have to be defined in the objects
IStatObj::SSubObject* FindHelperObject_Extended( const char* pHelperName, EntityId objectId, int slot )
{
IStatObj::SSubObject* pSObjHelper = NULL;
IEntity* pEntity = gEnv->pEntitySystem->GetEntity( objectId );
SEntitySlotInfo info;
if (pEntity && pEntity->GetSlotInfo( slot, info ))
{
if (info.pStatObj)
{
IStatObj* pStatObj = info.pStatObj->GetCloneSourceObject(); // we use the clone source in case it exists. Because when it is cloned, only geometries are cloned. the helpers are NOT cloned.
if (!pStatObj)
pStatObj = info.pStatObj;
// special case: when the pStatObj is the root, we look for the first helper that does not have a hidden parent, whatever is its name as long as it includes pHelperName
// because: it can be child of a visible geometry (usually "main"...) even when that geometry is not the root
if (!pSObjHelper && !pStatObj->GetParentObject())
{
const int subObjectCount = pStatObj->GetSubObjectCount();
for (int sid = 0; sid < subObjectCount; ++sid)
{
IStatObj::SSubObject* pLocSObjHelper = pStatObj->GetSubObject( sid );
if ( pLocSObjHelper && (pLocSObjHelper->nType==STATIC_SUB_OBJECT_DUMMY) && strstr( pLocSObjHelper->name.c_str(), pHelperName ))
{
pLocSObjHelper = pStatObj->GetSubObject( pLocSObjHelper->nParent );
if (pLocSObjHelper && (pLocSObjHelper->nType==STATIC_SUB_OBJECT_MESH) && !pLocSObjHelper->bHidden)
{
pSObjHelper = pStatObj->GetSubObject( sid );
break;
}
}
}
}
// if all failed, we look from the parent, but by id
// because: helpers are not necesarily a subobject of their geometry, but just a child
if (!pSObjHelper && pStatObj->GetParentObject())
{
IStatObj* pParent = pStatObj->GetParentObject();
IStatObj::SSubObject* pMeSubObject = pParent->FindSubObject( pStatObj->GetGeoName() );
if (pMeSubObject)
{
const int subObjectCount = pParent->GetSubObjectCount();
for (int sid=0; sid < subObjectCount; ++sid)
{
IStatObj::SSubObject* pLocSObjHelper = pParent->GetSubObject( sid );
if ( pLocSObjHelper && (pLocSObjHelper->nType==STATIC_SUB_OBJECT_DUMMY) && (pLocSObjHelper->name==pHelperName) && (pParent->GetSubObject( pLocSObjHelper->nParent )==pMeSubObject) )
{
pSObjHelper = pLocSObjHelper;
break;
}
}
}
}
//If STILL we don't find the object, try with composed name based on geometry name (for destroyed pieces), and look on the whole hierarchy
if (!pSObjHelper)
{
CryFixedStringT<128> helperNameBuffer;
helperNameBuffer.Format("%s_%s", pStatObj->GetGeoName(), pHelperName);
pSObjHelper = pStatObj->FindSubObject( helperNameBuffer.c_str() );
if (!pSObjHelper)
{
IStatObj* pObj = pStatObj;
while (pObj->GetParentObject())
pObj = pObj->GetParentObject();
pSObjHelper = FindHelperObject_RecursivePart( pObj, helperNameBuffer.c_str() );
}
}
}
}
return pSObjHelper;
}