largetent.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. enum SoundTypeTent
  2. {
  3. REPACK = 1,
  4. NONE = 0,
  5. }
  6. class LargeTent extends TentBase
  7. {
  8. ref protected EffectSound m_RepackingLoopSound;
  9. void LargeTent()
  10. {
  11. m_ToggleAnimations.Insert( new ToggleAnimations("EntranceO", "EntranceC", OPENING_0), 0 );
  12. m_ToggleAnimations.Insert( new ToggleAnimations("Window1O", "Window1C", OPENING_1), 0 );
  13. m_ToggleAnimations.Insert( new ToggleAnimations("Window2O", "Window2C", OPENING_2), 0 );
  14. m_ToggleAnimations.Insert( new ToggleAnimations("Window3O", "Window3C", OPENING_3), 0 );
  15. m_ToggleAnimations.Insert( new ToggleAnimations("Window4O", "Window4C", OPENING_4), 0 );
  16. m_ToggleAnimations.Insert( new ToggleAnimations("Window5O", "Window5C", OPENING_5), 0 );
  17. m_ToggleAnimations.Insert( new ToggleAnimations("Window6O", "Window6C", OPENING_6), 0 );
  18. m_ToggleAnimations.Insert( new ToggleAnimations("Window7O", "Window7C", OPENING_7), 0 );
  19. m_ShowAnimationsWhenPitched.Insert( "Body" );
  20. /*m_ShowAnimationsWhenPitched.Insert( "EntranceO" );
  21. m_ShowAnimationsWhenPitched.Insert( "Window1O" );
  22. m_ShowAnimationsWhenPitched.Insert( "Window2O" );
  23. m_ShowAnimationsWhenPitched.Insert( "Window3O" );
  24. m_ShowAnimationsWhenPitched.Insert( "Window4O" );
  25. m_ShowAnimationsWhenPitched.Insert( "Window5O" );
  26. m_ShowAnimationsWhenPitched.Insert( "Window6O" );
  27. m_ShowAnimationsWhenPitched.Insert( "Window7O" );*/
  28. m_ShowAnimationsWhenPitched.Insert( "Pack" );
  29. m_ShowAnimationsWhenPacked.Insert( "Inventory" );
  30. m_HalfExtents = Vector(2.2, 0.3, 1.9);
  31. }
  32. void ~LargeTent()
  33. {
  34. SEffectManager.DestroyEffect( m_RepackingLoopSound );
  35. }
  36. override void OnRPC(PlayerIdentity sender, int rpc_type,ParamsReadContext ctx)
  37. {
  38. super.OnRPC(sender, rpc_type, ctx);
  39. Param1<bool> p = new Param1<bool>(false);
  40. if (ctx.Read(p))
  41. {
  42. bool play = p.param1;
  43. }
  44. switch (rpc_type)
  45. {
  46. case SoundTypeTent.REPACK:
  47. if ( play )
  48. {
  49. PlayRepackingLoopSound();
  50. }
  51. if ( !play )
  52. {
  53. StopRepackingLoopSound();
  54. }
  55. break;
  56. }
  57. }
  58. void PlayRepackingLoopSound()
  59. {
  60. if ( !m_RepackingLoopSound || !m_RepackingLoopSound.IsSoundPlaying() )
  61. {
  62. m_RepackingLoopSound = SEffectManager.PlaySound( "largetent_deploy_SoundSet", GetPosition(), 0.5, 0.5 );
  63. }
  64. }
  65. void StopRepackingLoopSound()
  66. {
  67. m_RepackingLoopSound.SetSoundFadeOut(0.5);
  68. m_RepackingLoopSound.SoundStop();
  69. }
  70. override void EEInit()
  71. {
  72. super.EEInit();
  73. }
  74. override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
  75. {
  76. super.OnItemLocationChanged(old_owner, new_owner);
  77. }
  78. override string GetSoundOpen()
  79. {
  80. return "LargeTent_Door_Open_SoundSet";
  81. }
  82. override string GetSoundClose()
  83. {
  84. return "LargeTent_Door_Close_SoundSet";
  85. }
  86. override string GetSoundOpenWindow()
  87. {
  88. return "LargeTent_Window_Open_SoundSet";
  89. }
  90. override string GetSoundCloseWindow()
  91. {
  92. return "LargeTent_Window_Close_SoundSet";
  93. }
  94. override bool HasClutterCutter()
  95. {
  96. return true;
  97. }
  98. override string GetClutterCutter()
  99. {
  100. return "LargeTentClutterCutter";
  101. }
  102. //================================================================
  103. // ADVANCED PLACEMENT
  104. //================================================================
  105. override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
  106. {
  107. super.OnPlacementComplete( player, position, orientation );
  108. PlayerBase pb = PlayerBase.Cast( player );
  109. if ( GetGame().IsServer() )
  110. {
  111. if ( !m_ClutterCutter )
  112. {
  113. m_ClutterCutter = GetGame().CreateObjectEx( "LargeTentClutterCutter", pb.GetLocalProjectionPosition(), ECE_PLACE_ON_SURFACE );
  114. m_ClutterCutter.SetOrientation( pb.GetLocalProjectionOrientation() );
  115. }
  116. }
  117. }
  118. override string GetDeploySoundset()
  119. {
  120. return "placeLargeTent_SoundSet";
  121. }
  122. override string GetLoopDeploySoundset()
  123. {
  124. return "largetent_deploy_SoundSet";
  125. }
  126. };