actionfillobject.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. class ActionFillObjectCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousTime(UATimeSpent.DEFAULT_FILL);
  6. }
  7. };
  8. class ActionFillObject: ActionContinuousBase
  9. {
  10. protected int m_ActionState;
  11. protected const int EMPTY = 0;
  12. protected const int FILLED = 1;
  13. void ActionFillObject()
  14. {
  15. m_CallbackClass = ActionFillObjectCB;
  16. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_DIG;
  17. m_FullBody = true;
  18. m_StanceMask = DayZPlayerConstants.STANCEMASK_ERECT;
  19. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
  20. }
  21. override void CreateConditionComponents()
  22. {
  23. m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
  24. m_ConditionItem = new CCINonRuined;
  25. }
  26. override void OnActionInfoUpdate( PlayerBase player, ActionTarget target, ItemBase item )
  27. {
  28. HescoBox hesco = HescoBox.Cast(target.GetObject());
  29. if( hesco.GetState() == HescoBox.UNFOLDED )
  30. {
  31. m_Text = "#empty";
  32. }
  33. else
  34. {
  35. m_Text = "#fill";
  36. }
  37. }
  38. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  39. {
  40. if ( player.IsPlacingLocal() )
  41. return false;
  42. HescoBox hesco;
  43. if ( Class.CastTo(hesco,target.GetObject()) )
  44. {
  45. if ( hesco.CanBeFilledAtPosition( player.GetPosition() ) )
  46. {
  47. if ( hesco.GetState() == HescoBox.UNFOLDED )
  48. {
  49. m_ActionState = EMPTY;
  50. return true;
  51. }
  52. else if( hesco.GetState() == HescoBox.FILLED)
  53. {
  54. m_ActionState = FILLED;
  55. return true;
  56. }
  57. }
  58. }
  59. return false;
  60. }
  61. override void OnFinishProgressServer( ActionData action_data )
  62. {
  63. HescoBox hesco;
  64. if ( Class.CastTo(hesco,action_data.m_Target.GetObject()) )
  65. {
  66. const float ITEM_DAMAGE = 5;
  67. action_data.m_MainItem.DecreaseHealth("", "", ITEM_DAMAGE);
  68. if (hesco.GetState() == HescoBox.UNFOLDED)
  69. {
  70. hesco.Fill();
  71. }
  72. else if (hesco.GetState() == HescoBox.FILLED)
  73. {
  74. hesco.Unfold();
  75. }
  76. }
  77. }
  78. override void OnFinishProgressClient( ActionData action_data )
  79. {
  80. HescoBox hesco;
  81. if ( Class.CastTo(hesco,action_data.m_Target.GetObject()) )
  82. {
  83. if ( hesco.GetState() == HescoBox.UNFOLDED )
  84. {
  85. hesco.Fill();
  86. }
  87. else if ( hesco.GetState() == HescoBox.FILLED )
  88. {
  89. hesco.Unfold();
  90. }
  91. }
  92. }
  93. };