Advertisement
DeAmouSE

Untitled

Oct 12th, 2020
4,425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. moodded class class ActionDismantlePart: ActionContinuousBase
  2. {
  3.     override protected bool DismantleCondition( PlayerBase player, ActionTarget target, ItemBase item, bool camera_check )
  4.     {    
  5.         if ( player && !player.IsLeaning() )
  6.         {
  7.             Object target_object = target.GetObject();
  8.             EntityAI target_entity;
  9.             if ( target_object && target_object.CanUseConstruction() )
  10.             {
  11.                
  12.                 string part_name = target_object.GetActionComponentName( target.GetComponentIndex() );
  13.                
  14.                 BaseBuildingBase base_building = BaseBuildingBase.Cast( target_object );
  15.                 Construction construction = base_building.GetConstruction();        
  16.                 ConstructionPart construction_part = construction.GetConstructionPartToDismantle( part_name, item );
  17.                
  18.                 if ( construction_part )
  19.                 {
  20.                    
  21.                     //invalid on gate if the gate is opened
  22.                     if ( construction_part.IsGate() && base_building.IsOpened() )
  23.                         return false;
  24.                    
  25.                     //camera and position checks
  26.                     bool checked = false;
  27.                    
  28.                     if ( construction_part.IsBase() )
  29.                         checked = true;
  30.                    
  31.                     if ( !checked && base_building.IsPlayerInside( player, part_name ) && !player.GetInputController().CameraIsFreeLook() )
  32.                     {
  33.                         //Camera check (client-only)
  34.                         if ( camera_check )
  35.                         {
  36.                             if ( GetGame() && ( !GetGame().IsMultiplayer() || GetGame().IsClient() ) )
  37.                             {
  38.                                 if ( base_building.IsFacingCamera( part_name ) )
  39.                                 {
  40.                                     return false;
  41.                                 }
  42.                             }
  43.                         }
  44.  
  45.                         checked = true;
  46.                     }
  47.  
  48.                     if ( checked )
  49.                     {
  50.                         ConstructionActionData construction_action_data = player.GetConstructionActionData();
  51.                         construction_action_data.SetTargetPart( construction_part );
  52.                        
  53.                         return true;
  54.                     }
  55.                 }
  56.             }
  57.         }
  58.        
  59.         return false;
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement