Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
cacontinuousfillpowergenerator.c
Go to the documentation of this file.
2 {
3  void CAContinuousFillPowerGenerator( float quantity_filled_per_second , int liquid_type )
4  {
5  m_QuantityFilledPerSecond = quantity_filled_per_second;
6  m_liquid_type = liquid_type;
7  }
8 
9  override void Setup( ActionData action_data )
10  {
11  m_TimeElpased = 0;
12 
13  if ( !m_SpentUnits )
14  {
15  m_SpentUnits = new Param1<float>(0);
16  }
17  else
18  {
19  m_SpentUnits.param1 = 0;
20  }
21 
22  EntityAI pg = EntityAI.Cast(action_data.m_Target.GetObject()); // get power generator
23  m_QuantityFilledPerSecond *= Math.Min(action_data.m_MainItem.GetLiquidThroughputCoef(),pg.GetLiquidThroughputCoef());
24 
25  m_ItemQuantity = action_data.m_MainItem.GetQuantity();
26  m_TargetUnits = pg.GetCompEM().GetEnergyMax() - pg.GetCompEM().GetEnergy();
27  m_AdjustedQuantityFilledPerSecond = action_data.m_Player.GetSoftSkillsManager().AddSpecialtyBonus( m_QuantityFilledPerSecond, m_Action.GetSpecialtyWeight(), true );
28  }
29 
30  override int Execute( ActionData action_data )
31  {
32  if ( !action_data.m_Player )
33  {
34  return UA_ERROR;
35  }
36 
37  PowerGeneratorBase pg = PowerGeneratorBase.Cast(action_data.m_Target.GetObject()); // get power generator
38 
39  if ( pg.GetFuel() >= pg.GetMaxFuel() )
40  {
41  return UA_FINISHED;
42  }
43  else
44  {
45  if ( m_SpentQuantity_total < m_TargetUnits )
46  {
47  m_SpentQuantity += m_AdjustedQuantityFilledPerSecond * action_data.m_Player.GetDeltaT();
48  m_TimeElpased += action_data.m_Player.GetDeltaT();
49 
50  if ( m_TimeElpased >= m_DefaultTimeStep )
51  {
52  CalcAndSetQuantity( action_data );
53  m_TimeElpased = 0;
54  //Setup(action_data); //reset data after repeat
55  }
56  return UA_PROCESSING;
57  }
58  else
59  {
60  CalcAndSetQuantity( action_data );
61  OnCompletePogress(action_data);
62  return UA_FINISHED;
63  }
64  }
65  }
66 
67  override void CalcAndSetQuantity( ActionData action_data )
68  {
69  m_SpentQuantity_total += m_SpentQuantity;
70 
71  if ( m_SpentUnits )
72  {
73  m_SpentUnits.param1 = m_SpentQuantity;
74  SetACData(m_SpentUnits);
75  }
76 
77 
78  if ( GetGame().IsServer() )
79  {
80  PowerGeneratorBase pg = PowerGeneratorBase.Cast(action_data.m_Target.GetObject()); // get power generator
81  int consumed_fuel = pg.AddFuel( m_SpentQuantity );
82  action_data.m_MainItem.AddQuantity( -consumed_fuel );
83  }
84 
85  m_SpentQuantity = 0;
86  }
87 };
GetGame
proto native CGame GetGame()
CAContinuousFill
Definition: cacontinuousfill.c:1
UA_ERROR
const int UA_ERROR
Definition: constants.c:455
PowerGeneratorBase
PumpkinHelmet PowerGeneratorBase
UA_FINISHED
const int UA_FINISHED
Definition: constants.c:436
ActionData
Definition: actionbase.c:20
CAContinuousFillPowerGenerator
Definition: cacontinuousfillpowergenerator.c:1
UA_PROCESSING
const int UA_PROCESSING
Definition: constants.c:434
Math
Definition: enmath.c:6
m_Action
enum ActionInputType m_Action
EntityAI
Definition: building.c:5