Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuousquantityedible.c
Go to the documentation of this file.
2 {
3  protected float m_InitItemQuantity;
4  protected float m_SpentQuantityTotal;
5 
6  void CAContinuousQuantityEdible( float quantity_used_per_second, float time_to_repeat )
7  {
8  m_QuantityUsedPerSecond = quantity_used_per_second;
9  m_DefaultTimeToRepeat = time_to_repeat;
10  m_InitItemQuantity = -1;
11  m_SpentQuantityTotal = 0;
12  }
13 
14  override void Setup( ActionData action_data )
15  {
16  super.Setup( action_data );
17 
18  if (m_InitItemQuantity < 0)
19  {
20  m_InitItemQuantity = action_data.m_MainItem.GetQuantity();
21  }
22  }
23 
24  override void CalcAndSetQuantity( ActionData action_data )
25  {
26  //Print("Munch!");
27  if ( m_SpentUnits )
28  {
29  m_SpentUnits.param1 = m_SpentQuantity;
30  SetACData(m_SpentUnits);
31 
32  m_SpentQuantityTotal += m_SpentQuantity;
33  }
34  //m_SpentQuantity = Math.Floor(m_SpentQuantity);
35 
36  PlayerBase ntarget = PlayerBase.Cast( action_data.m_Target.GetObject() );
37  if ( ntarget )
38  {
39  if ( GetGame().IsServer() )
40  {
41  //action_data.m_MainItem.Consume(targetObject, m_SpentQuantity);
42  ntarget.Consume(action_data.m_MainItem, m_SpentQuantity, EConsumeType.ITEM_CONTINUOUS);
43 
44  }
45  }
46  else
47  {
48  if ( GetGame().IsServer() )
49  {
50  //action_data.m_MainItem.Consume(action_data.m_Player, m_SpentQuantity);
51  action_data.m_Player.Consume(action_data.m_MainItem, m_SpentQuantity, EConsumeType.ITEM_CONTINUOUS);
52  }
53  }
54  }
55 
56  override float GetProgress()
57  {
58  //return super.GetProgress();
59  if (m_SpentQuantity > 0)
60  {
61  return Math.Clamp((1 - (m_InitItemQuantity - m_SpentQuantity - m_SpentQuantityTotal ) / m_InitItemQuantity), 0, 1);
62  }
63  else
64  {
65  return Math.Clamp((1 - (m_InitItemQuantity - m_SpentQuantityTotal ) / m_InitItemQuantity), 0, 1);
66  }
67  }
68 };
GetGame
proto native CGame GetGame()
CAContinuousQuantityRepeat
Definition: cacontinuousquantityrepeat.c:1
EConsumeType
EConsumeType
Definition: econsumetype.c:1
PlayerBase
Definition: playerbaseclient.c:1
ActionData
Definition: actionbase.c:20
CAContinuousQuantityEdible
Definition: cacontinuousquantityedible.c:1
Math
Definition: enmath.c:6