Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuousrepeat.c
Go to the documentation of this file.
2 {
3  protected float m_TimeElpased;
4  protected float m_TotalTimeElpased;
5  protected float m_TimeToComplete;
6  protected float m_DefaultTimeToComplete;
7  protected ref Param1<float> m_SpentUnits;
8 
9  void CAContinuousRepeat( float time_to_complete_action )
10  {
11  m_DefaultTimeToComplete = time_to_complete_action;
12  }
13 
14  override void Setup( ActionData action_data )
15  {
16  if ( !m_SpentUnits )
17  {
18  m_SpentUnits = new Param1<float>(0);
19  }
20  else
21  {
22  m_SpentUnits.param1 = 0;
23  }
24 
25  m_TimeToComplete = action_data.m_Player.GetSoftSkillsManager().SubtractSpecialtyBonus( m_DefaultTimeToComplete, m_Action.GetSpecialtyWeight(), true);
26  }
27 
28  override int Execute( ActionData action_data )
29  {
30  if ( !action_data.m_Player )
31  {
32  return UA_ERROR;
33  }
34 
35  if ( m_TimeElpased < m_TimeToComplete )
36  {
37  m_TimeElpased += action_data.m_Player.GetDeltaT();
38  m_TotalTimeElpased += action_data.m_Player.GetDeltaT();
39  return UA_PROCESSING;
40  }
41  else
42  {
43  m_SpentUnits.param1 = m_TimeElpased;
44  SetACData(m_SpentUnits);
45  m_TimeElpased = m_TimeToComplete - m_TimeElpased;
46  OnCompletePogress(action_data);
47  return UA_PROCESSING;
48  }
49  }
50 
51  override int Cancel( ActionData action_data )
52  {
53  if ( m_SpentUnits )
54  {
55  m_SpentUnits.param1 = m_TotalTimeElpased;
56  SetACData(m_SpentUnits);
57  }
58  return UA_CANCEL;
59  }
60 
61  override float GetProgress()
62  {
63  float progress = m_TimeElpased/m_TimeToComplete;
64  //Print("progress: " + progress + " | m_TimeElpased: " + m_TimeElpased + " | m_TimeToComplete: " + m_TimeToComplete);
65  return progress;
66  }
67 
68  void SetProgress(float value)
69  {
70  m_TimeElpased = value;
71  }
72 };
CAContinuousBase
Definition: cacontinuousbase.c:1
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
CAContinuousRepeat
Definition: cacontinuousrepeat.c:1
UA_CANCEL
const int UA_CANCEL
Definition: constants.c:437
ActionData
Definition: actionbase.c:20
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
m_Action
enum ActionInputType m_Action