actionopen.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. class ActionOpen: ActionSingleUseBase
  2. {
  3. void ActionOpen()
  4. {
  5. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENITEM_ONCE;
  6. m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_OPENITEM_ONCE;
  7. //m_Animation = "open";
  8. m_Text = "#open";
  9. }
  10. override void CreateConditionComponents()
  11. {
  12. m_ConditionItem = new CCINonRuined;
  13. m_ConditionTarget = new CCTNone;
  14. }
  15. override bool HasTarget()
  16. {
  17. return false;
  18. }
  19. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  20. {
  21. if (item && !item.IsOpen())
  22. {
  23. Edible_Base edible;
  24. if (Class.CastTo(edible,item) && edible.GetIsFrozen())
  25. return false;
  26. return true;
  27. }
  28. return false;
  29. }
  30. override bool ActionConditionContinue( ActionData action_data )
  31. {
  32. return true;
  33. }
  34. override void OnExecuteClient( ActionData action_data )
  35. {
  36. ClearInventoryReservationEx(action_data);
  37. }
  38. override void OnExecuteServer( ActionData action_data )
  39. {
  40. if( !GetGame().IsMultiplayer() )
  41. ClearInventoryReservationEx(action_data);
  42. action_data.m_MainItem.Open();
  43. }
  44. };