ambient_generic: Fixed triggers, networking and whatnot. Should behave a lot closer now
This commit is contained in:
parent
675ecc323c
commit
1397d9a533
1 changed files with 68 additions and 47 deletions
|
@ -16,12 +16,14 @@ enumflags
|
|||
AS_NOTTOGGLED
|
||||
};
|
||||
|
||||
class ambient_generic : CBaseTrigger {
|
||||
class ambient_generic:CBaseTrigger
|
||||
{
|
||||
string m_strActivePath;
|
||||
string m_strSoundPath;
|
||||
float m_flVolume;
|
||||
float m_flRadius;
|
||||
int m_iToggleSwitch;
|
||||
|
||||
float m_flPitch;
|
||||
int m_iLoop;
|
||||
|
||||
|
@ -30,10 +32,19 @@ class ambient_generic : CBaseTrigger {
|
|||
float m_flFadeIn;
|
||||
float m_flFadeOut;*/ // TODO: Do this in CSQC
|
||||
void() ambient_generic;
|
||||
|
||||
virtual void() Respawn;
|
||||
virtual void() UseNormal;
|
||||
virtual void() UseLoop;
|
||||
virtual float(entity, float) Network;
|
||||
};
|
||||
|
||||
static float ambient_generic::Network(entity ePEnt, float fChanged)
|
||||
float ambient_generic::Network(entity ePEnt, float fChanged)
|
||||
{
|
||||
if (!m_iToggleSwitch) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
WriteByte(MSG_ENTITY, ENT_AMBIENTSOUND);
|
||||
WriteCoord(MSG_ENTITY, origin[0]);
|
||||
WriteCoord(MSG_ENTITY, origin[1]);
|
||||
|
@ -45,6 +56,7 @@ static float ambient_generic::Network(entity ePEnt, float fChanged)
|
|||
WriteByte(MSG_ENTITY, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void ambient_generic::UseNormal(void)
|
||||
{
|
||||
sound(this, CHAN_VOICE, m_strActivePath, m_flVolume, m_flRadius, m_flPitch);
|
||||
|
@ -53,13 +65,36 @@ void ambient_generic::UseLoop( void )
|
|||
{
|
||||
if (m_iToggleSwitch == TRUE) {
|
||||
m_strActivePath = "common/null.wav";
|
||||
SendFlags = 128;
|
||||
m_iToggleSwitch = FALSE;
|
||||
} else {
|
||||
m_strActivePath = m_strSoundPath;
|
||||
SendFlags = 128;
|
||||
}
|
||||
m_iToggleSwitch = 1 - m_iToggleSwitch;
|
||||
SendFlags = 1;
|
||||
}
|
||||
|
||||
void ambient_generic::Respawn(void)
|
||||
{
|
||||
m_strActivePath = m_strSoundPath;
|
||||
|
||||
if (spawnflags & AS_NOTTOGGLED) {
|
||||
Trigger = UseNormal;
|
||||
m_iLoop = FALSE;
|
||||
} else {
|
||||
m_iLoop = TRUE;
|
||||
}
|
||||
|
||||
if (spawnflags & AS_SILENT) {
|
||||
m_iToggleSwitch = FALSE;
|
||||
} else {
|
||||
m_iToggleSwitch = TRUE;
|
||||
}
|
||||
|
||||
if (m_iLoop) {
|
||||
pvsflags = PVSF_IGNOREPVS;
|
||||
Trigger = UseLoop;
|
||||
SendEntity = Network;
|
||||
SendFlags = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void ambient_generic::ambient_generic (void)
|
||||
|
@ -110,20 +145,6 @@ void ambient_generic::ambient_generic ( void )
|
|||
m_flRadius = ATTN_STATIC;
|
||||
}
|
||||
|
||||
if ( spawnflags & AS_NOTTOGGLED ) {
|
||||
m_iLoop = FALSE;
|
||||
} else {
|
||||
m_iLoop = TRUE;
|
||||
}
|
||||
|
||||
if( spawnflags & AS_SILENT ) {
|
||||
Trigger = UseNormal;
|
||||
} else {
|
||||
pvsflags = PVSF_NOREMOVE | PVSF_IGNOREPVS;
|
||||
Trigger = UseLoop;
|
||||
SendEntity = Network;
|
||||
m_iToggleSwitch = FALSE;
|
||||
}
|
||||
|
||||
ambient_generic::Respawn();
|
||||
CBaseTrigger::CBaseTrigger();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue