Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuousempty.c
Go to the documentation of this file.
2 {
3  protected float m_TargetUnits;
4  protected float m_SpentQuantity;
5  protected float m_SpentQuantity_total;
6  protected float m_AdjustedQuantityEmptiedPerSecond;
7  protected float m_QuantityEmptiedPerSecond;
8  protected bool m_WringingClothes;
9  protected ref Param1<float> m_SpentUnits;
10  protected float m_TimeElpased;
11  protected float m_DefaultTimeStep = 0.25;
12 
13  void CAContinuousEmpty( float quantity_emptied_per_second )
14  {
15  m_QuantityEmptiedPerSecond = quantity_emptied_per_second;
16  }
17 
18  override void Setup( ActionData action_data )
19  {
20  if ( !m_SpentUnits )
21  {
22  m_SpentUnits = new Param1<float>(0);
23  }
24  else
25  {
26  m_SpentUnits.param1 = 0;
27  }
28 
29  if ( action_data.m_MainItem.IsClothing() )
30  {
31  m_WringingClothes = true;
32 
33  m_SpentQuantity = action_data.m_MainItem.GetWetMax() - action_data.m_MainItem.GetWet();
34  m_TargetUnits = action_data.m_MainItem.GetWetMax();
35  }
36  else
37  {
38  m_WringingClothes = false;
39 
40  m_SpentQuantity = action_data.m_MainItem.GetQuantityMin();
41  m_TargetUnits = action_data.m_MainItem.GetQuantity();
42  }
43 
44  m_AdjustedQuantityEmptiedPerSecond = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( m_QuantityEmptiedPerSecond, m_Action.GetSpecialtyWeight(), true );
45  }
46 
47  override int Execute( ActionData action_data )
48  {
49  if ( !action_data.m_Player )
50  {
51  return UA_ERROR;
52  }
53 
54  if ( m_WringingClothes && action_data.m_MainItem.GetWet() >= action_data.m_MainItem.GetWetMax() )
55  {
56  return UA_FINISHED;
57  }
58  else
59  {
60  if ( m_SpentQuantity_total <= m_TargetUnits )
61  {
62  m_SpentQuantity += m_AdjustedQuantityEmptiedPerSecond * action_data.m_Player.GetDeltaT();
63  m_TimeElpased += action_data.m_Player.GetDeltaT();
64 
65  if ( m_TimeElpased >= m_DefaultTimeStep )
66  {
67  CalcAndSetQuantity( action_data );
68  m_TimeElpased = 0;
69  }
70  return UA_PROCESSING;
71  }
72  else
73  {
74  CalcAndSetQuantity( action_data );
75  OnCompletePogress(action_data);
76  return UA_FINISHED;
77  }
78  }
79  }
80 
81  override int Cancel( ActionData action_data )
82  {
83  if ( !action_data.m_Player || !action_data.m_MainItem )
84  {
85  return UA_ERROR;
86  }
87 
88  CalcAndSetQuantity( action_data );
89  return UA_CANCEL;
90  }
91 
92  override float GetProgress()
93  {
94  return m_SpentQuantity_total / m_TargetUnits;
95  }
96 
97  //---------------------------------------------------------------------------
98 
99  void CalcAndSetQuantity( ActionData action_data )
100  {
101  m_SpentQuantity_total += m_SpentQuantity;
102  if (GetGame().IsServer())
103  {
104  if ( m_SpentUnits )
105  {
106  m_SpentUnits.param1 = m_SpentQuantity;
107  SetACData(m_SpentUnits);
108  }
109 
110  action_data.m_MainItem.AddQuantity(-m_SpentQuantity);
111  }
112  m_SpentQuantity = 0;
113  }
114 };
GetGame
proto native CGame GetGame()
CAContinuousBase
Definition: cacontinuousbase.c:1
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
UA_CANCEL
const int UA_CANCEL
Definition: constants.c:437
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionData
Definition: actionbase.c:20
CAContinuousEmpty
Definition: cacontinuousempty.c:1
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
m_Action
enum ActionInputType m_Action