Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.0 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef VOICE_GAMEMGR_H
  8. #define VOICE_GAMEMGR_H
  9. #pragma once
  10. #include "voice_common.h"
  11. class CGameRules;
  12. class CBasePlayer;
  13. abstract_class IVoiceGameMgrHelper
  14. {
  15. public:
  16. virtual ~IVoiceGameMgrHelper() {}
  17. // Called each frame to determine which players are allowed to hear each other. This overrides
  18. // whatever squelch settings players have.
  19. virtual bool CanPlayerHearPlayer(CBasePlayer *pListener, CBasePlayer *pTalker, bool &bProximity ) = 0;
  20. };
  21. // CVoiceGameMgr manages which clients can hear which other clients.
  22. class CVoiceGameMgr
  23. {
  24. public:
  25. CVoiceGameMgr();
  26. virtual ~CVoiceGameMgr();
  27. bool Init(
  28. IVoiceGameMgrHelper *m_pHelper,
  29. int maxClients
  30. );
  31. void SetHelper(IVoiceGameMgrHelper *pHelper);
  32. // Updates which players can hear which other players.
  33. // If gameplay mode is DM, then only players within the PVS can hear each other.
  34. // If gameplay mode is teamplay, then only players on the same team can hear each other.
  35. // Player masks are always applied.
  36. void Update(double frametime);
  37. // Called when a new client connects (unsquelches its entity for everyone).
  38. void ClientConnected(struct edict_t *pEdict);
  39. // Called on ClientCommand. Checks for the squelch and unsquelch commands.
  40. // Returns true if it handled the command.
  41. bool ClientCommand(CBasePlayer *pPlayer, const CCommand &args );
  42. bool CheckProximity( int iDistance );
  43. void SetProximityDistance( int iDistance );
  44. bool IsPlayerIgnoringPlayer( int iTalker, int iListener );
  45. private:
  46. // Force it to update the client masks.
  47. void UpdateMasks();
  48. private:
  49. IVoiceGameMgrHelper *m_pHelper;
  50. int m_nMaxPlayers;
  51. double m_UpdateInterval; // How long since the last update.
  52. int m_iProximityDistance;
  53. };
  54. // Use this to access CVoiceGameMgr.
  55. CVoiceGameMgr* GetVoiceGameMgr();
  56. #endif // VOICE_GAMEMGR_H