largetentbackpack.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. class LargeTentBackPack extends Backpack_Base
  2. {
  3. ref protected EffectSound m_RepackingLoopSound;
  4. void LargeTentBackPack()
  5. {
  6. m_RepackingLoopSound = new EffectSound;
  7. }
  8. void ~LargeTentBackPack()
  9. {
  10. SEffectManager.DestroyEffect( m_RepackingLoopSound );
  11. }
  12. override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
  13. {
  14. super.OnRPC(sender, rpc_type, ctx);
  15. Param1<bool> p = new Param1<bool>(false);
  16. if (!ctx.Read(p))
  17. return;
  18. bool play = p.param1;
  19. switch (rpc_type)
  20. {
  21. case SoundTypeTent.REPACK:
  22. if ( play )
  23. {
  24. PlayRepackingLoopSound();
  25. }
  26. else
  27. {
  28. StopRepackingLoopSound();
  29. }
  30. break;
  31. }
  32. }
  33. void PlayRepackingLoopSound()
  34. {
  35. if ( !m_RepackingLoopSound || !m_RepackingLoopSound.IsSoundPlaying() )
  36. {
  37. m_RepackingLoopSound = SEffectManager.PlaySound( "largetent_deploy_SoundSet", GetPosition(), 0.5, 0.5 );
  38. }
  39. }
  40. void StopRepackingLoopSound()
  41. {
  42. m_RepackingLoopSound.SetSoundFadeOut(0.5);
  43. m_RepackingLoopSound.SoundStop();
  44. }
  45. };