actioncookonstick.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. class ActionCookOnStickCB : ActionContinuousBaseCB
  2. {
  3. private const float COOKING_ON_STICK_UPDATE_TIME = 1;
  4. override void CreateActionComponent()
  5. {
  6. m_ActionData.m_ActionComponent = new CAContinuousTimeCooking( COOKING_ON_STICK_UPDATE_TIME );
  7. }
  8. };
  9. class ActionCookOnStick: ActionContinuousBase
  10. {
  11. void ActionCookOnStick()
  12. {
  13. m_CallbackClass = ActionCookOnStickCB;
  14. m_CommandUID = DayZPlayerConstants.CMD_GESTUREFB_CAMPFIRE;
  15. m_FullBody = true;
  16. m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
  17. m_SpecialtyWeight = UASoftSkillsWeight.ROUGH_LOW;
  18. m_LockTargetOnUse = false;
  19. m_Text = "#cook_on_stick";
  20. }
  21. override void CreateConditionComponents()
  22. {
  23. m_ConditionTarget = new CCTNonRuined(UAMaxDistances.DEFAULT);
  24. m_ConditionItem = new CCINonRuined;
  25. }
  26. override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
  27. {
  28. FireplaceBase fireplace_target = FireplaceBase.Cast(target.GetObject());
  29. Object targetObject = target.GetObject();
  30. Edible_Base item_on_stick = Edible_Base.Cast(item.GetAttachmentByType(Edible_Base));
  31. if (fireplace_target && fireplace_target.CanCookOnStick() && item_on_stick && item_on_stick.CanBeCookedOnStick())
  32. {
  33. //fireplace
  34. if (fireplace_target.IsBaseFireplace())
  35. {
  36. Fireplace fireplace = Fireplace.Cast(fireplace_target);
  37. if (fireplace && fireplace.IsOven())
  38. return false;
  39. if (fireplace_target.CanCookOnStick())
  40. return true;
  41. }
  42. //fireplace indoor
  43. if (fireplace_target.IsFireplaceIndoor())
  44. {
  45. if (fireplace_target.CanCookOnStick())
  46. return true;
  47. }
  48. }
  49. return false;
  50. }
  51. override void OnEndServer(ActionData action_data)
  52. {
  53. super.OnEndServer(action_data);
  54. ItemBase stick = action_data.m_MainItem;
  55. Edible_Base item_on_stick = Edible_Base.Cast(stick.GetAttachmentByType(Edible_Base));
  56. if (item_on_stick)
  57. {
  58. item_on_stick.MakeSoundsOnClient(false);
  59. }
  60. }
  61. };