Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuoustime.c
Go to the documentation of this file.
2 {
3  protected float m_LocalTimeElpased;
4  protected float m_TimeElpased;
5  protected float m_AdjustedTimeToComplete;
6  protected float m_DefaultTimeToComplete;
7  protected ref Param1<float> m_SpentUnits;
8 
9  void CAContinuousTime( float time_to_complete_action )
10  {
11  m_DefaultTimeToComplete = time_to_complete_action;
12  }
13 
14  override void Setup( ActionData action_data )
15  {
16  m_TimeElpased = 0;
17  if ( !m_SpentUnits )
18  {
19  m_SpentUnits = new Param1<float>(0);
20  }
21  else
22  {
23  m_SpentUnits.param1 = 0;
24  }
25 
26  m_AdjustedTimeToComplete = action_data.m_Player.GetSoftSkillsManager().SubtractSpecialtyBonus( m_DefaultTimeToComplete, m_Action.GetSpecialtyWeight(), true);
27  }
28 
29  override int Execute( ActionData action_data )
30  {
31  if ( m_DefaultTimeToComplete < 0 ) //for infinite actions
32  {
33  return UA_PROCESSING;
34  }
35 
36  if ( !action_data.m_Player )
37  {
38  return UA_ERROR;
39  }
40 
41  if ( m_TimeElpased < m_AdjustedTimeToComplete )
42  {
43  m_TimeElpased += action_data.m_Player.GetDeltaT();
44  return UA_PROCESSING;
45  }
46  else
47  {
48  if ( m_SpentUnits )
49  {
50  m_SpentUnits.param1 = m_TimeElpased;
51  SetACData(m_SpentUnits);
52  }
53  OnCompletePogress(action_data);
54  return UA_FINISHED;
55  }
56  }
57 
58  override int Cancel(ActionData action_data )
59  {
60  if ( m_SpentUnits )
61  {
62  m_SpentUnits.param1 = m_TimeElpased;
63  SetACData(m_SpentUnits);
64  }
65  if ( m_DefaultTimeToComplete < 0 ) //for infinite actions
66  {
67  return UA_FINISHED;
68  }
69 
70  return UA_CANCEL;
71  }
72 
73  override float GetProgress()
74  {
75  if ( m_AdjustedTimeToComplete != 0 )
76  {
77  //progress = m_TimeElpased/m_AdjustedTimeToComplete;
78  return m_TimeElpased/m_AdjustedTimeToComplete;
79  }
80  else
81  {
82  Print("USER ACTION COMPONENT CONTINUOUS TIME - WRONG TIME TO COMPLETE CALCULATION - Incorrect data for progress bar!");
83  }
84  return 1;
85  }
86 
87 };
CAContinuousBase
Definition: cacontinuousbase.c:1
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
CAContinuousTime
Definition: cacontinuoustime.c:1
Print
proto void Print(void var)
Prints content of variable to console/log.
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
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
m_Action
enum ActionInputType m_Action