本文整理汇总了C++中CElement类的典型用法代码示例。如果您正苦于以下问题:C++ CElement类的具体用法?C++ CElement怎么用?C++ CElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetChildrenListSnapshot
void CElement::CallEventNoParent ( const char* szName, const CLuaArguments& Arguments, CElement* pSource, CPlayer* pCaller )
{
// Call it on us if this isn't the same class it was raised on
if ( pSource != this && m_pEventManager->HasEvents () )
{
m_pEventManager->Call ( szName, Arguments, pSource, this, pCaller );
}
// Call it on all our children
CElementListSnapshot* pList = GetChildrenListSnapshot();
pList->AddRef(); // Keep list alive during use
for ( CElementListSnapshot::const_iterator iter = pList->begin() ; iter != pList->end() ; iter++ )
{
CElement* pElement = *iter;
if ( !pElement->IsBeingDeleted() )
{
if ( !pElement->m_pEventManager || pElement->m_pEventManager->HasEvents () || !pElement->m_Children.empty () )
{
pElement->CallEventNoParent ( szName, Arguments, pSource, pCaller );
if ( m_bIsBeingDeleted )
break;
}
}
}
pList->Release();
}
示例2: assert
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);
}
}
示例3: ATTR_METHOD_IMPL
ATTR_METHOD_IMPL(CElementParser, OnMaxOccurs)
{
TRACE_PARSE_ENTRY();
if (cchValue==sizeof("unbounded")-1 && !wcsncmp(wszValue, L"unbounded", cchValue))
{
CElement * pCurr = GetElement();
if (pCurr != NULL)
{
pCurr->SetMaxOccurs(MAXOCCURS_UNBOUNDED);
return S_OK;
}
return E_FAIL;
}
int nMaxOccurs = 0;
nMaxOccurs = _wtoi(wszValue);
if (nMaxOccurs >= 0)
{
//
// maxOccurs must be >= 0
//
CElement * pCurr = GetElement();
if (pCurr != NULL)
{
pCurr->SetMaxOccurs(nMaxOccurs);
return S_OK;
}
}
EmitInvalidValue("maxOccurs", wszValue);
return E_FAIL;
}
示例4: it
bool CComponentLibrary::fromXml(const CXmlElement &xmlElement,
CXmlSerializingContext &serializingContext)
{
CXmlElement childElement;
CXmlElement::CChildIterator it(xmlElement);
// XML populate all component libraries
while (it.next(childElement)) {
// Filter component library/type set elements
if (childElement.getType() == "ComponentLibrary" ||
childElement.getType() == "ComponentTypeSet") {
if (!fromXml(childElement, serializingContext)) {
return false;
}
} else {
// Regular child creation and populating
CElement *pChild = createChild(childElement, serializingContext);
if (!pChild || !pChild->fromXml(childElement, serializingContext)) {
return false;
}
}
}
return true;
}
示例5: GetOwner
void CFreeCameraComponent::Reset()
{
CElement *owner = GetOwner();
m_camController->SetPosition( owner->GetPosition() );
}
示例6:
/*****************************************************************
*
* method :void DrawCurrentPage(CDC *inDC)
*
* parameters : inCDC a device context
*
* returns : nothing
*
* description: Draw the current page
*
*
****************************************************************/
void CEasyReport::DrawCurrentPage(CDC *inDC)
{
int i,aStart, aMax;
CElement *aElem;
if( m_CurPage != 0 )
aStart = m_PageItems[m_CurPage-1];
else
aStart = 0;
aMax = m_PageItems[m_CurPage];
for( i =aStart;i< aMax;i++)
{
aElem = (CElement *)m_ReportItems[i];
aElem->Draw(inDC);
}
/*
CRect aRect(m_LeftMargin, -m_TopMargin,
m_PageWidth - m_RightMargin, -(m_PageHeight-m_BottomMargin));
inDC->MoveTo(aRect.left, aRect.top);
inDC->LineTo(aRect.right,aRect.top);
inDC->LineTo(aRect.right, aRect.bottom);
inDC->LineTo(aRect.left, aRect.bottom);
inDC->LineTo(aRect.left, aRect.top);
*/
}
示例7: assert
void CElement::_GetEntitiesFromRoot ( unsigned int uiTypeHash, std::map < CElement*, int >& mapResults )
{
t_mapEntitiesFromRoot::iterator find = ms_mapEntitiesFromRoot.find ( uiTypeHash );
if ( find != ms_mapEntitiesFromRoot.end () )
{
CChildListType& listEntities = find->second;
CElement* pEntity;
unsigned int uiIndex = 0;
for ( CChildListType::const_reverse_iterator i = listEntities.rbegin ();
i != listEntities.rend ();
++i )
{
pEntity = *i;
assert ( pEntity );
ElementID ID = pEntity->GetID ();
assert ( ID != INVALID_ELEMENT_ID );
assert ( pEntity == CElementIDs::GetElement ( ID ) );
if ( pEntity->IsBeingDeleted () )
OutputDebugString ( SString ( "Server: 0x%08x %s is flagged as IsBeingDeleted() but is still in GetEntitiesFromRoot\n", pEntity, pEntity->GetTypeName ().c_str () ) );
assert ( mapResults.find ( pEntity ) == mapResults.end () );
mapResults [ pEntity ] = 1;
}
}
}
示例8: Callback_OnLeave
void CPickup::Callback_OnLeave ( CColShape& Shape, CElement& Element )
{
if ( IS_PLAYER ( &Element ) )
{
CPlayer& Player = static_cast < CPlayer& > ( Element );
// Matching interior
if ( GetInterior () == Element.GetInterior () )
{
// Matching dimension
if ( GetDimension () == Element.GetDimension () )
{
// Is he alive?
if ( !Player.IsDead () )
{
// Call the onPickupHit event
CLuaArguments Arguments;
Arguments.PushElement ( &Player );
CallEvent ( "onPickupLeave", Arguments );
CLuaArguments Arguments2;
Arguments2.PushElement ( this ); // pickup
Element.CallEvent ( "onPlayerPickupLeave", Arguments2 );
}
}
}
}
}
示例9: IsPlayerIgnoringElement
bool CPlayer::IsPlayerIgnoringElement( CElement* pElement )
{
// For each ignored element
for ( list < CElement* > ::const_iterator iter = m_lstIgnoredList.begin () ; iter != m_lstIgnoredList.end () ; ++iter )
{
CElement* pIgnoredElement = *iter;
if ( IS_TEAM ( pIgnoredElement ) )
{
// Check team
CTeam* pTeam = static_cast < CTeam* > ( pIgnoredElement );
// If the broadcast-to player is in the ignored team
list < CPlayer* > ::const_iterator iter = pTeam->PlayersBegin ();
for ( ; iter != pTeam->PlayersEnd (); iter++ )
{
if ( *iter == pElement )
return true;
}
}
else if ( IS_PLAYER( pIgnoredElement ) )
{
// Check player
if ( pIgnoredElement == pElement )
return true;
}
else
{
// Check element decendants
if ( pIgnoredElement->IsMyChild ( pElement , true ) )
return true;
}
}
return false;
}
示例10: TAG_METHOD_IMPL
TAG_METHOD_IMPL(CElementParser, OnComplexType)
{
TRACE_PARSE_ENTRY();
CElement * pCurr = GetElement();
if (pCurr != NULL)
{
CComplexType * pElem = pCurr->AddComplexType();
if (pElem != NULL)
{
SetXSDElementInfo(pElem, pCurr, GetLocator());
CAutoPtr<CComplexTypeParser> p( new CComplexTypeParser(GetReader(), this, GetLevel(), pElem) );
if (p != NULL)
{
if (g_ParserList.AddHead(p) != NULL)
{
return p.Detach()->GetAttributes(pAttributes);
}
}
}
}
EmitErrorHr(E_OUTOFMEMORY);
return E_FAIL;
}
示例11: Draw
void CCell::Draw(CDC *pDC)
{
POSITION pos;
CElement *pElement;
for(pos=m_Elements.GetHeadPosition();pos!=NULL;){
pElement=(CElement *)(m_Elements.GetNext(pos));
pElement->Draw(pDC);
}
}
示例12: MoveInCell
void CCell::MoveInCell(POINT potTracker)
{
POSITION pos;
CElement *pElement;
for(pos=m_Elements.GetHeadPosition();pos!=NULL;){
pElement=(CElement *)(m_Elements.GetNext(pos));
pElement->MoveInCell(potTracker);
}
}
示例13: UpdateView
void CCell::UpdateView()
{
POSITION pos;
CElement *pElement;
for(pos=m_Elements.GetHeadPosition();pos!=NULL;){
pElement=(CElement *)(m_Elements.GetNext(pos));
pElement->UpdateView();
}
}
示例14: FlushUpdateQueue
///////////////////////////////////////////////////////////////
//
// CSpatialDatabaseImpl::FlushUpdateQueue
//
// Process all entities that have changed since the last call
//
///////////////////////////////////////////////////////////////
void CSpatialDatabaseImpl::FlushUpdateQueue ( void )
{
int iTotalUpdated = 0;
for ( std::map < CElement*, int >::iterator it = m_UpdateQueue.begin (); it != m_UpdateQueue.end (); ++it )
{
CElement* pEntity = it->first;
// Get the new bounding box
SEntityInfo newInfo;
CSphere sphere = pEntity->GetWorldBoundingSphere ();
newInfo.box = CBox ( sphere.vecPosition, fabsf ( sphere.fRadius ) );
// Make everything 2D for now
newInfo.box.vecMin.fZ = SPATIAL_2D_Z;
newInfo.box.vecMax.fZ = SPATIAL_2D_Z;
// Get previous info
if ( SEntityInfo* pOldInfo = MapFind ( m_InfoMap, pEntity ) )
{
// Don't update if bounding box is the same
if ( pOldInfo->box == newInfo.box )
continue;
// Remove old bounding box from tree
m_Tree.Remove ( &pOldInfo->box.vecMin.fX, &pOldInfo->box.vecMax.fX, pEntity );
}
if ( !IsValidSphere ( sphere ) )
continue;
// Add new bounding box
m_Tree.Insert( &newInfo.box.vecMin.fX, &newInfo.box.vecMax.fX, pEntity );
// Update info map
MapSet ( m_InfoMap, pEntity, newInfo );
iTotalUpdated++;
#ifdef SPATIAL_DATABASE_DEBUG_OUTPUTA
OutputDebugLine ( SString ( "SpatialDatabase::UpdateEntity %08x %2.0f,%2.0f,%2.0f %2.0f,%2.0f,%2.0f"
,pEntity
,info.box.vecMin.fX
,info.box.vecMin.fY
,info.box.vecMin.fZ
,info.box.vecMax.fX
,info.box.vecMax.fY
,info.box.vecMax.fZ
) );
#endif
}
m_UpdateQueue.clear ();
#ifdef SPATIAL_DATABASE_DEBUG_OUTPUTB
int iTotalToUpdate = m_UpdateQueue.size ();
if ( iTotalToUpdate )
OutputDebugLine ( SString ( "SpatialDatabase::FlushUpdateQueue TotalToUpdate: %d TotalUpdated: %d m_InfoMap: %d tree: %d ", iTotalToUpdate, iTotalUpdated, m_InfoMap.size (), m_Tree.Count () ) );
#endif
}
示例15: switch
vector < char * > * CLuaArguments::WriteToCharVector ( vector < char * > * values )
{
vector < CLuaArgument* > ::const_iterator iter = m_Arguments.begin ();
for ( ; iter != m_Arguments.end () ; iter++ )
{
switch ( (*iter)->GetType() )
{
case LUA_TNUMBER:
{
char * szValue = new char [ 20 ];
itoa ( ( int ) (*iter)->GetNumber(), szValue, 10 );
values->push_back ( szValue );
break;
}
case LUA_TSTRING:
{
const char * szString = (*iter)->GetString().c_str ();
char * szValue = new char [ strlen ( szString ) + 1 ];
strcpy ( szValue, szString );
values->push_back ( szValue );
break;
}
case LUA_TBOOLEAN:
{
char * szValue = new char [ 6 ];
if ( (*iter)->GetBoolean() )
values->push_back ( strcpy ( szValue, "true" ) );
else
values->push_back ( strcpy ( szValue, "false" ) );
break;
}
case LUA_TLIGHTUSERDATA:
{
char * szValue = new char [10];
memset(szValue,0,10);
CElement* pElement = (*iter)->GetElement ();
if ( VERIFY_ELEMENT(pElement) )
{
_snprintf ( szValue, 9, "E#%d", (int)pElement->GetID() );
}
else
{
g_pGame->GetScriptDebugging()->LogError ( NULL, "Couldn't serialize argument list, invalid element specified. Passing empty string instead." );
}
values->push_back ( szValue );
}
default:
{
char * szEmpty = new char [ 1 ];
szEmpty[0] = '\0';
values->push_back ( szEmpty );
}
}
}
return values;
}