actionconsume.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. class ActionConsumeCB : ActionContinuousBaseCB
  2. {
  3. override void CreateActionComponent()
  4. {
  5. m_ActionData.m_ActionComponent = new CAContinuousQuantityEdible(UAQuantityConsumed.DEFAULT, UATimeSpent.DEFAULT);
  6. }
  7. };
  8. class ActionConsume: ActionContinuousBase
  9. {
  10. void ActionConsume()
  11. {
  12. m_CallbackClass = ActionConsumeCB;
  13. m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_EAT;
  14. m_CommandUIDProne = DayZPlayerConstants.CMD_ACTIONFB_EAT;
  15. m_Text = "#eat";
  16. }
  17. override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
  18. {
  19. if (!super.ActionCondition(player, target, item))
  20. return false;
  21. return !item.GetIsFrozen() && player.CanEatAndDrink();
  22. }
  23. override bool HasProneException()
  24. {
  25. return true;
  26. }
  27. override bool HasTarget()
  28. {
  29. return false;
  30. }
  31. override void CreateConditionComponents()
  32. {
  33. m_ConditionItem = new CCINotRuinedAndEmpty();
  34. m_ConditionTarget = new CCTSelf();
  35. }
  36. override void OnEndServer(ActionData action_data)
  37. {
  38. super.OnEndServer(action_data);
  39. ItemBase item = action_data.m_MainItem;
  40. if (item && item.GetQuantity() <= 0.01)
  41. {
  42. item.SetQuantity(0);
  43. }
  44. else if (item && GetProgress(action_data) > 0)
  45. {
  46. // we don't want to inject an agent into an empty container
  47. PlayerBase player = action_data.m_Player;
  48. PluginTransmissionAgents plugin = PluginTransmissionAgents.Cast(GetPlugin(PluginTransmissionAgents));
  49. plugin.TransmitAgents(player, item, AGT_UACTION_TO_ITEM);
  50. }
  51. }
  52. };