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


C++ CUtlVector::Element方法代码示例

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


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

示例1: ResizeAnimationLayerCallback

void ResizeAnimationLayerCallback( void *pStruct, int offsetToUtlVector, int len )
{
	C_BaseAnimatingOverlay *pEnt = (C_BaseAnimatingOverlay*)pStruct;
	CUtlVector < CAnimationLayer > *pVec = &pEnt->m_AnimOverlay;
	CUtlVector< CInterpolatedVar< CAnimationLayer > > *pVecIV = &pEnt->m_iv_AnimOverlay;
	
	Assert( (char*)pVec - (char*)pEnt == offsetToUtlVector );
	Assert( pVec->Count() == pVecIV->Count() );
	Assert( pVec->Count() <= C_BaseAnimatingOverlay::MAX_OVERLAYS );
	
	int diff = len - pVec->Count();
	if ( diff != 0 )
	{
		// remove all entries
		for ( int i=0; i < pVec->Count(); i++ )
		{
			pEnt->RemoveVar( &pVec->Element( i ) );
		}

		pEnt->InvalidatePhysicsRecursive( BOUNDS_CHANGED );

		// adjust vector sizes
		if ( diff > 0 )
		{
			for ( int i = 0; i < diff; ++i )
			{
				int j = pVec->AddToTail( );
				(*pVec)[j].SetOwner( pEnt );
			}
			pVecIV->AddMultipleToTail( diff );
		}
		else
		{
			pVec->RemoveMultiple( len, -diff );
			pVecIV->RemoveMultiple( len, -diff );
		}

		// Rebind all the variables in the ent's list.
		for ( int i=0; i < len; i++ )
		{
			IInterpolatedVar *pWatcher = &pVecIV->Element( i );
			pWatcher->SetDebugName( s_m_iv_AnimOverlayNames[i] );
			pEnt->AddVar( &pVec->Element( i ), pWatcher, LATCH_ANIMATION_VAR, true );
		}
	}

	// FIXME: need to set historical values of nOrder in pVecIV to MAX_OVERLAY

	// Ensure capacity
	pVec->EnsureCapacity( len );

	int nNumAllocated = pVec->NumAllocated();

	// This is important to do because EnsureCapacity doesn't actually call the constructors
	// on the elements, but we need them to be initialized, otherwise it'll have out-of-range
	// values which will piss off the datatable encoder.
	UtlVector_InitializeAllocatedElements( pVec->Base() + pVec->Count(), nNumAllocated - pVec->Count() );
}
开发者ID:Cre3per,项目名称:hl2sdk-csgo,代码行数:58,代码来源:c_baseanimatingoverlay.cpp

示例2: Execute

void CTilegenAction_ChooseCandidate::Execute( CLayoutSystem *pLayoutSystem )
{
	CUtlVector< CRoomCandidate > *pRoomCandidateList = pLayoutSystem->GetRoomCandidateList();
	if ( pRoomCandidateList->Count() == 0 )
	{
		Log_Msg( LOG_TilegenLayoutSystem, "No more room candidates to choose from.\n" );
		pLayoutSystem->GetFreeVariables()->SetOrCreateFreeVariable( "ChoseCandidate", ( void * )0 );
		return;
	}

	int i;
	float flChance = 0.0f;
	for ( i = 0; i < pRoomCandidateList->Count(); ++ i )
	{
		flChance += pRoomCandidateList->Element( i ).m_flCandidateChance;
	}

	float flRandom = pLayoutSystem->GetRandomFloat( 0.0f, 1.0f ) * flChance;

	for ( i = 0; i < pRoomCandidateList->Count(); ++ i )
	{
		flRandom -= pRoomCandidateList->Element( i ).m_flCandidateChance;
		if ( flRandom <= 0.0f )
		{
			break;
		}
	}
	
	if ( i == pRoomCandidateList->Count() ) 
	{
		i = pRoomCandidateList->Count() - 1;
	}
	
	const CRoomCandidate *pCandidate = &pRoomCandidateList->Element( i );

	// This should always succeed since it's in the candidate list to begin with
	bool bSuccess = pLayoutSystem->TryPlaceRoom( pCandidate );
	Assert( bSuccess );
	bSuccess;
	Log_Msg( LOG_TilegenLayoutSystem, "Chose room candidate %s at position (%d, %d).\n", pCandidate->m_pRoomTemplate->GetFullName(), pCandidate->m_iXPos, pCandidate->m_iYPos );
	
	// Empty the room candidate list for future actions
	pRoomCandidateList->RemoveAll();

	if ( m_bStopProcessingActionsOnSuccess )
	{
		pLayoutSystem->StopProcessingActions();
	}

	pLayoutSystem->GetFreeVariables()->SetOrCreateFreeVariable( "ChoseCandidate", ( void * )1 );
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:51,代码来源:tilegen_actions.cpp

示例3: SetupNetworkTablesRelease

bool SetupNetworkTablesRelease()
{
	if( g_SetupNetworkTablesOnHold == false )
		return false;
	g_SetupNetworkTablesOnHold = false;

	// Setup all tables and update all clients
	PyServerClass *p = g_pPyServerClassHead;
	while( p )
	{
		if( p->m_pNetworkedClass )
			p->m_pNetworkedClass->SetupServerClass();
		p = p->m_pPyNext;
	}

	// Release on hold
	for( int i=0; i<g_SetupNetworkTablesOnHoldList.Count(); i++ )
	{
		EntityInfoOnHold info = (g_SetupNetworkTablesOnHoldList.Element(i));
		info.ent->NetworkProp()->AttachEdict( info.edict );
		info.ent->edict()->m_pNetworkable = info.ent->NetworkProp();
		info.ent->SetTransmitState(FL_FULL_EDICT_CHANGED|FL_EDICT_DIRTY_PVS_INFORMATION);
		info.ent->DispatchUpdateTransmitState();
	}
	g_SetupNetworkTablesOnHoldList.RemoveAll();
	return true;
}
开发者ID:detoxhby,项目名称:lambdawars,代码行数:27,代码来源:srcpy_server_class.cpp

示例4: OverlayTransition_EmitOverlayFaces

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void OverlayTransition_EmitOverlayFaces( void )
{
	int nMapOverlayCount = g_aMapWaterOverlays.Count();
	for( int iMapOverlay = 0; iMapOverlay < nMapOverlayCount; ++iMapOverlay )
	{
		OverlayTransition_EmitOverlayFace( &g_aMapWaterOverlays.Element( iMapOverlay ) );
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:11,代码来源:overlay.cpp

示例5: ResizeAnimationLayerCallback

void ResizeAnimationLayerCallback( void *pStruct, int offsetToUtlVector, int len )
{
	C_BaseAnimatingOverlay *pEnt = (C_BaseAnimatingOverlay*)pStruct;
	CUtlVector < C_AnimationLayer > *pVec = &pEnt->m_AnimOverlay;
	CUtlVector< CInterpolatedVar< C_AnimationLayer > > *pVecIV = &pEnt->m_iv_AnimOverlay;
	
	Assert( (char*)pVec - (char*)pEnt == offsetToUtlVector );
	Assert( pVec->Count() == pVecIV->Count() );
	Assert( pVec->Count() <= C_BaseAnimatingOverlay::MAX_OVERLAYS );
	
	int diff = len - pVec->Count();

	

	if ( diff == 0 )
		return;

	// remove all entries
	for ( int i=0; i < pVec->Count(); i++ )
	{
		pEnt->RemoveVar( &pVec->Element( i ) );
	}

	// adjust vector sizes
	if ( diff > 0 )
	{
		pVec->AddMultipleToTail( diff );
		pVecIV->AddMultipleToTail( diff );
	}
	else
	{
		pVec->RemoveMultiple( len, -diff );
		pVecIV->RemoveMultiple( len, -diff );
	}

	// Rebind all the variables in the ent's list.
	for ( int i=0; i < len; i++ )
	{
		IInterpolatedVar *pWatcher = &pVecIV->Element( i );
		pWatcher->SetDebugName( s_m_iv_AnimOverlayNames[i] );
		pEnt->AddVar( &pVec->Element( i ), pWatcher, LATCH_ANIMATION_VAR, true );
	}
	// FIXME: need to set historical values of nOrder in pVecIV to MAX_OVERLAY
	
}
开发者ID:TotallyMehis,项目名称:ZM-Updated,代码行数:45,代码来源:c_baseanimatingoverlay.cpp

示例6: ClearAllShakes

//-----------------------------------------------------------------------------
// Purpose: Zeros out all active screen shakes.
//-----------------------------------------------------------------------------
void CViewEffects::ClearAllShakes()
{
	int nShakeCount = m_ShakeList.Count();
	for ( int i = 0; i < nShakeCount; i++ )
	{
		delete m_ShakeList.Element( i );
	}

	m_ShakeList.Purge();
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:13,代码来源:view_effects.cpp

示例7: Templates_RemoveAll

//-----------------------------------------------------------------------------
// Purpose: Frees all the template data. Called on level shutdown.
//-----------------------------------------------------------------------------
void Templates_RemoveAll(void)
{
	int nCount = g_Templates.Count();
	for (int i = 0; i < nCount; i++)
	{
		TemplateEntityData_t *pTemplate = g_Templates.Element(i);
		Templates_FreeTemplate( pTemplate );
	}

	g_Templates.RemoveAll();
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:14,代码来源:TemplateEntities.cpp

示例8: TraceAgainstRayTraceEnv

void CParticleSystemQuery::TraceAgainstRayTraceEnv( int envnumber, const FourRays &rays, fltx4 TMin, fltx4 TMax,
													  RayTracingResult *rslt_out, int32 skip_id ) const
{
#if defined( CLIENT_DLL )
	if ( g_RayTraceEnvironments.IsValidIndex( envnumber ) )
	{
		RayTracingEnvironment *RtEnv = g_RayTraceEnvironments.Element( envnumber );
		RtEnv->Trace4Rays( rays, TMin, TMax, rslt_out, skip_id );
	}
#endif
}
开发者ID:gamenew09,项目名称:SourceSDK2010,代码行数:11,代码来源:particlesystemquery.cpp

示例9: Templates_FindByTargetName

//-----------------------------------------------------------------------------
// Purpose: Looks up a template entity by name, returning the map data blob as
//			a null-terminated string containing key/value pairs.
//			NOTE: This can't handle multiple templates with the same targetname.
//-----------------------------------------------------------------------------
string_t Templates_FindByTargetName(const char *pszName)
{
	int nCount = g_Templates.Count();
	for (int i = 0; i < nCount; i++)
	{
		TemplateEntityData_t *pTemplate = g_Templates.Element(i);
		if ( !stricmp(pTemplate->pszName, pszName) )
			return Templates_FindByIndex( i );
	}

	return NULL_STRING;
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:17,代码来源:TemplateEntities.cpp

示例10:

CEffectScriptElement *CEnvEffectsScript::GetScriptElementByName( const char *pName )
{
	for ( int i = 0; i < m_ScriptElements.Count(); i++ )
	{
		CEffectScriptElement *pCurrent = &m_ScriptElements.Element( i );

		if ( pCurrent && !Q_stricmp( pCurrent->m_szEffectName, pName ) ) 
		{
			return pCurrent;
		}
	}

	return NULL;
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:14,代码来源:env_effectsscript.cpp

示例11: OverlayTransition_AddFaceToLists

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void OverlayTransition_AddFaceToLists( int iFace, side_t *pSide )
{
	int nOverlayIdCount = pSide->aWaterOverlayIds.Count();
	for( int iOverlayId = 0; iOverlayId < nOverlayIdCount; ++iOverlayId )
	{
		mapoverlay_t *pMapOverlay = &g_aMapWaterOverlays.Element( pSide->aWaterOverlayIds[iOverlayId] - ( MAX_MAP_OVERLAYS + 1 ) );
		if ( pMapOverlay )
		{
			if( pMapOverlay->aFaceList.Find( iFace ) == -1 )
			{
				pMapOverlay->aFaceList.AddToTail( iFace );
			}
		}
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:17,代码来源:overlay.cpp

示例12: Overlay_AddFaceToLists

//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void Overlay_AddFaceToLists( int iFace, side_t *pSide )
{
	int nOverlayIdCount = pSide->aOverlayIds.Count();
	for( int iOverlayId = 0; iOverlayId < nOverlayIdCount; ++iOverlayId )
	{
		mapoverlay_t *pMapOverlay = &g_aMapOverlays.Element( pSide->aOverlayIds[iOverlayId] );
		if ( pMapOverlay )
		{
			if( pMapOverlay->aFaceList.Find( iFace ) == -1 )
			{
				pMapOverlay->aFaceList.AddToTail( iFace );
			}
		}
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:17,代码来源:overlay.cpp

示例13:

//-----------------------------------------------------------------------------
// Purpose: Returns the shake with the longest duration. This is the shake we
//			use anytime we get an amplitude or frequency command, because the
//			most likely case is that we're modifying a shake with a long
//			duration rather than a brief shake caused by an explosion, etc.
//-----------------------------------------------------------------------------
screenshake_t *CViewEffects::FindLongestShake()
{
	screenshake_t *pLongestShake = NULL;

	int nShakeCount = m_ShakeList.Count();
	for ( int i = 0; i < nShakeCount; i++ )
	{
		screenshake_t *pShake = m_ShakeList.Element( i );
		if ( pShake && ( !pLongestShake || ( pShake->duration > pLongestShake->duration ) ) )
		{
			pLongestShake = pShake;
		}
	}

	return pLongestShake;
}
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:22,代码来源:view_effects.cpp

示例14: ThreadComputeLeafAmbient

static void ThreadComputeLeafAmbient( int iThread, void *pUserData )
{
	CUtlVector<ambientsample_t> list;
	while (1)
	{
		int leafID = GetThreadWork ();
		if (leafID == -1)
			break;
		list.RemoveAll();
		ComputeAmbientForLeaf(iThread, leafID, list);
		// copy to the output array
		g_LeafAmbientSamples[leafID].SetCount( list.Count() );
		for ( int i = 0; i < list.Count(); i++ )
		{
			g_LeafAmbientSamples[leafID].Element(i) = list.Element(i);
		}
	}
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:18,代码来源:leaf_ambient_lighting.cpp

示例15: SaveItem

    bool SaveItem(specialitemload_t const &item)
    {
        unsigned long long profileid = item.steamid.ConvertToUint64();

        item.itemmutex->Lock();
        unsigned int index = item.itemlist->Find(profileid);
        if(item.itemlist->IsValidIndex(index))
        {
            char query[1024];
            char petname[512];

            CUtlVector<CSpecialItem *> *items = item.itemlist->Element(index);
            item.itemmutex->Unlock();

            //Msg("[ITEMDBG] Saving/deleting old item list.\n");
            for(int i = 0; i < items->Count(); i++)
            {
                //Msg("[ITEMDBG]  - Saving/deleting item %i\n", i);
                item.itemmutex->Lock();
                CSpecialItem *olditem = items->Element(i);

                m_SQL->EscapeString(petname, olditem->m_szPetName, strlen(olditem->m_szPetName));
                
                V_snprintf(query, sizeof(query), "UPDATE `specialitems` SET `petname` = '%s', `equipped` = %i WHERE `id` = %i LIMIT 1", petname, olditem->m_bEquipped, olditem->m_iIndex);
                item.itemmutex->Unlock();
                //Msg("[ITEMDBG] %s\n", query);
                m_SQL->Query(query);
                
                delete olditem->m_pItem;
                delete olditem;
            }

            item.itemmutex->Lock();
            item.itemlist->RemoveAt(index);
            item.itemmutex->Unlock();
            delete items;
        }
        else
        {
            item.itemmutex->Unlock();
        }

        return true;
    }
开发者ID:apaloma,项目名称:sourceop,代码行数:44,代码来源:specialitems.cpp


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