actionattachonproxy.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. class ActionAttachOnProxy: ActionAttach
  2. {
  3. void ActionAttachOnProxy()
  4. {
  5. m_Text = "#attach";
  6. }
  7. override void CreateConditionComponents()
  8. {
  9. m_ConditionItem = new CCINonRuined;
  10. m_ConditionTarget = new CCTCursor;
  11. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_ATTACHITEM;
  12. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT | DayZPlayerConstants.STANCEMASK_CROUCH;
  13. }
  14. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  15. {
  16. Object targetObject = target.GetObject();
  17. Object targetParent = target.GetParent();
  18. EntityAI target_entity = EntityAI.Cast( targetParent );
  19. EntityAI item_entity = item;
  20. if ( targetParent )
  21. {
  22. if ( target_entity && item_entity )
  23. {
  24. if ( target_entity.GetInventory() && target_entity.GetInventory().CanAddAttachment( item_entity ) )
  25. {
  26. return true;
  27. }
  28. }
  29. }
  30. return false;
  31. }
  32. override void OnExecuteClient( ActionData action_data )
  33. {
  34. super.OnExecuteClient( action_data );
  35. if ( action_data.m_Player.IsPlacingLocal() )
  36. {
  37. action_data.m_Player.TogglePlacingLocal();
  38. }
  39. }
  40. }