Advertisement
Guest User

tent.c

a guest
Jun 17th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.37 KB | None | 0 0
  1. // This class deals with placement for all custom tents.
  2. // Class that deals with default tent.
  3. class CivilianTentCamo extends ItemBase
  4. {  
  5.     ref protected EffectSound                       m_DeployLoopSound;
  6.     protected Object                                CivilianTentDeployed1;
  7.     protected Object                                ClutterCutter;
  8.     private bool m_IsOpend                          = false;
  9.    
  10.     void CivilianTentCamo()
  11.     {
  12.         RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
  13.     }
  14.    
  15.     override void EEInit()
  16.     {
  17.         super.EEInit();
  18.     }
  19.  
  20.     // 1.03 requirement for all actions custom or otherwise.
  21.     override void SetActions()
  22.     {
  23.         super.SetActions();
  24.         AddAction(ActionToggleTentOpen); // 1021
  25.         AddAction(ActionPackTent); // 1022
  26.         AddAction(ActionOpenBarrel); // 1025
  27.         AddAction(ActionCloseBarrel); // 1026
  28.         AddAction(ActionTogglePlaceObject); // 527
  29.         AddAction(ActionDeployObject); // 231
  30.         AddAction(ActionPackTentCamoModded); // Custom Action.
  31.         //AddAction(ActionOpenTent); // Custom Action.
  32.         //AddAction(ActionCloseTent); // Custom Action.
  33.     }
  34.  
  35.     override void OnItemLocationChanged( EntityAI old_owner, EntityAI new_owner )
  36.     {
  37.         super.OnItemLocationChanged( old_owner, new_owner );
  38.     }  
  39.    
  40.     override void OnVariablesSynchronized()
  41.     {
  42.         super.OnVariablesSynchronized();
  43.        
  44.         if ( IsDeploySound() )
  45.         {
  46.             PlayDeploySound();
  47.         }
  48.                
  49.         if ( CanPlayDeployLoopSound() )
  50.         {
  51.             PlayDeployLoopSound();
  52.         }
  53.                    
  54.         if ( m_DeployLoopSound && !CanPlayDeployLoopSound() )
  55.         {
  56.             StopDeployLoopSound();
  57.         }
  58.     }
  59.    
  60.     //================================================================
  61.     // ADVANCED PLACEMENT
  62.     //================================================================         
  63.        
  64.     // Clutter cutter gets rid of grass clipping into the tent.
  65.     override void OnPlacementComplete( Man player )
  66.     {
  67.         super.OnPlacementComplete( player );
  68.        
  69.         PlayerBase pb = PlayerBase.Cast( player );
  70.         if ( GetGame().IsServer() )
  71.         {
  72.             PlayerBase player_base = PlayerBase.Cast( player );
  73.             vector position = player_base.GetLocalProjectionPosition();
  74.             vector orientation = player_base.GetLocalProjectionOrientation();
  75.                
  76.             CivilianTentDeployed1 = GetGame().CreateObject("CivilianTentCamoDeployed", pb.GetLocalProjectionPosition(), false );
  77.             ClutterCutter = GetGame().CreateObject("LargeTentClutterCutter", pb.GetLocalProjectionPosition(), false );
  78.             CivilianTentDeployed1.SetPosition( position );
  79.             CivilianTentDeployed1.SetOrientation( orientation );
  80.             ClutterCutter.SetPosition( position );
  81.             ClutterCutter.SetOrientation( orientation );
  82.             GetGame().RemoteObjectCreate(ClutterCutter);
  83.  
  84.             this.Delete();         
  85.         }  
  86.        
  87.         SetIsDeploySound( true );
  88.     }
  89.    
  90.     override bool IsDeployable()
  91.     {
  92.         return true;
  93.     }  
  94.    
  95.     override string GetDeploySoundset()
  96.     {
  97.         return "putDown_FenceKit_SoundSet";
  98.     }
  99.    
  100.     override string GetLoopDeploySoundset()
  101.     {
  102.         return "BarbedWire_Deploy_loop_SoundSet";
  103.     }
  104.    
  105.     void PlayDeployLoopSound()
  106.     {      
  107.         if ( GetGame().IsMultiplayer() && GetGame().IsClient() || !GetGame().IsMultiplayer() )
  108.         {      
  109.             m_DeployLoopSound = SEffectManager.PlaySound( GetLoopDeploySoundset(), GetPosition() );
  110.         }
  111.     }
  112.    
  113.     void StopDeployLoopSound()
  114.     {
  115.         if ( GetGame().IsMultiplayer() && GetGame().IsClient() || !GetGame().IsMultiplayer() )
  116.         {  
  117.             m_DeployLoopSound.SoundStop();
  118.             delete m_DeployLoopSound;
  119.         }
  120.     }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement