//----------------------------------------------------------------------------- // Purpose: Called after all entities have spawned and after a load game. // Finds the reference point at which to measure sound level. //----------------------------------------------------------------------------- void CEnvMicrophone::Activate(void) { BaseClass::Activate(); // Get a handle to my filter entity if there is one if (m_iszListenFilter != NULL_STRING) { m_hListenFilter = dynamic_cast<CBaseFilter *>(gEntList.FindEntityByName( NULL, m_iszListenFilter )); } if (m_target != NULL_STRING) { m_hMeasureTarget = gEntList.FindEntityByName(NULL, STRING(m_target) ); // // If we were given a bad measure target, just measure sound where we are. // if ((m_hMeasureTarget == NULL) || (m_hMeasureTarget->edict() == NULL)) { // We've decided to disable this warning since this seems to be the 90% case. //Warning( "EnvMicrophone - Measure target not found or measure target with no origin. Using Self.!\n"); m_hMeasureTarget = this; } } else { m_hMeasureTarget = this; } ActivateSpeaker(); }
void CEnvMicrophone::SetSpeakerName( string_t iszSpeakerName ) { m_iszSpeakerName = iszSpeakerName; // Set the speaker to null. This will force it to find the speaker next time a sound is routed. m_hSpeaker = NULL; ActivateSpeaker(); }
//----------------------------------------------------------------------------- // Purpose: // Input : &inputdata - //----------------------------------------------------------------------------- void CEnvMicrophone::InputSetSpeakerName( inputdata_t &inputdata ) { m_iszSpeakerName = inputdata.value.StringID(); // Set the speaker to null. This will force it to find the speaker next time a sound is routed. m_hSpeaker = NULL; ActivateSpeaker(); }
//----------------------------------------------------------------------------- // Purpose: Stops the microphone from sampling the sound level and firing the // SoundLevel output. //----------------------------------------------------------------------------- void CEnvMicrophone::InputEnable( inputdata_t &inputdata ) { if (m_bDisabled) { m_bDisabled = false; SetNextThink( gpGlobals->curtime + 0.1f ); ActivateSpeaker(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CEnvMicrophone::OnRestore( void ) { BaseClass::OnRestore(); ActivateSpeaker(); }