本文整理汇总了C++中CUtlVector::IsValidIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ CUtlVector::IsValidIndex方法的具体用法?C++ CUtlVector::IsValidIndex怎么用?C++ CUtlVector::IsValidIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtlVector
的用法示例。
在下文中一共展示了CUtlVector::IsValidIndex方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TalkingThink
//-----------------------------------------------------------------------------
// Purpose: Start playing personality VO list
//-----------------------------------------------------------------------------
void CPropGladosCore::TalkingThink( void )
{
if ( m_speechEvents.Count() <= 0 || !m_speechEvents.IsValidIndex( m_iSpeechIter ) )
{
SetThink ( NULL );
SetNextThink( gpGlobals->curtime );
return;
}
// Loop the 'look around' animation after the first line.
int iCurSequence = GetSequence();
int iLookSequence = LookupSequence( STRING(m_iszLookAnimationName) );
if ( iCurSequence != iLookSequence && m_iSpeechIter > 0 )
{
ResetSequence( iLookSequence );
}
int iPrevIter = m_iSpeechIter-1;
if ( iPrevIter < 0 )
iPrevIter = 0;
StopSound( m_speechEvents[iPrevIter].ToCStr() );
float flCurDuration = GetSoundDuration( m_speechEvents[m_iSpeechIter].ToCStr(), GLADOS_CORE_MODEL_NAME );
EmitSound( m_speechEvents[m_iSpeechIter].ToCStr() );
SetNextThink( gpGlobals->curtime + m_flBetweenVOPadding + flCurDuration );
// wrap if we hit the end of the list
m_iSpeechIter = (m_iSpeechIter+1)%m_speechEvents.Count();
}
示例2: StartTalking
void CPropGladosCore::StartTalking( float flDelay )
{
if ( m_speechEvents.IsValidIndex( m_iSpeechIter ) && m_speechEvents.Count() > 0 )
{
StopSound( m_speechEvents[m_iSpeechIter].ToCStr() );
}
m_iSpeechIter = 0;
SetThink( &CPropGladosCore::TalkingThink );
SetNextThink( gpGlobals->curtime + m_flBetweenVOPadding + flDelay );
}
示例3: 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
}
示例4: RemoveCore
void CPhysicsMotionController::RemoveCore( IVP_Core *pCore )
{
int index = m_coreList.Find(pCore);
if ( !m_coreList.IsValidIndex(index) )
{
#if DEBUG
Msg("removed invalid core !!!\n");
#endif
return;
}
m_coreList.Remove( index );
pCore->rem_core_controller( static_cast<IVP_Controller_Independent *>(this) );
}
示例5: PanicThink
//-----------------------------------------------------------------------------
// Purpose: Play panic vo and animations, then return to talking
// Output :
//-----------------------------------------------------------------------------
void CPropGladosCore::PanicThink ( void )
{
if ( m_speechEvents.Count() <= 0 || !m_speechEvents.IsValidIndex( m_iSpeechIter ) || m_iszPanicSoundScriptName == NULL_STRING )
{
SetThink ( NULL );
SetNextThink( gpGlobals->curtime );
return;
}
StopSound( m_speechEvents[m_iSpeechIter].ToCStr() );
EmitSound( m_iszPanicSoundScriptName.ToCStr() );
float flCurDuration = GetSoundDuration( m_iszPanicSoundScriptName.ToCStr(), GLADOS_CORE_MODEL_NAME );
SetThink( &CPropGladosCore::TalkingThink );
SetNextThink( gpGlobals->curtime + m_flBetweenVOPadding + flCurDuration );
}
示例6: AttachObject
void CPhysicsMotionController::AttachObject( IPhysicsObject *pObject )
{
Assert(pObject);
// BUGBUG: Sometimes restore comes back with a NULL, REVISIT
if ( !pObject || pObject->IsStatic() )
return;
CPhysicsObject *pPhys = static_cast<CPhysicsObject *>(pObject);
IVP_Real_Object *pIVP = pPhys->GetObject();
IVP_Core *pCore = pIVP->get_core();
#if DEBUG
int index = m_coreList.Find(pCore);
if ( m_coreList.IsValidIndex(index) )
{
Msg("Attached core twice!!!\n");
return;
}
#endif
m_coreList.AddToTail( pCore );
pCore->add_core_controller( (IVP_Controller *)this );
}
示例7: PlayGameStartupSound
//-----------------------------------------------------------------------------
// Purpose: Searches for GameStartup*.mp3 files in the sound/ui folder and plays one
//-----------------------------------------------------------------------------
void CGameUI::PlayGameStartupSound()
{
#if defined( LEFT4DEAD )
// L4D not using this path, L4D UI now handling with background menu movies
return;
#endif
if ( IsX360() )
return;
if ( CommandLine()->FindParm( "-nostartupsound" ) )
return;
FileFindHandle_t fh;
CUtlVector<char *> fileNames;
char path[ 512 ];
Q_snprintf( path, sizeof( path ), "sound/ui/gamestartup*.mp3" );
Q_FixSlashes( path );
char const *fn = g_pFullFileSystem->FindFirstEx( path, "MOD", &fh );
if ( fn )
{
do
{
char ext[ 10 ];
Q_ExtractFileExtension( fn, ext, sizeof( ext ) );
if ( !Q_stricmp( ext, "mp3" ) )
{
char temp[ 512 ];
Q_snprintf( temp, sizeof( temp ), "ui/%s", fn );
char *found = new char[ strlen( temp ) + 1 ];
Q_strncpy( found, temp, strlen( temp ) + 1 );
Q_FixSlashes( found );
fileNames.AddToTail( found );
}
fn = g_pFullFileSystem->FindNext( fh );
} while ( fn );
g_pFullFileSystem->FindClose( fh );
}
// did we find any?
if ( fileNames.Count() > 0 )
{
SYSTEMTIME SystemTime;
GetSystemTime( &SystemTime );
int index = SystemTime.wMilliseconds % fileNames.Count();
if ( fileNames.IsValidIndex( index ) && fileNames[index] )
{
char found[ 512 ];
// escape chars "*#" make it stream, and be affected by snd_musicvolume
Q_snprintf( found, sizeof( found ), "play *#%s", fileNames[index] );
engine->ClientCmd_Unrestricted( found );
}
fileNames.PurgeAndDeleteElements();
}
}
示例8:
KeyValues *C_SoundscapeSystem::SoundscapeByIndex( int index )
{
if ( m_soundscapes.IsValidIndex(index) )
return m_soundscapes[index];
return NULL;
}
示例9: ActivateVguiScreen
//-----------------------------------------------------------------------------
//
// Look for vgui screens, returns true if it found one ...
//
//-----------------------------------------------------------------------------
C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &viewAngle, int nTeam )
{
if ( IsX360() )
{
// X360TBD: Turn this on if feature actually used
return NULL;
}
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
Assert( pLocalPlayer );
if ( !pLocalPlayer )
return NULL;
// Get the view direction...
Vector lookDir;
AngleVectors( viewAngle, &lookDir );
// Create a ray used for raytracing
Vector lookEnd;
VectorMA( viewPosition, 2.0f * VGUI_SCREEN_MODE_RADIUS, lookDir, lookEnd );
Ray_t lookRay;
lookRay.Init( viewPosition, lookEnd );
#ifndef C17
// Look for vgui screens that are close to the player
CVGuiScreenEnumerator localScreens;
partition->EnumerateElementsInSphere( PARTITION_CLIENT_NON_STATIC_EDICTS, viewPosition, VGUI_SCREEN_MODE_RADIUS, false, &localScreens );
#endif
Vector vecOut, vecViewDelta;
float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
#ifdef C17
for (int i = 0; i < g_pVGUIScreens.Count(); i++)
{
if (g_pVGUIScreens.IsValidIndex(i))
{
C_VGuiScreen *pScreen = g_pVGUIScreens[i];
#else
for (int i = localScreens.GetScreenCount(); --i >= 0; )
{
C_VGuiScreen *pScreen = localScreens.GetVGuiScreen(i);
#endif
if (pScreen->IsAttachedToViewModel())
continue;
// Don't bother with screens I'm behind...
// Hax - don't cancel backfacing with viewmodel attached screens.
// we can get prediction bugs that make us backfacing for one frame and
// it resets the mouse position if we lose focus.
if (pScreen->IsBackfacing(viewPosition))
continue;
// Don't bother with screens that are turned off
if (!pScreen->IsActive())
continue;
// FIXME: Should this maybe go into a derived class of some sort?
// Don't bother with screens on the wrong team
if (!pScreen->IsVisibleToTeam(nTeam))
continue;
if (!pScreen->AcceptsInput())
continue;
if (pScreen->IsInputOnlyToOwner() && pScreen->GetPlayerOwner() != pLocalPlayer)
continue;
// Test perpendicular distance from the screen...
pScreen->GetVectors(NULL, NULL, &vecOut);
VectorSubtract(viewPosition, pScreen->GetAbsOrigin(), vecViewDelta);
float flPerpDist = DotProduct(vecViewDelta, vecOut);
if ((flPerpDist < 0) || (flPerpDist > VGUI_SCREEN_MODE_RADIUS))
continue;
// Perform a raycast to see where in barycentric coordinates the ray hits
// the viewscreen; if it doesn't hit it, you're not in the mode
float u, v, t;
if (!pScreen->IntersectWithRay(lookRay, &u, &v, &t))
continue;
// Barycentric test
if ((u < 0) || (v < 0) || (u > 1) || (v > 1))
continue;
if (t < flBestDist)
{
flBestDist = t;
pBestScreen = pScreen;
}
//.........这里部分代码省略.........
示例10: DotProduct
//-----------------------------------------------------------------------------
//
// Look for vgui screens, returns true if it found one ...
//
//-----------------------------------------------------------------------------
C_BaseEntity *FindNearbyVguiScreen( const Vector &viewPosition, const QAngle &viewAngle, int nTeam )
{
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
Assert(pLocalPlayer);
if (!pLocalPlayer)
return NULL;
// Get the view direction...
Vector lookDir;
AngleVectors(viewAngle, &lookDir);
// Create a ray used for raytracing
Vector lookEnd;
VectorMA(viewPosition, 2.0f * VGUI_SCREEN_MODE_RADIUS, lookDir, lookEnd);
Ray_t lookRay;
lookRay.Init(viewPosition, lookEnd);
Vector vecOut, vecViewDelta;
float flBestDist = 2.0f;
C_VGuiScreen *pBestScreen = NULL;
for (int i = 0; i < g_pVGUIScreens.Count(); i++)
{
if (g_pVGUIScreens.IsValidIndex(i))
{
C_VGuiScreen *pScreen = g_pVGUIScreens[i];
if (pScreen->IsAttachedToViewModel())
continue;
// Don't bother with screens I'm behind...
// Hax - don't cancel backfacing with viewmodel attached screens.
// we can get prediction bugs that make us backfacing for one frame and
// it resets the mouse position if we lose focus.
if (pScreen->IsBackfacing(viewPosition))
continue;
// Don't bother with screens that are turned off
if (!pScreen->IsActive())
continue;
// FIXME: Should this maybe go into a derived class of some sort?
// Don't bother with screens on the wrong team
if (!pScreen->IsVisibleToTeam(nTeam))
continue;
if (!pScreen->AcceptsInput())
continue;
if (pScreen->IsInputOnlyToOwner() && pScreen->GetPlayerOwner() != pLocalPlayer)
continue;
// Test perpendicular distance from the screen...
pScreen->GetVectors(NULL, NULL, &vecOut);
VectorSubtract(viewPosition, pScreen->GetAbsOrigin(), vecViewDelta);
float flPerpDist = DotProduct(vecViewDelta, vecOut);
if ((flPerpDist < 0) || (flPerpDist > VGUI_SCREEN_MODE_RADIUS))
continue;
// Perform a raycast to see where in barycentric coordinates the ray hits
// the viewscreen; if it doesn't hit it, you're not in the mode
float u, v, t;
if (!pScreen->IntersectWithRay(lookRay, &u, &v, &t))
continue;
// Barycentric test
if ((u < 0) || (v < 0) || (u > 1) || (v > 1))
continue;
if (t < flBestDist)
{
flBestDist = t;
pBestScreen = pScreen;
}
}
}
return pBestScreen;
}