actioneatsnowcontinuous.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. class ActionEatSnowContinuousCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousRepeat(UATimeSpent.DRINK_POND);
  6. }
  7. }
  8. class ActionEatSnowContinuous: ActionContinuousBase
  9. {
  10. void ActionEatSnowContinuous()
  11. {
  12. m_CallbackClass = ActionEatSnowContinuousCB;
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONFB_EATING_SNOW;
  14. m_FullBody = true;
  15. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH;
  16. m_Text = "#eat";
  17. }
  18. override bool IsDrink()
  19. {
  20. return true;
  21. }
  22. override typename GetInputType()
  23. {
  24. return ContinuousInteractActionInput;
  25. }
  26. override void CreateConditionComponents()
  27. {
  28. m_ConditionItem = new CCINone();
  29. m_ConditionTarget = new CCTWaterSurfaceEx(UAMaxDistances.DEFAULT,LIQUID_SNOW);
  30. }
  31. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  32. {
  33. if (item && item.IsHeavyBehaviour())
  34. return false;
  35. return player.CanEatAndDrink();
  36. }
  37. override void OnStart(ActionData action_data)
  38. {
  39. super.OnStart(action_data);
  40. action_data.m_Player.TryHideItemInHands(true);
  41. }
  42. override void OnEnd(ActionData action_data)
  43. {
  44. action_data.m_Player.TryHideItemInHands(false);
  45. }
  46. override void OnFinishProgressServer(ActionData action_data)
  47. {
  48. Param1<float> nacdata = Param1<float>.Cast(action_data.m_ActionComponent.GetACData());
  49. float amount = UAQuantityConsumed.EAT_NORMAL;
  50. action_data.m_Player.Consume(null, amount, EConsumeType.ENVIRO_SNOW);
  51. }
  52. override void OnEndAnimationLoopServer(ActionData action_data)
  53. {
  54. if (action_data.m_Player.HasBloodyHands() && !action_data.m_Player.GetInventory().FindAttachment(InventorySlots.GLOVES))
  55. {
  56. action_data.m_Player.SetBloodyHandsPenalty();
  57. }
  58. }
  59. override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
  60. {
  61. super.WriteToContext(ctx, action_data);
  62. if (HasTarget())
  63. {
  64. ctx.Write(action_data.m_Target.GetCursorHitPos());
  65. return;
  66. }
  67. ctx.Write(vector.Zero);
  68. }
  69. override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
  70. {
  71. super.ReadFromContext(ctx, action_recive_data);
  72. if (HasTarget())
  73. {
  74. vector cursorPosition;
  75. if (!ctx.Read(cursorPosition))
  76. return false;
  77. action_recive_data.m_Target.SetCursorHitPos(cursorPosition);
  78. }
  79. return true;
  80. }
  81. }