actionclose.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. class ActionClose: ActionSingleUseBase
  2. {
  3. void ActionClose()
  4. {
  5. m_Text = "#close";
  6. }
  7. override void CreateConditionComponents()
  8. {
  9. m_ConditionItem = new CCINonRuined;
  10. m_ConditionTarget = new CCTNone;
  11. }
  12. override bool HasTarget()
  13. {
  14. return false;
  15. }
  16. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  17. {
  18. if ( item && item.IsOpen() )
  19. {
  20. return true;
  21. }
  22. return false;
  23. }
  24. //setup
  25. override bool SetupAction( PlayerBase player, ActionTarget target, ItemBase item, out ActionData action_data, Param extra_data = NULL )
  26. {
  27. if( super.SetupAction( player, target, item, action_data, extra_data ) )
  28. {
  29. SetCloseAnimation( item );
  30. return true;
  31. }
  32. return false;
  33. }
  34. void SetCloseAnimation( ItemBase item )
  35. {
  36. switch( item.Type() )
  37. {
  38. case Compass:
  39. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_CLOSEITEM_ONCE;
  40. break;
  41. case TelescopicBaton:
  42. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_PICKUP_HANDS;
  43. break;
  44. }
  45. }
  46. override void OnExecuteServer( ActionData action_data )
  47. {
  48. action_data.m_MainItem.Close();
  49. }
  50. };