actionwaterplant.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. class ActionWaterPlantCB : ActionContinuousBaseCB
  2. {
  3. private const float QUANTITY_USED_PER_SEC = 150;
  4. override void CreateActionComponent()
  5. {
  6. m_ActionData.m_ActionComponent = new CAContinuousWaterPlant(QUANTITY_USED_PER_SEC);
  7. }
  8. };
  9. class ActionWaterPlant: ActionContinuousBase
  10. {
  11. void ActionWaterPlant()
  12. {
  13. m_CallbackClass = ActionWaterPlantCB;
  14. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_EMPTY_VESSEL;
  15. m_FullBody = true;
  16. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
  17. m_Text = "#water_plant";
  18. m_LockTargetOnUse = false;
  19. }
  20. override void CreateConditionComponents()
  21. {
  22. m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
  23. m_ConditionItem = new CCINotRuinedAndEmpty;
  24. }
  25. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  26. {
  27. Object targetObject = target.GetObject();
  28. if ( targetObject != NULL && targetObject.IsInherited(PlantBase) && item != NULL && !item.IsDamageDestroyed() )
  29. {
  30. PlantBase plant = PlantBase.Cast( targetObject );
  31. if ( plant.NeedsWater() && item.GetQuantity() > 0 )
  32. {
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. override void OnFinishProgressServer( ActionData action_data )
  39. {
  40. Object targetObject = action_data.m_Target.GetObject();
  41. if ( targetObject != NULL && targetObject.IsInherited(PlantBase) )
  42. {
  43. PlantBase plant = PlantBase.Cast( targetObject );
  44. Param1<float> nacdata = Param1<float>.Cast( action_data.m_ActionComponent.GetACData() );
  45. float water = nacdata.param1;
  46. Slot slot = plant.GetSlot();
  47. slot.GiveWater( water );
  48. }
  49. }
  50. override void OnFinishProgressClient( ActionData action_data )
  51. {
  52. Object targetObject = action_data.m_Target.GetObject();
  53. if ( targetObject != NULL && targetObject.IsInherited(PlantBase) )
  54. {
  55. PlantBase plant = PlantBase.Cast( targetObject );
  56. Param1<float> nacdata = Param1<float>.Cast( action_data.m_ActionComponent.GetACData() );
  57. float water = nacdata.param1;
  58. Slot slot = plant.GetSlot();
  59. slot.GiveWater( water );
  60. }
  61. }
  62. };