Team Fortress 2 Source Code as on 22/4/2020
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.

116 lines
2.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef SOUNDSCAPE_H
  7. #define SOUNDSCAPE_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. class CEnvSoundscape;
  12. struct ss_update_t
  13. {
  14. CBasePlayer *pPlayer;
  15. CEnvSoundscape *pCurrentSoundscape;
  16. Vector playerPosition;
  17. float currentDistance;
  18. int traceCount;
  19. bool bInRange;
  20. };
  21. class CEnvSoundscape : public CPointEntity
  22. {
  23. public:
  24. DECLARE_CLASS( CEnvSoundscape, CPointEntity );
  25. DECLARE_DATADESC();
  26. CEnvSoundscape();
  27. ~CEnvSoundscape();
  28. bool KeyValue( const char *szKeyName, const char *szValue );
  29. void Spawn( void );
  30. void Precache( void );
  31. void UpdateForPlayer( ss_update_t &update );
  32. void WriteAudioParamsTo( audioparams_t &audio );
  33. virtual int UpdateTransmitState();
  34. bool InRangeOfPlayer( CBasePlayer *pPlayer );
  35. void DrawDebugGeometryOverlays( void );
  36. void InputEnable( inputdata_t &inputdata );
  37. void InputDisable( inputdata_t &inputdata );
  38. void InputToggleEnabled( inputdata_t &inputdata );
  39. string_t GetSoundscapeName() const {return m_soundscapeName;}
  40. private:
  41. bool IsEnabled( void ) const;
  42. void Disable( void );
  43. void Enable( void );
  44. public:
  45. COutputEvent m_OnPlay;
  46. float m_flRadius;
  47. string_t m_soundscapeName;
  48. int m_soundscapeIndex;
  49. int m_soundscapeEntityId;
  50. string_t m_positionNames[NUM_AUDIO_LOCAL_SOUNDS];
  51. // If this is set, then this soundscape ignores all its parameters and uses
  52. // those of this soundscape.
  53. CHandle<CEnvSoundscape> m_hProxySoundscape;
  54. private:
  55. bool m_bDisabled;
  56. };
  57. class CEnvSoundscapeProxy : public CEnvSoundscape
  58. {
  59. public:
  60. DECLARE_CLASS( CEnvSoundscapeProxy, CEnvSoundscape );
  61. DECLARE_DATADESC();
  62. CEnvSoundscapeProxy();
  63. virtual void Activate();
  64. // Here just to stop it falling back to CEnvSoundscape's, and
  65. // printing bogus errors about missing soundscapes.
  66. virtual void Precache() { return; }
  67. private:
  68. string_t m_MainSoundscapeName;
  69. };
  70. class CEnvSoundscapeTriggerable : public CEnvSoundscape
  71. {
  72. friend class CTriggerSoundscape;
  73. public:
  74. DECLARE_CLASS( CEnvSoundscapeTriggerable, CEnvSoundscape );
  75. DECLARE_DATADESC();
  76. CEnvSoundscapeTriggerable();
  77. // Overrides the base class's think and prevents it from running at all.
  78. virtual void Think();
  79. private:
  80. // Passed through from CTriggerSoundscape.
  81. void DelegateStartTouch( CBaseEntity *pEnt );
  82. void DelegateEndTouch( CBaseEntity *pEnt );
  83. };
  84. #endif // SOUNDSCAPE_H