actioncookonstick.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.IsOven() && fireplace_target.CanCookOnStick())
  38. {
  39. return true;
  40. }
  41. }
  42. //fireplace indoor
  43. if (fireplace_target.IsFireplaceIndoor())
  44. {
  45. if (fireplace_target.CanCookOnStick())
  46. {
  47. return true;
  48. }
  49. }
  50. }
  51. return false;
  52. }
  53. override void OnEndServer(ActionData action_data)
  54. {
  55. super.OnEndServer(action_data);
  56. ItemBase stick = action_data.m_MainItem;
  57. Edible_Base item_on_stick = Edible_Base.Cast(stick.GetAttachmentByType(Edible_Base));
  58. if (item_on_stick)
  59. {
  60. item_on_stick.MakeSoundsOnClient(false);
  61. }
  62. }
  63. };