void CClientThinkList::SetNextClientThink( ClientEntityHandle_t hEnt, float nextTime ) { if ( nextTime == CLIENT_THINK_NEVER ) { RemoveThinkable( hEnt ); } else { IClientThinkable *pThink = ClientEntityList().GetClientThinkableFromHandle( hEnt ); if ( pThink ) { ClientThinkHandle_t hThink = pThink->GetThinkHandle(); // Add it to the list if it's not already in there. if ( hThink == INVALID_THINK_HANDLE ) { hThink = (ClientThinkHandle_t)m_ThinkEntries.AddToTail(); pThink->SetThinkHandle( hThink ); GetThinkEntry( hThink )->m_hEnt = hEnt; } // Set the next think time.. GetThinkEntry( hThink )->m_flNextClientThink = nextTime; } } }
void CClientThinkList::RemoveThinkable( ClientEntityHandle_t hEnt ) { IClientThinkable *pThink = ClientEntityList().GetClientThinkableFromHandle( hEnt ); if ( pThink ) { ClientThinkHandle_t hThink = pThink->GetThinkHandle(); // It will never think so make sure it's NOT in the list. if ( hThink != INVALID_THINK_HANDLE ) { m_ThinkEntries.Remove( (unsigned long)hThink ); pThink->SetThinkHandle( INVALID_THINK_HANDLE ); } } }
void CClientThinkList::SetNextClientThink( ClientEntityHandle_t hEnt, float flNextTime ) { if ( flNextTime == CLIENT_THINK_NEVER ) { RemoveThinkable( hEnt ); return; } IClientThinkable *pThink = ClientEntityList().GetClientThinkableFromHandle( hEnt ); if ( !pThink ) return; ClientThinkHandle_t hThink = pThink->GetThinkHandle(); if ( m_bInThinkLoop ) { // Queue up all changes int i = m_aChangeList.AddToTail(); m_aChangeList[i].m_hEnt = hEnt; m_aChangeList[i].m_hThink = hThink; m_aChangeList[i].m_flNextTime = flNextTime; return; } // Add it to the list if it's not already in there. if ( hThink == INVALID_THINK_HANDLE ) { hThink = (ClientThinkHandle_t)m_ThinkEntries.AddToTail(); pThink->SetThinkHandle( hThink ); ThinkEntry_t *pEntry = GetThinkEntry( hThink ); pEntry->m_hEnt = hEnt; pEntry->m_nIterEnum = -1; pEntry->m_flLastClientThink = 0.0f; } Assert( GetThinkEntry( hThink )->m_hEnt == hEnt ); GetThinkEntry( hThink )->m_flNextClientThink = flNextTime; }
//----------------------------------------------------------------------------- // Removes the thinkable from the list //----------------------------------------------------------------------------- void CClientThinkList::RemoveThinkable( ClientThinkHandle_t hThink ) { if ( hThink == INVALID_THINK_HANDLE ) return; if ( m_bInThinkLoop ) { // Queue up all changes int i = m_aChangeList.AddToTail(); m_aChangeList[i].m_hEnt = INVALID_CLIENTENTITY_HANDLE; m_aChangeList[i].m_hThink = hThink; m_aChangeList[i].m_flNextTime = CLIENT_THINK_NEVER; return; } ThinkEntry_t *pEntry = GetThinkEntry( hThink ); IClientThinkable *pThink = ClientEntityList().GetClientThinkableFromHandle( pEntry->m_hEnt ); if ( pThink ) { pThink->SetThinkHandle( INVALID_THINK_HANDLE ); } m_ThinkEntries.Remove( (unsigned long)hThink ); }