extensions/sdktools/vsound.h
author Scott Ehlert <ds@alliedmods.net>
Sun Sep 14 03:01:05 2008 -0500 (2008-09-14)
changeset 2289 44045ead61cd
parent 1952 b7aa2b626807
parent 1947 e73a1e51833b
child 3515 c14c14e06cc1
permissions -rw-r--r--
Eliminated head: da55a80522cf, a remnant of sourcemod-1.1.0 branch
faluco@1735
     1
/**
faluco@1735
     2
* vim: set ts=4 :
faluco@1735
     3
* =============================================================================
faluco@1735
     4
* SourceMod SDKTools Extension
ds@1947
     5
* Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
faluco@1735
     6
* =============================================================================
faluco@1735
     7
*
faluco@1735
     8
* This program is free software; you can redistribute it and/or modify it under
faluco@1735
     9
* the terms of the GNU General Public License, version 3.0, as published by the
faluco@1735
    10
* Free Software Foundation.
faluco@1735
    11
* 
faluco@1735
    12
* This program is distributed in the hope that it will be useful, but WITHOUT
faluco@1735
    13
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
faluco@1735
    14
* FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
faluco@1735
    15
* details.
faluco@1735
    16
*
faluco@1735
    17
* You should have received a copy of the GNU General Public License along with
faluco@1735
    18
* this program.  If not, see <http://www.gnu.org/licenses/>.
faluco@1735
    19
*
faluco@1735
    20
* As a special exception, AlliedModders LLC gives you permission to link the
faluco@1735
    21
* code of this program (as well as its derivative works) to "Half-Life 2," the
faluco@1735
    22
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
faluco@1735
    23
* by the Valve Corporation.  You must obey the GNU General Public License in
faluco@1735
    24
* all respects for all other code used.  Additionally, AlliedModders LLC grants
faluco@1735
    25
* this exception to all derivative works.  AlliedModders LLC defines further
faluco@1735
    26
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
faluco@1735
    27
* or <http://www.sourcemod.net/license.php>.
faluco@1735
    28
*
faluco@1735
    29
* Version: $Id$
faluco@1735
    30
*/
faluco@1735
    31
faluco@1735
    32
#ifndef _INCLUDE_SOURCEMOD_VSOUND_H_
faluco@1735
    33
#define _INCLUDE_SOURCEMOD_VSOUND_H_
faluco@1735
    34
faluco@1735
    35
#include <sh_list.h>
faluco@1735
    36
#include "extension.h"
faluco@1735
    37
#include "CellRecipientFilter.h"
faluco@1735
    38
faluco@1735
    39
#define NORMAL_SOUND_HOOK		0
faluco@1735
    40
#define AMBIENT_SOUND_HOOK		1
faluco@1735
    41
faluco@1735
    42
typedef SourceHook::List<IPluginFunction *>::iterator SoundHookIter;
faluco@1735
    43
faluco@1735
    44
class SoundHooks : public IPluginsListener
faluco@1735
    45
{
faluco@1735
    46
public: //IPluginsListener
faluco@1735
    47
	void OnPluginUnloaded(IPlugin *plugin);
faluco@1735
    48
public:
faluco@1735
    49
	void Initialize();
faluco@1735
    50
	void Shutdown();
faluco@1735
    51
	void AddHook(int type, IPluginFunction *pFunc);
faluco@1735
    52
	bool RemoveHook(int type, IPluginFunction *pFunc);
faluco@1735
    53
	void OnEmitAmbientSound(int entindex, const Vector &pos, const char *samp, float vol, 
faluco@1735
    54
		soundlevel_t soundlevel, int fFlags, int pitch, float delay);
faluco@1735
    55
	void OnEmitSound(IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample, float flVolume, 
faluco@1735
    56
		soundlevel_t iSoundlevel, int iFlags, int iPitch, const Vector *pOrigin, 
faluco@1735
    57
		const Vector *pDirection, CUtlVector<Vector> *pUtlVecOrigins, bool bUpdatePositions, 
faluco@1735
    58
		float soundtime, int speakerentity);
faluco@1735
    59
	void OnEmitSound2(IRecipientFilter& filter, int iEntIndex, int iChannel, const char *pSample, float flVolume, 
faluco@1735
    60
		float flAttenuation, int iFlags, int iPitch, const Vector *pOrigin, 
faluco@1735
    61
		const Vector *pDirection, CUtlVector<Vector> *pUtlVecOrigins, bool bUpdatePositions, 
faluco@1735
    62
		float soundtime, int speakerentity);
faluco@1735
    63
private:
faluco@1735
    64
	size_t _FillInPlayers(int *pl_array, IRecipientFilter *pFilter);
faluco@1735
    65
	void _IncRefCounter(int type);
faluco@1735
    66
	void _DecRefCounter(int type);
faluco@1735
    67
private:
faluco@1735
    68
	SourceHook::List<IPluginFunction *> m_AmbientFuncs;
faluco@1735
    69
	SourceHook::List<IPluginFunction *> m_NormalFuncs;
faluco@1735
    70
	size_t m_NormalCount;
faluco@1735
    71
	size_t m_AmbientCount;
faluco@1735
    72
};
faluco@1735
    73
faluco@1735
    74
extern SoundHooks s_SoundHooks;
faluco@1735
    75
faluco@1737
    76
#endif //_INCLUDE_SOURCEMOD_VSOUND_H_