actionplantseed.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. class ActionPlantSeed: ActionSingleUseBase
  2. {
  3. void ActionPlantSeed()
  4. {
  5. m_SpecialtyWeight = UASoftSkillsWeight.PRECISE_MEDIUM;
  6. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_DROPITEM_HANDS;
  7. m_FullBody = false;
  8. m_Text = "#plant_seed";
  9. }
  10. override void CreateConditionComponents()
  11. {
  12. m_ConditionItem = new CCINonRuined;
  13. m_ConditionTarget = new CCTDummy;
  14. }
  15. override bool HasTarget()
  16. {
  17. return true;
  18. }
  19. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  20. {
  21. GardenBase targetObject = GardenBase.Cast( target.GetObject() );
  22. if ( targetObject && ( !targetObject.IsHologram() || !targetObject.IsBeingPlaced() ) )
  23. {
  24. array<string> selections = new array<string>;
  25. targetObject.GetActionComponentNameList(target.GetComponentIndex(), selections);
  26. for (int s = 0; s < selections.Count(); s++)
  27. {
  28. string selection = selections[s];
  29. Slot slot = targetObject.GetSlotBySelection( selection );
  30. if (slot)
  31. {
  32. if ( item != NULL && item.GetQuantity() > 0 && targetObject.CanPlantSeed( selection ) )
  33. {
  34. return true;
  35. }
  36. }
  37. }
  38. }
  39. return false;
  40. }
  41. override void OnExecuteServer( ActionData action_data )
  42. {
  43. Process(action_data);
  44. }
  45. override void OnExecuteClient( ActionData action_data )
  46. {
  47. //Process(action_data);
  48. }
  49. void Process( ActionData action_data )
  50. {
  51. Object targetObject = action_data.m_Target.GetObject();
  52. int slot_ID;
  53. if ( targetObject != NULL && targetObject.IsInherited(GardenBase) )
  54. {
  55. GardenBase garden_base = GardenBase.Cast( targetObject );
  56. array<string> selections = new array<string>;
  57. targetObject.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
  58. for (int s = 0; s < selections.Count(); s++)
  59. {
  60. string selection = selections[s];
  61. Slot slot = garden_base.GetSlotBySelection( selection );
  62. if (slot)
  63. {
  64. slot_ID = slot.GetSlotId();
  65. break;
  66. }
  67. }
  68. //int slot_ID = slot.GetSlotId();
  69. ItemBase seed_IB = ItemBase.Cast( action_data.m_MainItem );
  70. seed_IB.SplitIntoStackMax( garden_base, slot_ID, action_data.m_Player );
  71. }
  72. }
  73. };