Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuousquantity.c
Go to the documentation of this file.
2 {
3  protected float m_ItemQuantity;
4  protected float m_SpentQuantity;
5  protected float m_ItemMaxQuantity;
6  protected float m_QuantityUsedPerSecond;
7  protected float m_AdjustedQuantityUsedPerSecond;
8  protected ref Param1<float> m_SpentUnits;
9 
10  void CAContinuousQuantity( float quantity_used_per_second )
11  {
12  m_QuantityUsedPerSecond = quantity_used_per_second;
13  }
14 
15  override void Setup( ActionData action_data )
16  {
17  m_SpentQuantity = 0;
18  if ( !m_SpentUnits )
19  {
20  m_SpentUnits = new Param1<float>(0);
21  }
22  else
23  {
24  m_SpentUnits.param1 = 0;
25  }
26  m_ItemMaxQuantity = action_data.m_MainItem.GetQuantityMax();
27  m_ItemQuantity = action_data.m_MainItem.GetQuantity();
28  }
29 
30 
31  override int Execute( ActionData action_data )
32  {
33  if ( !action_data.m_Player )
34  {
35  return UA_ERROR;
36  }
37 
38  if ( m_ItemQuantity <= 0 )
39  {
40  return UA_FINISHED;
41  }
42  else
43  {
44  if ( m_SpentQuantity < m_ItemQuantity )
45  {
46  m_AdjustedQuantityUsedPerSecond = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( m_QuantityUsedPerSecond, m_Action.GetSpecialtyWeight(), true);
47  m_SpentQuantity += m_AdjustedQuantityUsedPerSecond * action_data.m_Player.GetDeltaT();
48  return UA_PROCESSING;
49  }
50  else
51  {
52  CalcAndSetQuantity( action_data );
53  OnCompletePogress(action_data);
54  return UA_FINISHED;
55  }
56  }
57  }
58 
59  override int Cancel( ActionData action_data )
60  {
61  if ( !action_data.m_Player )
62  {
63  return UA_ERROR;
64  }
65 
66  CalcAndSetQuantity( action_data );
67  return UA_INTERRUPT;
68  }
69 
70  override float GetProgress()
71  {
72  //float progress = m_SpentQuantity/m_ItemQuantity;
73  return m_SpentQuantity/m_ItemQuantity;
74  }
75 
76  //---------------------------------------------------------------------------
77 
78 
79  void CalcAndSetQuantity( ActionData action_data )
80  {
81  if ( GetGame().IsServer() )
82  {
83  if ( m_SpentUnits )
84  {
85  m_SpentUnits.param1 = m_SpentQuantity;
86  SetACData(m_SpentUnits);
87  }
88 
89  if (action_data.m_MainItem)
90  {
91  action_data.m_MainItem.AddQuantity(- m_SpentQuantity,false,false);
92  }
93  }
94  }
95 };
UA_INTERRUPT
const int UA_INTERRUPT
Definition: constants.c:438
GetGame
proto native CGame GetGame()
CAContinuousBase
Definition: cacontinuousbase.c:1
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
CAContinuousQuantity
Definition: cacontinuousquantity.c:1
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionData
Definition: actionbase.c:20
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
m_Action
enum ActionInputType m_Action