thirstsoundhandler.c 996 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. class ThirstSoundHandlerBase extends SoundHandlerBase
  2. {
  3. override void Init()
  4. {
  5. m_Id = eSoundHandlers.THIRST;
  6. }
  7. }
  8. //---------------------------
  9. // Client
  10. //---------------------------
  11. class ThirstSoundHandlerClient extends ThirstSoundHandlerBase
  12. {
  13. const float SOUND_INTERVALS_LIGHT_MIN = 10;
  14. const float SOUND_INTERVALS_LIGHT_MAX = 30;
  15. float m_SoundTime;
  16. EffectSound m_Sound;
  17. override void Update()
  18. {
  19. if ( m_Player.GetMixedSoundStates() & eMixedSoundStates.THIRSTY )
  20. {
  21. ProcessSound();
  22. }
  23. }
  24. void ProcessSound()
  25. {
  26. if ( GetGame().GetTime() > m_SoundTime)
  27. {
  28. float offset_time = Math.RandomFloatInclusive(SOUND_INTERVALS_LIGHT_MIN, SOUND_INTERVALS_LIGHT_MAX) * 1000;
  29. m_SoundTime = GetGame().GetTime() + offset_time;
  30. PlaySound();
  31. }
  32. }
  33. void PlaySound()
  34. {
  35. m_Player.PlaySoundEventEx(EPlayerSoundEventID.THIRST);
  36. }
  37. }
  38. //---------------------------
  39. // Server
  40. //---------------------------
  41. class ThirstSoundHandlerServer extends ThirstSoundHandlerBase
  42. {
  43. }