upload "kind" alien swarm

This commit is contained in:
nillerusr
2023-10-03 17:23:56 +03:00
parent b7bd94c52e
commit 7d3c0d8b5a
4229 changed files with 462900 additions and 495155 deletions
+44 -4
View File
@@ -1,4 +1,4 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ====
//
// Purpose: Implements an entity that measures sound volume at a point in a map.
//
@@ -105,7 +105,7 @@ void CEnvMicrophone::Spawn(void)
m_flSensitivity = 10;
}
m_flSmoothFactor = clamp(m_flSmoothFactor, 0.f, 0.9f);
m_flSmoothFactor = clamp(m_flSmoothFactor, 0, 0.9);
if (!m_bDisabled)
{
@@ -278,7 +278,7 @@ bool CEnvMicrophone::CanHearSound(CSound *pSound, float &flVolume)
if (flDistance <= pSound->Volume() * m_flSensitivity)
{
flVolume = 1 - (flDistance / (pSound->Volume() * m_flSensitivity));
flVolume = clamp(flVolume, 0.f, 1.f);
flVolume = clamp(flVolume, 0, 1);
return true;
}
@@ -305,7 +305,7 @@ bool CEnvMicrophone::CanHearSound( int entindex, soundlevel_t soundlevel, float
CBaseEntity *pEntity = NULL;
if ( entindex )
{
pEntity = CBaseEntity::Instance( engine->PEntityOfEntIndex(entindex) );
pEntity = CBaseEntity::Instance( INDEXENT(entindex) );
}
// Cull out sounds except from specific entities
@@ -366,6 +366,11 @@ void CEnvMicrophone::SetSensitivity( float flSensitivity )
m_flSensitivity = flSensitivity;
}
void CEnvMicrophone::SetMaxRange( float flMaxRange )
{
m_flMaxRange = flMaxRange;
}
void CEnvMicrophone::SetSpeakerName( string_t iszSpeakerName )
{
m_iszSpeakerName = iszSpeakerName;
@@ -375,6 +380,17 @@ void CEnvMicrophone::SetSpeakerName( string_t iszSpeakerName )
ActivateSpeaker();
}
//--------------------------------------------------------------------------------------------------
// Same as above, but skips the speaker name lookup
//--------------------------------------------------------------------------------------------------
void CEnvMicrophone::SetSpeaker( string_t iszSpeakerName, EHANDLE hSpeaker )
{
m_iszSpeakerName = iszSpeakerName;
m_hSpeaker = hSpeaker;
ActivateSpeaker();
}
//-----------------------------------------------------------------------------
// Purpose: Listens for sounds and updates the value of the SoundLevel output.
//-----------------------------------------------------------------------------
@@ -512,6 +528,14 @@ MicrophoneResult_t CEnvMicrophone::SoundPlayed( int entindex, const char *soundn
return MicrophoneResult_Ok;
}
void CEnvMicrophone::SoundStopped( const char *soundname )
{
if ( m_hSpeaker )
{
CBaseEntity::StopSound( m_hSpeaker->entindex(), CHAN_STATIC, soundname, true );
}
}
//-----------------------------------------------------------------------------
// Purpose: Called by the sound system whenever a sound is played so that
@@ -558,3 +582,19 @@ bool CEnvMicrophone::OnSoundPlayed( int entindex, const char *soundname, soundle
return bSwallowed;
}
void CEnvMicrophone::OnSoundStopped( const char *soundname )
{
// Loop through all registered microphones and tell them which sound to stop
int iCount = s_Microphones.Count();
if ( iCount > 0 )
{
for ( int i = iCount - 1; i >= 0; i-- )
{
if ( s_Microphones[i] )
{
s_Microphones[i]->SoundStopped( soundname );
}
}
}
}