本文整理汇总了C++中CElement::CountChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ CElement::CountChildren方法的具体用法?C++ CElement::CountChildren怎么用?C++ CElement::CountChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CElement
的用法示例。
在下文中一共展示了CElement::CountChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RemovePlayersBelow
void CPerPlayerEntity::RemovePlayersBelow(CElement* pElement, std::set<CPlayer*>& Removed)
{
assert(pElement);
// Is this a player?
if (IS_PLAYER(pElement))
{
// Remove the reference
CPlayer* pPlayer = static_cast<CPlayer*>(pElement);
RemovePlayerReference(pPlayer);
// Did we just loose the last reference to that player? Add him to the list over removed players.
if (!IsVisibleToPlayer(*pPlayer))
{
MapInsert(Removed, pPlayer);
}
}
// Call ourself on all our children
CChildListType ::const_iterator iterChildren = pElement->IterBegin();
for (; iterChildren != pElement->IterEnd(); iterChildren++)
{
CElement* pElement = *iterChildren;
if (pElement->CountChildren() || IS_PLAYER(pElement)) // This check reduces cpu usage when unloading large maps (due to recursion)
RemovePlayersBelow(pElement, Removed);
}
}
示例2: AddPlayersBelow
void CPerPlayerEntity::AddPlayersBelow(CElement* pElement, std::set<CPlayer*>& Added)
{
assert(pElement);
// Is this a player?
if (IS_PLAYER(pElement))
{
// Are we not already visible to that player? Add it to the list
CPlayer* pPlayer = static_cast<CPlayer*>(pElement);
if (!IsVisibleToPlayer(*pPlayer))
{
MapInsert(Added, pPlayer);
}
// Add it to our reference list
AddPlayerReference(pPlayer);
}
// Call ourself on all its children elements
CChildListType ::const_iterator iterChildren = pElement->IterBegin();
for (; iterChildren != pElement->IterEnd(); iterChildren++)
{
CElement* pElement = *iterChildren;
if (pElement->CountChildren() || IS_PLAYER(pElement)) // This check reduces cpu usage when loading large maps (due to recursion)
AddPlayersBelow(pElement, Added);
}
}
示例3: BroadcastElementChildren
void CMapManager::BroadcastElementChildren ( CElement* pParentElement, CEntityAddPacket &Packet, std::vector < CPerPlayerEntity* > &pPerPlayerList, std::set < CElement* >& outDoneElements )
{
CChildListType ::const_iterator iter = pParentElement->IterBegin ();
for ( ; iter != pParentElement->IterEnd(); iter++ )
{
CElement* pChildElement = *iter;
MapInsert( outDoneElements, pChildElement );
// Is it a per-player entity
if ( pChildElement->IsPerPlayerEntity () )
{
pPerPlayerList.push_back ( static_cast < CPerPlayerEntity* > ( pChildElement ) );
}
else
{
Packet.Add ( pChildElement );
}
if ( pChildElement->CountChildren() > 0 )
BroadcastElementChildren ( pChildElement, Packet, pPerPlayerList, outDoneElements );
}
}
示例4: BroadcastElementChildren
void CMapManager::BroadcastElementChildren ( CElement* pElement, CEntityAddPacket &Packet, list < CPerPlayerEntity* > &pPerPlayerList, bool bBroadcastAll )
{
CElement * pTemp;
CChildListType ::const_iterator iter = pElement->IterBegin ();
for ( ; iter != pElement->IterEnd(); iter++ )
{
pTemp = *iter;
// Is this a map created entity or our resource's root element
if ( bBroadcastAll || ( pTemp->IsMapCreated () || ( pTemp->GetType () == CElement::DUMMY && !strcmp ( pTemp->GetTypeName ().c_str (), "map" ) ) ) )
{
// Is it a per-player entity
if ( pTemp->IsPerPlayerEntity () )
{
pPerPlayerList.push_back ( static_cast < CPerPlayerEntity* > ( pTemp ) );
}
else
{
Packet.Add ( pTemp );
}
}
if ( pTemp->CountChildren() > 0 ) BroadcastElementChildren ( pTemp, Packet, pPerPlayerList, bBroadcastAll );
}
}