Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuoustimecooking.c
Go to the documentation of this file.
2 {
3  const float TIME_DAMAGE_THRESHOLD = 5.0;
4 
5  protected float m_LocalTimeElpased;
6  protected float m_TimeElapsed;
7  protected float m_TimeElapsedRepeat;
8  protected float m_TimeElapsedDamage;
9  protected ref Param1<float> m_SpentUnits;
10 
11  protected float m_TimeToCook;
12  protected float m_AdjustedTimeToCook;
13  protected Cooking m_CookingProcess;
14  protected Edible_Base m_ItemToCook;
15  protected float m_CookingUpdateTime;
16  protected float m_AdjustedCookingUpdateTime;
17 
18  void CAContinuousTimeCooking(float cooking_update_time)
19  {
20  m_CookingUpdateTime = cooking_update_time;
21  }
22 
23  override void Setup(ActionData action_data)
24  {
25  m_TimeElapsedRepeat = 0;
26  m_TimeElapsedDamage = 0;
27 
28  if (!m_SpentUnits)
29  {
30  m_SpentUnits = new Param1<float>(0);
31  }
32  else
33  {
34  m_SpentUnits.param1 = 0;
35  }
36 
37  //fireplace & cooking process
38  FireplaceBase fireplace = FireplaceBase.Cast(action_data.m_Target.GetObject());
39  m_CookingProcess = fireplace.GetCookingProcess();
40  m_ItemToCook = m_CookingProcess.GetFoodOnStick(action_data.m_MainItem);
41  m_TimeToCook = m_CookingProcess.GetTimeToCook(m_ItemToCook, CookingMethodType.BAKING);
42 
43  //update elapsed time
44  m_TimeElapsed = m_ItemToCook.GetFoodStage().GetCookingTime();
45 
46  //SoftSkill implementation to hasten Cooking
47  m_AdjustedCookingUpdateTime = action_data.m_Player.GetSoftSkillsManager().SubtractSpecialtyBonus(m_CookingUpdateTime, m_Action.GetSpecialtyWeight(), true);
48  m_AdjustedTimeToCook = action_data.m_Player.GetSoftSkillsManager().SubtractSpecialtyBonus(m_TimeToCook, m_Action.GetSpecialtyWeight(), true);
49  }
50 
51  override int Execute(ActionData action_data)
52  {
53  if ( !action_data.m_Player )
54  {
55  return UA_ERROR;
56  }
57 
58  int cooking_state_update = 0;
59  float cooking_time = m_ItemToCook.GetFoodStage().GetCookingTime();
60  if (m_TimeToCook > cooking_time)
61  {
62  m_TimeElapsed += action_data.m_Player.GetDeltaT();
63  m_TimeElapsedRepeat += action_data.m_Player.GetDeltaT();
64 
65  if (m_TimeElapsedRepeat >= m_AdjustedCookingUpdateTime)
66  {
67  cooking_state_update = m_CookingProcess.CookOnStick(m_ItemToCook, m_CookingUpdateTime);
68 
69  if (GetGame().IsServer())
70  {
71  m_TimeElapsedDamage += m_TimeElapsedRepeat;
72 
73  if (m_TimeElapsedDamage >= TIME_DAMAGE_THRESHOLD)
74  {
75  m_TimeElapsedDamage = 0;
76  action_data.m_MainItem.DecreaseHealth(GameConstants.FIRE_ATTACHMENT_DAMAGE_PER_SECOND * TIME_DAMAGE_THRESHOLD, false);
77  }
78  }
79 
80  if (cooking_state_update == 1)
81  {
82  Setup(action_data);
83 
84  if (GetGame().IsServer())
85  {
86  action_data.m_Player.GetSoftSkillsManager().AddSpecialty( m_Action.GetSpecialtyWeight());
87  }
88  else
89  {
90  if (m_ItemToCook.IsMeat() && m_ItemToCook.GetFoodStage().GetFoodStageType() == FoodStageType.BAKED)
91  {
92  GetGame().GetAnalyticsClient().OnActionCookedSteak();
93  }
94  }
95  }
96 
97  m_TimeElapsedRepeat = 0;
98  }
99 
100  return UA_PROCESSING;
101  }
102  else
103  {
104  if (m_SpentUnits)
105  {
106  m_SpentUnits.param1 = m_TimeElapsed;
107  SetACData(m_SpentUnits);
108  }
109  OnCompletePogress(action_data);
110  return UA_FINISHED;
111  }
112  }
113 
114  override float GetProgress()
115  {
116  if (m_AdjustedTimeToCook != 0)
117  {
118  return m_TimeElapsed/m_AdjustedTimeToCook;
119  }
120 
121  return 1;
122  }
123 };
GetGame
proto native CGame GetGame()
CAContinuousBase
Definition: cacontinuousbase.c:1
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
m_CookingProcess
protected ref Cooking m_CookingProcess
determines how fast will the fuel item burn before spending (lower is better)
Definition: fireplacebase.c:40
CAContinuousTimeCooking
Definition: cacontinuoustimecooking.c:1
FireplaceBase
Definition: barrelholes_colorbase.c:1
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionData
Definition: actionbase.c:20
FoodStageType
FoodStageType
Definition: foodstage.c:1
GameConstants
Definition: constants.c:612
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
CookingMethodType
CookingMethodType
Definition: cooking.c:1
m_Action
enum ActionInputType m_Action
Edible_Base
Definition: bearsteakmeat.c:1