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.

137 lines
3.0 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef VEHICLE_SOUNDS_H
  7. #define VEHICLE_SOUNDS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vcollide_parse.h"
  12. //-----------------------------------------------------------------------------
  13. // Purpose:
  14. //-----------------------------------------------------------------------------
  15. enum vehiclesound
  16. {
  17. VS_SKID_FRICTION_LOW,
  18. VS_SKID_FRICTION_NORMAL,
  19. VS_SKID_FRICTION_HIGH,
  20. VS_ENGINE2_START,
  21. VS_ENGINE2_STOP,
  22. VS_MISC1,
  23. VS_MISC2,
  24. VS_MISC3,
  25. VS_MISC4,
  26. VS_NUM_SOUNDS,
  27. };
  28. extern const char *vehiclesound_parsenames[VS_NUM_SOUNDS];
  29. // This is a list of vehiclesounds to automatically stop when the vehicle's driver exits the vehicle
  30. #define NUM_SOUNDS_TO_STOP_ON_EXIT 4
  31. extern vehiclesound g_iSoundsToStopOnExit[NUM_SOUNDS_TO_STOP_ON_EXIT];
  32. //-----------------------------------------------------------------------------
  33. // Purpose:
  34. //-----------------------------------------------------------------------------
  35. struct vehicle_gear_t
  36. {
  37. DECLARE_DATADESC();
  38. float flMinSpeed;
  39. float flMaxSpeed;
  40. float flSpeedApproachFactor;
  41. };
  42. struct vehicle_crashsound_t
  43. {
  44. DECLARE_DATADESC();
  45. float flMinSpeed;
  46. float flMinDeltaSpeed;
  47. int gearLimit;
  48. string_t iszCrashSound;
  49. };
  50. enum sound_states
  51. {
  52. SS_NONE = 0,
  53. SS_SHUTDOWN,
  54. SS_SHUTDOWN_WATER,
  55. SS_START_WATER,
  56. SS_START_IDLE,
  57. SS_IDLE,
  58. SS_GEAR_0,
  59. SS_GEAR_1,
  60. SS_GEAR_2,
  61. SS_GEAR_3,
  62. SS_GEAR_4,
  63. SS_SLOWDOWN,
  64. SS_SLOWDOWN_HIGHSPEED, // not a real state, just a slot for state sounds
  65. SS_GEAR_0_RESUME,
  66. SS_GEAR_1_RESUME,
  67. SS_GEAR_2_RESUME,
  68. SS_GEAR_3_RESUME,
  69. SS_GEAR_4_RESUME,
  70. SS_TURBO,
  71. SS_REVERSE,
  72. SS_NUM_STATES,
  73. };
  74. //-----------------------------------------------------------------------------
  75. // Purpose:
  76. //-----------------------------------------------------------------------------
  77. struct vehiclesounds_t
  78. {
  79. void Init( void )
  80. {
  81. pGears.Purge();
  82. crashSounds.Purge();
  83. for ( int i = 0; i < VS_NUM_SOUNDS; i++ )
  84. {
  85. iszSound[i] = NULL_STRING;
  86. }
  87. for ( int i = 0; i < SS_NUM_STATES; i++ )
  88. {
  89. iszStateSounds[i] = NULL_STRING;
  90. minStateTime[i] = 0.0f;
  91. }
  92. }
  93. DECLARE_DATADESC();
  94. CUtlVector<vehicle_gear_t> pGears;
  95. CUtlVector<vehicle_crashsound_t> crashSounds;
  96. string_t iszSound[ VS_NUM_SOUNDS ];
  97. string_t iszStateSounds[SS_NUM_STATES];
  98. float minStateTime[SS_NUM_STATES];
  99. };
  100. //-----------------------------------------------------------------------------
  101. // Purpose: A KeyValues parse for vehicle sound blocks
  102. //-----------------------------------------------------------------------------
  103. class CVehicleSoundsParser : public IVPhysicsKeyHandler
  104. {
  105. public:
  106. CVehicleSoundsParser( void );
  107. virtual void ParseKeyValue( void *pData, const char *pKey, const char *pValue );
  108. virtual void SetDefaults( void *pData );
  109. private:
  110. // Index of the gear we're currently reading data into
  111. int m_iCurrentGear;
  112. int m_iCurrentState;
  113. int m_iCurrentCrashSound;
  114. };
  115. #endif // VEHICLE_SOUNDS_H