actionwaterplant.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. return plant.NeedsWater() && item.GetQuantity() > 0 && !item.GetIsFrozen();
  32. }
  33. return false;
  34. }
  35. override void OnFinishProgressServer( ActionData action_data )
  36. {
  37. Object targetObject = action_data.m_Target.GetObject();
  38. if ( targetObject != NULL && targetObject.IsInherited(PlantBase) )
  39. {
  40. PlantBase plant = PlantBase.Cast( targetObject );
  41. Param1<float> nacdata = Param1<float>.Cast( action_data.m_ActionComponent.GetACData() );
  42. float water = nacdata.param1;
  43. Slot slot = plant.GetSlot();
  44. slot.GiveWater( water );
  45. }
  46. }
  47. override void OnFinishProgressClient( ActionData action_data )
  48. {
  49. Object targetObject = action_data.m_Target.GetObject();
  50. if ( targetObject != NULL && targetObject.IsInherited(PlantBase) )
  51. {
  52. PlantBase plant = PlantBase.Cast( targetObject );
  53. Param1<float> nacdata = Param1<float>.Cast( action_data.m_ActionComponent.GetACData() );
  54. float water = nacdata.param1;
  55. Slot slot = plant.GetSlot();
  56. slot.GiveWater( water );
  57. }
  58. }
  59. };