infectedsoundeventbase.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. enum EInfectedSoundEventType
  2. {
  3. GENERAL,
  4. }
  5. class InfectedSoundEventBase extends SoundEventBase
  6. {
  7. ZombieBase m_Infected;
  8. void InfectedSoundEventBase()
  9. {
  10. m_Type = EInfectedSoundEventType.GENERAL;
  11. }
  12. void ~InfectedSoundEventBase()
  13. {
  14. if (m_SoundSetCallback) m_SoundSetCallback.Stop();
  15. }
  16. void Init(ZombieBase pInfected)
  17. {
  18. m_Infected = pInfected;
  19. }
  20. void SoftStop()
  21. {
  22. if (m_SoundSetCallback)
  23. {
  24. m_SoundSetCallback.Loop(false);
  25. m_SoundSetCallback = null;
  26. }
  27. }
  28. override void Stop()
  29. {
  30. if (m_SoundSetCallback)
  31. {
  32. m_SoundSetCallback.Stop();
  33. m_SoundSetCallback = null;
  34. }
  35. GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).RemoveByName(this, "PosUpdate");
  36. }
  37. void PosUpdate()
  38. {
  39. if (m_SoundSetCallback)
  40. {
  41. m_SoundSetCallback.SetPosition(m_Infected.GetPosition());
  42. }
  43. }
  44. override bool Play()
  45. {
  46. string soundset_name;
  47. soundset_name = string.Format("%1_%2_SoundSet", m_Infected.ClassName(), m_SoundSetNameRoot);
  48. m_SoundSetCallback = m_Infected.ProcessVoiceFX(soundset_name);
  49. if ( m_SoundSetCallback )
  50. {
  51. GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLaterByName(this, "PosUpdate", 0, true);
  52. return true;
  53. }
  54. string error = "[%1] No sound callback for : \'%2\' in state: \'%3\' Please define relevant SoundSet in %4";
  55. #ifdef DEVELOPER
  56. Error(string.Format(error, "ERROR", m_Infected.ClassName(), m_SoundSetNameRoot, "Zombie_SoundSets.hpp"));
  57. #else
  58. PrintToRPT("" + string.Format(error, "WARNING", m_Infected.ClassName(), m_SoundSetNameRoot, "sounds/hpp/config.cpp"));
  59. #endif
  60. return false;
  61. }
  62. }