Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- moodded class class ActionDismantlePart: ActionContinuousBase
- {
- override protected bool DismantleCondition( PlayerBase player, ActionTarget target, ItemBase item, bool camera_check )
- {
- if ( player && !player.IsLeaning() )
- {
- Object target_object = target.GetObject();
- EntityAI target_entity;
- if ( target_object && target_object.CanUseConstruction() )
- {
- string part_name = target_object.GetActionComponentName( target.GetComponentIndex() );
- BaseBuildingBase base_building = BaseBuildingBase.Cast( target_object );
- Construction construction = base_building.GetConstruction();
- ConstructionPart construction_part = construction.GetConstructionPartToDismantle( part_name, item );
- if ( construction_part )
- {
- //invalid on gate if the gate is opened
- if ( construction_part.IsGate() && base_building.IsOpened() )
- return false;
- //camera and position checks
- bool checked = false;
- if ( construction_part.IsBase() )
- checked = true;
- if ( !checked && base_building.IsPlayerInside( player, part_name ) && !player.GetInputController().CameraIsFreeLook() )
- {
- //Camera check (client-only)
- if ( camera_check )
- {
- if ( GetGame() && ( !GetGame().IsMultiplayer() || GetGame().IsClient() ) )
- {
- if ( base_building.IsFacingCamera( part_name ) )
- {
- return false;
- }
- }
- }
- checked = true;
- }
- if ( checked )
- {
- ConstructionActionData construction_action_data = player.GetConstructionActionData();
- construction_action_data.SetTargetPart( construction_part );
- return true;
- }
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement